Quality Assurance and Testing with Chai - Run Functional Tests on an API Response using Chai-HTTP IV - PUT method

Tell us what’s happening:
Hey, I seem to have completed the challenge but it won’t accept my code for the challenge. I have written this code:

test('Send {surname: "da Verrazzano"}', function (done) {
      chai
        .request(server)
        .keepOpen()
        .put('/travellers')
        .send({surname: "da Verrazzano"})
        .end(function (err, res) {
          assert.equal(res.status, 200);
          assert.equal(res.type, 'application/json');
          assert.equal(res.body.name, "Giovanni");
          assert.equal(res.body.surname, "da Verrazzano");

      done();
    });
  });

and this is the response I get from freecodecamp when I submit my link. Does anyone know what is going on?

// running tests All tests should pass You should test for

```
res.status
```

to be 200 You should test for

```
res.type
```

to be

```
'application/json'
```

You should test for

```
res.body.name
```

to be

```
'Giovanni'
```

You should test for

```
res.body.surname
```

to be

```
'da Verrazzano'
```

// tests completed // console output jQuery.Deferred exception: Cannot read properties of undefined (reading '0') TypeError: Cannot read properties of undefined (reading '0') 

Your project link(s)

solution: boilerplate-mochachai (2) - Replit

Challenge: Quality Assurance and Testing with Chai - Run Functional Tests on an API Response using Chai-HTTP IV - PUT method

Link to the challenge:

Your Replit is passing the test for me.

If you fixed this, or if this is no longer an issue please update the thread.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.