摩卡测试不会超时

时间:2017-05-28 19:02:48

标签: javascript node.js ecmascript-6 mocha

我似乎无法通过Mocha中的测试文件为我的任何测试设置超时:

测试/ 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();
            }
        });
  });
});

当我在package.json中执行我的npm run test脚本时:

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

测试立即进行,最近接近10000毫秒。为什么呢?

0 个答案:

没有答案
相关问题