mosh-hamedani / vidly-api-node

309 stars 285 forks source link

Integration tests are failing randomly #6

Open jakimcho opened 5 years ago

jakimcho commented 5 years ago

Summary

Integration tests fail in a random manner.

Steps

  1. Run npm test

Result:

Some integration tests are failing with:

...................

auth middleware
    ✕ should return 401 if no token is provided (342ms)
    ✕ should return 400 if token is invalid (132ms)
    ✓ should return 200 if token is valid (122ms)

  ● auth middleware › should return 401 if no token is provided

    listen EADDRINUSE :::3900

      12 | 
      13 | const port = process.env.PORT || config.get("port");
    > 14 | const server = app.listen(port, () =>
      15 |   winston.info(`Listening on port ${port}...`)
      16 | );

...............

Expected Result

All tests (unit and integration) should pass

Probable reason

Race condition. The server has not been stopped on time when the next test cases initiates.

yardenshoham commented 4 years ago

I have the same issue. I believe more people are having this problem at #12.

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

ybakhshi commented 4 years ago

vidly@1.0.0 test C:\projects\vidly-api-node jest --watchAll --verbose --runInBand

Error: Cannot find module 'walker' Require stack: