Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests need a refactor #14

Open
Embiggenerd opened this issue Jun 22, 2018 · 2 comments
Open

Tests need a refactor #14

Embiggenerd opened this issue Jun 22, 2018 · 2 comments

Comments

@Embiggenerd
Copy link

A lot of the tests do not throw an error.

it('should return status 401', async () => { try { await chai.request(server).get(secret); } catch (error) { expect(error.status).to.equal(401); expect(error.response.text).to.equal('Unauthorized'); } });

should be:

it('Should return 401 without token in request', async () => { try { const result = await chai.request(server).get(secret); expect(result.status).to.equal(401); expect(result.response.text).to.equal('Unauthorized'); } catch (e) { throw new Error(e); } });

Because the error in the first example isn't thrown, it causes the assertion to fail, but the test still passes. Remember, try/catch causes the error to not be thrown unless you explicitly tell it to.

@eXtremeXR
Copy link
Owner

Hey @Embiggenerd, thanks for pointing that out. I wasn't the one who wrote the tests initially, but I'll try to fix that at some point. PRs are of course welcome if anyone wants to jump in.

@Embiggenerd
Copy link
Author

I wouldn't mind actually, you helped me quite a bit. Will try to make some time soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants