You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a _body key instead of body in response.
I don't know if it's an expected behavior due to recent changes but it's a breaking change for all my tests
Actual behavior
// ./app.jsconstexpress=require('express')constapp=express()constport=3000app.get('/',(req,res)=>{res.json({ok: true,})})app.listen(port,()=>{console.log(`Example app listening on port ${port}`)});module.exports=app;
// ./tests/app.test.jsconstsupertest=require('supertest');const{ expect }=require('chai');constapp=require('../app.js');constserver=supertest.agent(app);describe("Tests",()=>{it('should return a JSON object',async()=>{constresponse=awaitserver.get('/').expect(200);console.log({ response });expect(response).to.haveOwnProperty('body');});});
Result
1) Tests
should return a JSON object:
AssertionError: expected { Object (_events, _eventsCount, ...) } to have own property 'body'
at Context.<anonymous> (tests/app.test.js:14:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
In the response object there is no "body", only a "_body"
Describe the bug
Node.js version: >= 14
OS version: Docker devcontainer with vscode image
Description:
There is a
_body
key instead ofbody
in response.I don't know if it's an expected behavior due to recent changes but it's a breaking change for all my tests
Actual behavior
Result
In the
response
object there is no "body", only a "_body"Expected behavior
"body" should be present and test should pass.
Code to reproduce
Here is a replit example : https://replit.com/@MartialSeron/RowdyTenseLocations#tests/app.test.js
You just have to run
npm test
in the shellChecklist
The text was updated successfully, but these errors were encountered: