Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm test fail #12

Open
HeribertG opened this issue May 28, 2019 · 3 comments
Open

npm test fail #12

HeribertG opened this issue May 28, 2019 · 3 comments

Comments

@HeribertG
Copy link

Unfortunately I can't finish the course "Mastering React" because I can't get "npm test" to run in the "Section 8 Calling Backend Services". It always aborts with the error message. (see below)

  1. I installed user dataset manually
  2. I installed bcrypt manually

but it didn't help.

at Object.close (tests/integration/returns.test.js:55:18)

● /api/returns › should return 200 if we have a valid request

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/returns › should return 200 if we have a valid request

TypeError: app.address is not a function

  16 |   const exec = () => {
  17 |     return request(server)
> 18 |       .post('/api/returns')
     |        ^
  19 |       .set('x-auth-token', token)
  20 |       .send({ customerId, movieId });
  21 |   };

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/returns.test.js:18:8)
  at Object.exec (tests/integration/returns.test.js:102:23)

● /api/returns › should return 200 if we have a valid request

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

● /api/returns › should set the returnDate if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/returns › should set the returnDate if input is valid

TypeError: app.address is not a function

  16 |   const exec = () => {
  17 |     return request(server)
> 18 |       .post('/api/returns')
     |        ^
  19 |       .set('x-auth-token', token)
  20 |       .send({ customerId, movieId });
  21 |   };

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/returns.test.js:18:8)
  at Object.exec (tests/integration/returns.test.js:108:23)

● /api/returns › should set the returnDate if input is valid

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

● /api/returns › should set the rentalFee if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/returns › should set the rentalFee if input is valid

TypeError: Cannot set property 'dateOut' of undefined

  114 | 
  115 |   it('should set the rentalFee if input is valid', async () => {
> 116 |     rental.dateOut = moment().add(-7, 'days').toDate();
      |     ^
  117 |     await rental.save();
  118 | 
  119 |     const res = await exec();

  at Object.<anonymous> (tests/integration/returns.test.js:116:5)

● /api/returns › should set the rentalFee if input is valid

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

● /api/returns › should increase the movie stock if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/returns › should increase the movie stock if input is valid

TypeError: app.address is not a function

  16 |   const exec = () => {
  17 |     return request(server)
> 18 |       .post('/api/returns')
     |        ^
  19 |       .set('x-auth-token', token)
  20 |       .send({ customerId, movieId });
  21 |   };

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/returns.test.js:18:8)
  at Object.exec (tests/integration/returns.test.js:126:23)

● /api/returns › should increase the movie stock if input is valid

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

● /api/returns › should return the rental if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/returns › should return the rental if input is valid

TypeError: app.address is not a function

  16 |   const exec = () => {
  17 |     return request(server)
> 18 |       .post('/api/returns')
     |        ^
  19 |       .set('x-auth-token', token)
  20 |       .send({ customerId, movieId });
  21 |   };

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/returns.test.js:18:8)
  at Object.exec (tests/integration/returns.test.js:133:23)

● /api/returns › should return the rental if input is valid

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

FAIL tests/integration/genres.test.js (81.21s)
/api/genres
GET /
× should return all genres (5997ms)
GET /:id
× should return a genre if valid id is passed (5013ms)
× should return 404 if invalid id is passed (4ms)
× should return 404 if no genre with the given id exists (7ms)
POST /
× should return 401 if client is not logged in (39ms)
× should return 400 if genre is less than 5 characters (11ms)
× should return 400 if genre is more than 50 characters (22ms)
× should save the genre if it is valid (8ms)
× should return the genre if it is valid (10ms)
PUT /:id
× should return 401 if client is not logged in (5006ms)
× should return 400 if genre is less than 5 characters (5004ms)
× should return 400 if genre is more than 50 characters (5005ms)
× should return 404 if id is invalid (5006ms)
× should return 404 if genre with the given id was not found (5009ms)
× should update the genre if input is valid (5002ms)
× should return the updated genre if it is valid (5003ms)
DELETE /:id
× should return 401 if client is not logged in (5002ms)
× should return 403 if the user is not an admin (5004ms)
× should return 404 if id is invalid (5003ms)
× should return 404 if no genre with the given id was found (5001ms)
× should delete the genre if input is valid (5003ms)
× should return the removed genre (5006ms)

● /api/genres › GET / › should return all genres

Cannot find module 'bcrypt' from 'users.js'

However, Jest was able to find:
    '../routes/users.js'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

However, Jest was able to find:
    'startup/routes.js'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

However, Jest was able to find:
    '../../index.js'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

  1 | const auth = require("../middleware/auth");
> 2 | const bcrypt = require("bcrypt");
    |                ^
  3 | const _ = require("lodash");
  4 | const { User, validate } = require("../models/user");
  5 | const express = require("express");

  at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:230:17)
  at Object.require (routes/users.js:2:16)

