question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

express-validator and unit test

See original GitHub issue

Hi!

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:closed
  • Created 9 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

0reactions
lock[bot]commented, May 31, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found