I'm trying to get Mocha unit tests written in TypeScript to work in Visual Studio 2015 Community Edition in Node Tools for Visual Studio. I'm getting this error (in the Output window, Tests
section):
------ Discover test started ------
Processing: <lot of *.js** files>...
Test discovery error: [TypeError: Cannot read property 'replace' of undefined] in C:\Code\ov\BuyCo\test\sellers\testPersistance.js
Test discovery error: [TypeError: Cannot read property 'replace' of undefined] in C:\Code\ov\BuyCo\test\sellers\testUserPersistance.js
...<andsoon>
Processing finished for framework of Mocha
Discovered 0 testcases.
========== Discover test finished: 0 found (0:00:01.4378126) ==========
So it's listing .js files instead of ts, those are already transpiled out, but there is absolutely no replace
function in the generated code in those functions. So it's a very strange error. I'm using Typescript 1.7.
The tests are working when run from the command prompt (npm test ...
). But I want to be able to set (note I'm testing NodeJS code, e.g. serverside CommonJS).
Note: During analysis I've already simplified down one test file to the default typescript example file, but it raises the same error, so that should NOT be the issue:
import assert = require('assert');
describe("Test Suite 1", () => {
it("Test A", () => {
assert.ok(true, "This shouldn't fail");
});
it("Test B", () => {
assert.ok(1 === 1, "This shouldn't fail");
assert.ok(false, "This should fail ts");
});
});