● /api/genres › GET / › should return all genres

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:

  14 | 
  15 |   describe('GET /', () => {
> 16 |     it('should return all genres', async () => {
     |     ^
  17 |       const genres = [
  18 |         { name: 'genre1' },
  19 |         { name: 'genre2' },

  at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
  at Suite.it (tests/integration/genres.test.js:16:5)
  at Suite.describe (tests/integration/genres.test.js:15:3)
  at Object.describe (tests/integration/genres.test.js:8:1)

● /api/genres › GET / › should return all genres

TypeError: Cannot read property 'close' of undefined

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › GET /:id › should return a genre if valid id is passed

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:

  32 | 
  33 |   describe('GET /:id', () => {
> 34 |     it('should return a genre if valid id is passed', async () => {
     |     ^
  35 |       const genre = new Genre({ name: 'genre1' });
  36 |       await genre.save();
  37 | 

  at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
  at Suite.it (tests/integration/genres.test.js:34:5)
  at Suite.describe (tests/integration/genres.test.js:33:3)
  at Object.describe (tests/integration/genres.test.js:8:1)

● /api/genres › GET /:id › should return a genre if valid id is passed

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › GET /:id › should return 404 if invalid id is passed

TypeError: app.address is not a function

  43 | 
  44 |     it('should return 404 if invalid id is passed', async () => {
> 45 |       const res = await request(server).get('/api/genres/1');
     |                                         ^
  46 | 
  47 |       expect(res.status).toBe(404);
  48 |     });

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as get] (node_modules/supertest/index.js:25:14)
  at Object.get (tests/integration/genres.test.js:45:41)

● /api/genres › GET /:id › should return 404 if invalid id is passed

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › GET /:id › should return 404 if no genre with the given id exists

TypeError: app.address is not a function

  50 |     it('should return 404 if no genre with the given id exists', async () => {
  51 |       const id = mongoose.Types.ObjectId();
> 52 |       const res = await request(server).get('/api/genres/' + id);
     |                                         ^
  53 | 
  54 |       expect(res.status).toBe(404);
  55 |     });

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as get] (node_modules/supertest/index.js:25:14)
  at Object.get (tests/integration/genres.test.js:52:41)

● /api/genres › GET /:id › should return 404 if no genre with the given id exists

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › POST / › should return 401 if client is not logged in

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:81:25)

● /api/genres › POST / › should return 401 if client is not logged in

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › POST / › should return 400 if genre is less than 5 characters

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:89:25)

● /api/genres › POST / › should return 400 if genre is less than 5 characters

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › POST / › should return 400 if genre is more than 50 characters

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:97:25)

● /api/genres › POST / › should return 400 if genre is more than 50 characters

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › POST / › should save the genre if it is valid

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:103:13)

● /api/genres › POST / › should save the genre if it is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › POST / › should return the genre if it is valid

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:111:25)

● /api/genres › POST / › should return the genre if it is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › PUT /:id › should return 401 if client is not logged in

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › PUT /:id › should return 401 if client is not logged in

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:145:25)

● /api/genres › PUT /:id › should return 401 if client is not logged in

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › PUT /:id › should return 400 if genre is less than 5 characters

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › PUT /:id › should return 400 if genre is less than 5 characters

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:153:25)

● /api/genres › PUT /:id › should return 400 if genre is less than 5 characters

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › PUT /:id › should return 400 if genre is more than 50 characters

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › PUT /:id › should return 400 if genre is more than 50 characters

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:161:25)

● /api/genres › PUT /:id › should return 400 if genre is more than 50 characters

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › PUT /:id › should return 404 if id is invalid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › PUT /:id › should return 404 if id is invalid

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:169:25)

● /api/genres › PUT /:id › should return 404 if id is invalid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › PUT /:id › should return 404 if genre with the given id was not found

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › PUT /:id › should return 404 if genre with the given id was not found

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:177:25)

● /api/genres › PUT /:id › should return 404 if genre with the given id was not found

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › PUT /:id › should update the genre if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › PUT /:id › should update the genre if input is valid

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:183:13)

● /api/genres › PUT /:id › should update the genre if input is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › PUT /:id › should return the updated genre if it is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › PUT /:id › should return the updated genre if it is valid

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:191:25)

● /api/genres › PUT /:id › should return the updated genre if it is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › DELETE /:id › should return 401 if client is not logged in

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › DELETE /:id › should return 401 if client is not logged in

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:223:25)

● /api/genres › DELETE /:id › should return 401 if client is not logged in

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › DELETE /:id › should return 403 if the user is not an admin

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › DELETE /:id › should return 403 if the user is not an admin

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:231:25)

● /api/genres › DELETE /:id › should return 403 if the user is not an admin

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › DELETE /:id › should return 404 if id is invalid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › DELETE /:id › should return 404 if id is invalid

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:239:25)

● /api/genres › DELETE /:id › should return 404 if id is invalid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › DELETE /:id › should return 404 if no genre with the given id was found

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › DELETE /:id › should return 404 if no genre with the given id was found

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:247:25)

● /api/genres › DELETE /:id › should return 404 if no genre with the given id was found

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › DELETE /:id › should delete the genre if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › DELETE /:id › should delete the genre if input is valid

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:253:13)

● /api/genres › DELETE /:id › should delete the genre if input is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

● /api/genres › DELETE /:id › should return the removed genre

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

● /api/genres › DELETE /:id › should return the removed genre

TypeError: app.address is not a function

  202 |
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:261:25)

● /api/genres › DELETE /:id › should return the removed genre

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close();
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 |

  at Object.close (tests/integration/genres.test.js:11:18)

Test Suites: 3 failed, 2 passed, 5 total
Tests: 35 failed, 2 passed, 37 total
Snapshots: 0 total
Time: 84.325s
Ran all test suites.

Watch Usage
› Press f to run only failed tests.
› Press o to only run tests related to changed files.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press q to quit watch mode.
› Press Enter to trigger a test run.

@rdaguilarc
Copy link

I have the same issue :(

@mamunur121
Copy link

mamunur121 commented Aug 21, 2019

same issues here

@yardenshoham
Copy link

yardenshoham commented Aug 21, 2019

Same issue here also

Edit: It seems a solution was provided in #1. Here's the comment with the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants