X-Press Publishing project: Incomplete test results

Hi, codecademy community

I’m trying to solve the capstone proyect for BUILDING A PERSISTENT API and when I reach the part for creating routes for the issues, I notice I don’t get the tests for that part when running $ npm test. I’ve looked into the test file and there are in fact test for the issue route but still they don’t show up when i run the tests. Here’s the code for the issue route I’m trying to test:

describe('POST /api/series/:seriesId/issues', function() {
  let newIssue;

  beforeEach(function(done) {
    newIssue = {
      name: 'New Issue',
      issueNumber: 3,
      publicationDate: 'January 3, 1990',
      artistId: 1
    };

    seed.seedIssueDatabase(done);
  });

  it('should create a valid issue', function(done) {
    request(app)
        .post('/api/series/2/issues')
        .send({issue: newIssue})
        .then(function() {
          testDb.all('SELECT * FROM Issue', function(error, result) {
            if (error) {
              throw new Error(error);
            }
            const issue = result.find(issue => issue.name === newIssue.name);
            expect(issue).to.exist;
            expect(issue.id).to.exist;
            expect(issue.name).to.equal(newIssue.name);
            expect(issue.issue_number).to.equal(newIssue.issueNumber);
            expect(issue.publication_date).to.equal(newIssue.publicationDate);
            expect(issue.artist_id).to.equal(newIssue.artistId);
            expect(issue.series_id).to.equal(2);
            done()
          });
        }).catch(done);
  });

  it('should return a 201 status code after issue creation', function() {
    return request(app)
        .post('/api/series/2/issues')
        .send({issue: newIssue})
        .expect(201);
  });

  it('should return the newly-created issue after issue creation', function() {
    return request(app)
        .post('/api/series/2/issues')
        .send({issue: newIssue})
        .then(function(response) {
          const issue = response.body.issue;
          expect(issue).to.exist;
          expect(issue.id).to.exist;
          expect(issue.name).to.equal(newIssue.name);
          expect(issue.issue_number).to.equal(newIssue.issueNumber);
          expect(issue.publication_date).to.equal(newIssue.publicationDate);
          expect(issue.artist_id).to.equal(newIssue.artistId);
          expect(issue.series_id).to.equal(2);
        });
  });

  it('should return a 400 status code for invalid issues', function() {
    newIssue = {
      issueNumber: 3,
      publicationDate: 'January 3, 1990',
      artistId: 1
    };

    return request(app)
        .post('/api/series/2/issues')
        .send({issue: newIssue})
        .expect(400);
  });

  it('should return a 400 status code if an artist with the issue\'s artist ID doesn\'t exist', function() {
    newIssue = {
      issueNumber: 3,
      publicationDate: 'January 3, 1990',
      artistId: 999
    };

    return request(app)
        .post('/api/series/2/issues')
        .send({issue: newIssue})
        .expect(400);
  });
});

And here’s the complete result of the tests where the issues route only has two tests for the DELETE method. Note: there are test for the Issues table but not for the routes.

MBP:~ myName$ cd /Users/myName/Documents/Development/capstone-project-1-x-press-publishing 
MBP:capstone-project-1-x-press-publishing myName$ npm test

> x-press-publishing@1.0.0 test /Users/myName/Documents/Development/capstone-project-1-x-press-publishing
> mocha



Listenening on port 8081
  Artist Table
    ✓ should exist
    ✓ should have name, date_of_birth, biography, and is_currently_employed columns with appropriate data types
    ✓ should have a required name column
    ✓ should have a required date_of_birth column
    ✓ should have a required biography column
    ✓ is_currently_employed should default to 1

  Series Table
    ✓ should exist
    ✓ should have id, name, and description columns with appropriate data types
    ✓ should have a required name column
    ✓ should have a required description column

  Issue Table
    ✓ should exist
    ✓ should have id, name, issue_number, publication_date, artist_id, and series_id columns with appropriate data types
    ✓ should have a required name column
    ✓ should have a required name column
    ✓ should have a required issue_number column
    ✓ should have a required publication_date column
    ✓ should have a required artist_id column
    ✓ should have a required series_id column

  GET /api/artists
GET /api/artists 200 4.781 ms - 242
    ✓ should return all currently-employed artists
GET /api/artists 200 1.453 ms - 242
    ✓ should return a status code of 200

  GET /api/artists/:id
GET /api/artists/2 200 1.431 ms - 127
    ✓ should return the artist with the given ID
