express-validator and unit test
See original GitHub issueHi!
How can i use the express-validator to do unit tests with module like mocha?
Example:
//file.js
req = {} //My custom req
exports.test = function (req, callback) {
req.checkQuery('field', 'Invalid.').notEmpty().isNumeric().isLength(4,4);
};
//Main file that require file.js
var validationTest = rewire('file.js');
validationTest.test(req, res); //Problem here! -> has no method 'checkQuery'
Issue Analytics
- State:
- Created 9 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
How can i unit test the validators? · Issue #718 · express ...
express-validator is thoroughly tested, so you don't need to unit test it. Just trust that it will work, and if it doesn't, then...
Read more >Unit testing validation with express-validator - node.js
Here's a solution for the new express-validator api (v4):. tl;dr: You can use this function: exports.testExpressValidatorMiddleware = async ...
Read more >Testing Express Validator - Jake Trent
Express-validator is a middleware for Express on Node.js that can help you validate user input. It's a lovely library.
Read more >express-validator.validationResult JavaScript and Node.js ...
Best JavaScript code snippets using express-validator.validationResult(Showing top 15 results out of 360) ... app/helpers/__tests__/response.test.js/describe.
Read more >How to Unit Test your Express Js API With Jest? - CodingPR
In the last part of this testing tutorial, we'll use the Express Validator to test the login route. First, go to routes.js and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@carlosmcp look here: http://jaketrent.com/post/testing-express-validator/
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.