Sunday 28 May 2017

Tests do not timeout in Mocha

I can't seem to set a timeout for any of my tests from a test file in Mocha:

test/test.js

import request from 'supertest';
import app from '../app';

import { resetDB } from './helpers';
import { config } from '../app/config';
import { testHost } from '../config';

before(function() {
  this.timeout(10000);
  return resetDB();
});

describe('/myroute', function() {
  this.timeout(10000);
  it('should respond', function(done) {
    this.timeout(10000);
    request(app)
        .get('/recommendations')
        .query({ query: 'somevalue' })
        .end(function(err, res) {
            console.log('res is', res.body);
            if (err) {
                done(err);
            } else {
                done();
            }
        });
  });
});

When I execute my npm run test script in package.json:

"test": "NODE_ENV=test ./node_modules/mocha/bin/mocha test/test --compilers js:babel-core/register",...

The tests run immediately, nowhere close to 10000 ms. Why?



via writofmandamus

No comments:

Post a Comment