Does it work with Supertest? Tests fail with `TypeError: Cannot read property 'status' of undefined`
See original GitHub issueI’ve spent days trying to figure out what I do wrong, checked the docs and issues, but it still fails with:
TypeError: Cannot read property 'status' of undefined
at Test.Object.<anonymous>.Test._assertStatus (node_modules/supertest/lib/test.js:263:10)
at Test.Object.<anonymous>.Test._assertFunction (node_modules/supertest/lib/test.js:281:11)
at Test.Object.<anonymous>.Test.assert (node_modules/supertest/lib/test.js:171:18)
at assert (node_modules/supertest/lib/test.js:131:12)
at node_modules/supertest/lib/test.js:128:5
at Test.Object.<anonymous>.Request.callback (node_modules/superagent/lib/node/index.js:688:3)
at ErroringClientRequest.<anonymous> (node_modules/superagent/lib/node/index.js:615:10)
at Object.onceWrapper (events.js:293:19)
at emitOne (events.js:96:13)
at ErroringClientRequest.emit (events.js:191:7)
at ErroringClientRequest.<anonymous> (node_modules/nock/lib/intercept.js:219:10)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
Does Nock work with Jest/Supertest?
I created an repo to reproduce the issue - https://github.com/rosendi/nock-test
P.S. Tested on Node 7.9.0 and 7.10.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
supertest TypeError: Cannot read properties of undefined ...
Try to execute a one-time setup. closing and re-opening the connection after every test might be the cause of the issue:
Read more >Supertest - npm
SuperTest works with any test framework, here is an example without using any test framework at all: const request = require('supertest'); ...
Read more >How to test a post request for fetching the result in javascript ...
You might need to look at the documentation for the API endpoint and see why it's producing an incompatible response. Your code is...
Read more >Writing API Tests with Jest - Rithm School
Since we are using testing libraries, these are not dependencies that will be using in production. Therefore, when we install these using npm...
Read more >How to Test Nodejs Code and RESTful API - CodeForGeek
Getting below error after .double callback warning. Uncaught TypeError: Cannot read property 'status' of undefined. Anthony Jackman.
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 Free
Top 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
@sdotson the problem was in Nock Back, so i wrote my own VCR implementation. Don’t remember all the details, but here is code that I use and it works:
vcr.js
Test example (PlansController fetches data from Stripe):
The
request
variable isconst request = supertest(app.listen());
If you have a repo, I could check it.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!