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

Are our tests reliable? #592

Open
bjohansebas opened this issue Mar 6, 2025 · 2 comments
Open

Are our tests reliable? #592

bjohansebas opened this issue Mar 6, 2025 · 2 comments
Labels

Comments

@bjohansebas
Copy link
Member

We use supertest to run our tests in this module. While that tool does a great job, I'm not sure if we're making reliable tests, since Supertest also handles the body according to the content-type, which makes me question whether we're doing good tests or if in the future the tests will stop being reliable as we update that dependency.

Ref: ladjs/superagent#1812

cc: @Phillip9587, @jonchurch, @wesleytodd, @UlisesGascon

@jonchurch
Copy link
Member

jonchurch commented Mar 7, 2025

Supertest only parses the body asserts against the parsed body if you assert against an object, but when doing a string assertion it compares against the raw res.text

https://github.com/ladjs/supertest/blob/2ae1c36f48fdc5a60e8239c2d69c47e169042829/lib/test.js#L186C5-L201C22

@jonchurch
Copy link
Member

Which is to say, it's something important to think about. And we could explore lower level tests to ensure we are asserting against an unparsed response body.

Currently, we should be fine asserting against res.text by passing the body to expect as a string or regexp

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

No branches or pull requests

2 participants