forwardemail / forwardemail/supertest

TypeError: Cannot read properties of undefined (reading 'statusCode')

Open
#746 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.4k
Forks
782
PR merge metrics
No merged PRs in 30d

Description

### I am using chai and mocha using request package for testing APIs

```
var expect = require('chai').expect;
var request = require('request');

const HypersignAuthToken = 'auth_token_value';
const projectData =
{
"projectName": "demo-test-26",
"logoUrl": "http://localhost:3000",
"fromDate": "2021-12-15",
"toDate": "2021-12-18",
"actions": [],
"refereePoint": 5,
"referralPoint": 10,
"projectStatus": 1
}

it('should add (POST) new event', function (done) {
const tempProjectData = { ...projectData };
request
.post({
url: 'http://localhost:6006/api/v1/project',
body: tempProjectData,
'auth': {
'bearer': HypersignAuthToken
}
},
function (error, response, body) {

expect(response.statusCode).to.equal(200)
expect(response.body).to.be.a('object')
console.log('statusCode:',response && response.statusCode);
done();
})

})

```

I am getting error:-

**TypeError: Cannot read properties of undefined (reading 'statusCode')**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.