nodemock | Simple Yet Powerful Mocking Framework for NodeJs | Mock library
kandi X-RAY | nodemock Summary
kandi X-RAY | nodemock Summary
[NodeMock] is a Simple, Yet Powerful Mocking Framework for NodeJs. NodeMock is a very simple to use mocking framework which can be used to mock functions in JavaScript objects. NodeMock creates mock methods in less code with more expressive manner.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nodemock
nodemock Key Features
nodemock Examples and Code Snippets
Community Discussions
Trending Discussions on nodemock
QUESTION
There is a very basic middleware, which I would like to test.
First question is what kind of test I'm using. For my understanding, I cannot write a unit test for this code. I would call that an integration test. Is that correct?
The second problem ist the test itself: I'm running into a timeout, althoug I've used done()
.
What am I doing wrong? And is that the correct way to test this middleware?
/middlewares/graphql.js
...ANSWER
Answered 2017-Nov-22 at 09:57middleware
is a function with (req, res, next)
as parameters. You send req
, res
and a callback where you handle the assertions. I.e. the assertion testing is passed in as next()
.
But there is no reason for next()
to be called when you pass in OPTIONS
as request method. The middleware will then do res.sendStatus(200)
instead. So you have to call middleware as an ordinary function instead (for this particular test).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nodemock
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page