Reputation: 2275
I have the following test (whose values have been changed due to corporate policy), but for whatever reason Mocha will not run it. What is weirder, if I change test
to test.only
, Mocha does run it but - as one would expect - none of my other tests. I added some console.log
s describing what does get run versus what does not. Has anyone seen anything like this?
The code:
/*global suite, setup, teardown, test, require, console */
var expect = require('expect.js'),
sinon = require('sinon'),
proxyquire = require('proxyquire');
suite('seven', function () {
'use strict';
var one = {
a: sinon.stub()
};
var two = {
b: sinon.stub()
};
var three = {
c: sinon.stub()
};
var four = proxyquire(
'./four.js',
{
'one.js': one,
'two.js': two
}
);
var five = proxyquire(
'./five.js',
{
'./four.js': four
}
);
var six = proxyquire(
'./six.js',
{
'./five': five
}
);
var seven;
setup(function () {
console.log('does not print');
seven = proxyquire(
'./seven.js',
{
'./three.js': three,
'./six.js': six
}
);
});
suite('d', function () {
console.log('does print');
test('d things', function () {
console.log('also does not print');
var expectedDValue = 'd value';
one.a.callsArgWith(1, {
'dKey': expectedDValue
});
two.b.callsArgWith(1, true);
three.c.returns({
'cKeyOne': 'cValueOne',
'cKeyTwo': {
'subCKey': 'subCValue'
}
});
return seven.d().then(function (dValue) {
expect(dValue).to.be(expectedDValue);
});
});
});
});
Mocha is being run via make
with these relevant lines:
TEST_TIMEOUT := 5000
MOCHA_REPORTER := dot
MOCHA_UI := tdd
SERVER_PATH := js
MODULE_PATH := $(realpath ./)/node_modules/.bin
MOCHA_COMMAND := $(MODULE_PATH)/mocha
SERVER_TEST_FILES := $(shell find $(SERVER_PATH) -name "*.test.js")
MOCHA_SETUP_FILE := $(shell find $(SERVER_PATH) -name "mochaSetup.js")
test:
-@$(MOCHA_COMMAND) -u $(MOCHA_UI) -t $(TEST_TIMEOUT) -R $(MOCHA_REPORTER) $(MOCHA_SETUP_FILE) $(SERVER_TEST_FILES)
UPDATE
I have found that out of ~1600 tests only ~900 of them are being run. Mine being new is purely a coincidence. The test files are being read - if I console.log
inside of the suite
functions I see them printed - but neither the setup
nor test
functions are being executed. I confirmed they are not being executed on a coworker's machine either, but the are being executed in our CI environment.
UPDATE 2
It seems the problem may be limited to the Windows Subsystem for Linux (WSL) - another coworker running a VM on Windows 7 sees all of the tests run.
Upvotes: 2
Views: 335
Reputation: 2275
It turns a low-level exception raised in another test caused Mocha to stop running tests completely. In specific, one of my tests was trying to perform a file operation that WSL's file system does not support, but instead of giving me any indication of what was happening Mocha just quit.
It is not a great process, but my advice to anyone else having this problem is find the last test run before Mocha quits and manually check for low-level errors.
Upvotes: 1