GET /api/artists/2 200 0.843 ms - 127
    ✓ should return a 200 status code for valid IDs
GET /api/artists/999 404 0.563 ms - 9
    ✓ should return a 404 status code for invalid IDs

  POST /api/artists
POST /api/artists/ 201 3.372 ms - 127
    ✓ should create a valid artist
POST /api/artists/ 201 1.649 ms - 127
    ✓ should return a 201 status code after artist creation
POST /api/artists/ 201 1.984 ms - 127
    ✓ should return the newly-created artist after artist creation
POST /api/artists/ 201 1.757 ms - 127
    ✓ should set new artists as currently-employed by default
POST /api/artists/ 400 0.221 ms - 11
    ✓ should return a 400 status code for invalid artists

  PUT /api/artists/:id
PUT /api/artists/1 200 2.964 ms - 135
    ✓ should update the artist with the given ID
PUT /api/artists/1 200 2.916 ms - 135
    ✓ should return a 200 status code after artist update
PUT /api/artists/1 200 2.269 ms - 135
    ✓ should return the updated artist after artist update
PUT /api/artists/1 400 0.808 ms - 11
    ✓ should return a 400 status code for invalid artist updates

  DELETE /api/artists/:id
DELETE /api/artists/1 200 4.210 ms - 122
    ✓ should set the artist with the given ID as not currently-employed
DELETE /api/artists/1 200 1.773 ms - 122
    ✓ should return a 200 status code after artist delete
DELETE /api/artists/1 200 1.861 ms - 122
    ✓ should return the deleted artist after artist delete

  GET /api/series
GET /api/series 200 1.596 ms - 192
    ✓ should return all series
GET /api/series 200 0.456 ms - 192
    ✓ should return a status code of 200

  GET /api/series/:id
GET /api/series/2 200 2.336 ms - 70
    ✓ should return the series with the given ID
GET /api/series/2 200 0.448 ms - 70
    ✓ should return a 200 status code for valid IDs
GET /api/series/999 404 0.395 ms - 9
    ✓ should return a 404 status code for invalid IDs

  POST /api/series
POST /api/series/ 201 2.924 ms - 71
    ✓ should create a valid series
POST /api/series/ 201 2.210 ms - 71
    ✓ should return a 201 status code after series creation
POST /api/series/ 201 1.702 ms - 71
    ✓ should return the newly-created series after series creation
POST /api/series/ 400 0.238 ms - 11
    ✓ should return a 400 status code for invalid series

  PUT /api/series/:id
PUT /api/series/1 200 2.530 ms - 79
    ✓ should update the series with the given ID
PUT /api/series/1 200 2.252 ms - 79
    ✓ should return a 200 status code after series update
PUT /api/series/1 200 2.415 ms - 79
    ✓ should return the updated series after series update
PUT /api/series/1 400 0.736 ms - 11
    ✓ should return a 400 status code for invalid series updates

  DELETE /api/series/:id
DELETE /api/series/1 404 1.935 ms - 154
    ✓ should remove the series with the specified ID from the database if that series has no related issues
    1) "before each" hook

  GET /api/series/:seriesId/issues
    2) "before each" hook for "should return all issues of an existing series"


  49 passing (1s)
  2 failing

  1) DELETE /api/series/:id "before each" hook for "should return all issues of an existing series":
     TypeError: Cannot read property 'call' of undefined
  

  2) DELETE /api/series/:id "before each" hook for "should return all issues of an existing series":
     TypeError: Cannot read property 'call' of undefined
  



npm ERR! Test failed.  See above for more details.

I hope someone can tell me if I’m doing something wrong or if the test have a bug of some kind. Thanks in advance!

EDIT:
I just ran one of the skipped tests using mocha’s GREP option and it did run it. It returned a timeout error. Could it be related to the reason it doesn’t show up with the rest of the tests?
Here’s the terminal output:

MBP:capstone-project-1-x-press-publishing myName$ npm test -- -g 'should create a valid issue'

> x-press-publishing@1.0.0 test /Users/myName/Documents/Development/capstone-project-1-x-press-publishing
> mocha "-g" "should create a valid issue"



Listenening on port 8081
  POST /api/series/:seriesId/issues
    1) should create a valid issue


  0 passing (2s)
  1 failing

  1) POST /api/series/:seriesId/issues should create a valid issue:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  



npm ERR! Test failed.  See above for more details.