Issue Tracker can’t pass GET request tests

** GET request not working always return response.body=[ ] :cry: **
hello;
I have a problem with the GET request client-side response. body is showed as an empty array.
Error: expected [] to have a length of 3 but got 0
But when I check on the network panel in chrome dev tools I find that response.body contains the array that corresponds to project issues!

  • I tried console.log(res.body.length) in the 2_functional-tests.js and i got [ ]

Thank you

Your project link(s)

solution: Issue Tracker - Project Page

code source: https://replit.com/@abdelghanymh/boilerplate-project-issuetracker

 suite('2) GET request Tests', () => {
    test('View issues on a project: GET request to /api/issues/{project}', (done) => {
      chai
        .request(server)
        .get('/api/issues/gettest')
        .end((err, res) => {
          assert.equal(res.status, 200);
          assert.equal(res.body.length, 1);

          done();
        })
    });
    test('View issues on a project with one filter', (done) => {
      chai
        .request(server)
        .get('/api/issues/gettest')
        .query({
          _id: '6103cb9b68aaa701863ee7a2',
        })
        .end((err, res) => {
          assert.equal(res.status, 200);
          assert.deepEqual(res.body[0], {
            _id: "6103cb9bedc58d370e804a81",
            issue_title: "get test",
            issue_text: "DONT EDIT THIS PROJECT",
            created_on: "2021-07-30T09:51:23.670Z",
            updated_on: "2020-12-21T15:41:38.279Z",
            created_by: "CAMPER",
            assigned_to: "CHAI ",
            open: true,
            status_text:"NOT DONE",
          });
          done();
        });

    })
    test('View issues on a project with multiple filters', (done) => {
      chai
        .request(server)
        .get('/api/issues/gettest')
        .query({
           issue_title: "get test",
            issue_text: "DONT EDIT THIS PROJECT",
        })
        .end((err, res) => {
          assert.equal(res.status, 200);
          assert.deepEqual(res.body[0],{
            _id: "6103cb9bedc58d370e804a81",
            issue_title: "get test",
            issue_text: "DONT EDIT THIS PROJECT",
            created_on: "2021-07-30T09:51:23.670Z",
            updated_on: "2020-12-21T15:41:38.279Z",
            created_by: "CAMPER",
            assigned_to: "CHAI ",
            open: true,
            status_text:"NOT DONE",
          });
          done();
        });

    })
  });

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.18 Safari/537.36

Challenge: Issue Tracker

Link to the challenge:

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