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

Add integration tests #1073

Open
fedeci opened this issue Jul 31, 2021 · 5 comments
Open

Add integration tests #1073

fedeci opened this issue Jul 31, 2021 · 5 comments

Comments

@fedeci
Copy link
Member

fedeci commented Jul 31, 2021

Currently we only test units, I was thinking about adding some high level tests to better catch issues as the one addressed in #1070.
@gustavohenke what do you think?

@gustavohenke
Copy link
Member

That'd be awesome.

Fun fact, that's how express-validator used to have tests in the era before time, using supertest:
https://github.com/express-validator/express-validator/blob/v2.21.0/test/checkBodyTest.js

I really like the lib but the style back then was quite difficult to follow for me.
I'm sure we can do better this time around!

@fedeci
Copy link
Member Author

fedeci commented Aug 14, 2021

How about fixtures/snapshots where the output is the the req obj? It would give full control over what happened during the middleware execution.

@gustavohenke
Copy link
Member

Sounds good to me!

@danizavtz
Copy link

If you have a detailed specification on what should be done I can start integration tests.

@fedeci
Copy link
Member Author

fedeci commented Oct 6, 2021

Thanks for the interest @danizavtz! I hope I am not too late, but here is a list of what integration tests should do in this case:

  1. Accept an express req object as input;
  2. Perform a validation chain/set of chains on the input;
  3. Validate it against a predefined validationResult contained in a file along with the new update object;
  4. They should be easy to write and to update;

e.g.

// input file
export default {
  body: { name: 'foo' },
  query: { }
}
// chains file
body("name").isString().isLength(10)
// out file
export const errors = []
// in this case the req object was not updated, but it may not be so
export const req = {
  body: { name: 'foo' },
  query: { }
}

Please ping me if you are still interested in this and feel free to ask any question!

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

No branches or pull requests

3 participants