Mocha unit tests do not appear in Test Exporer

Dec 18, 2014 at 5:07 AM
Edited Dec 18, 2014 at 5:12 AM
I have two TypeScript projects set up in my solution. First project is an Express app with REST APIs, and the second project has a set of unit tests that test API endpoints from the first project using Supertest.

Currently, I have 2 issues with Mocha unit tests:
  1. Mocha unit tests do not appear in the Test Explorer if I set output directory for complied JS files to anything other than blank (all my TS files get complied to /bin directory)
  2. For some reason, adding the following code to the solution also results in unit tests not showing in the Test Explorer
import fs = require('fs');
import path = require('path');

var Mocha = require('mocha');

// First, instantiate a Mocha instance
var mocha = new Mocha();

// Then, use the method "addFile" on the mocha object for each file
var dir = path.join(__dirname, 'tests');

fs.readdirSync(dir).filter(function (file) {
    // Only keep the .js files
    return file.substr(-3) === '.js'; 

}).forEach(function (file) {
    // Use the method "addFile" to add the file to mocha
    mocha.addFile(path.join(dir, file)); 
// Now, run the tests (failures) {
    process.on('exit', function () {
I use this file to run the tests programmatically, and when run through this file, all tests work fine. But adding this file to the project causes all unit tests to disappear from the Test Explorer. Even more strangely, if I pass a string literal to the mocha.addFile() function - they appear back in the Test Explorer - but if that function is supplied with a variable (as in the code above), unit tests disappear.

The reason I have this file in the first place is that I cannot run unit tests from Test Explore when my API project is running. Ideally, i would like to run my API project, and while it is listening on localhost, I'd like to run unit tests through the test project. But it doesn't seem to be possible - hence the workaround with running unit tests programmatically.

Any help on these is greatly appreciated. I'm running the NTVS 1.0 RC on MS Visual Studio Express 2013 for Web Update 4