JS Unit Test not showing up in VS 2015 Test Explorer

I am new to JavaScript unit testing. I am trying to test typescript classes, and my tests are also written in typescript, which looks somewhat like this:

/// <reference path="../../typings/qunit/qunit.d.ts" /> import Utility1 = require("../utility");//This is script I want to test. test("utility_test",function() { ... var result = ...; var expected = ...; equal(result, expected, "Test failed"); }) 

I am using VS 2015 with an adapter for testing chutzpah, as shown here . To be clear, I installed this to expand to vs 2015: Chutzpah test run context menu extension and Chutzpah test adapter for test explorer , and also added Chutzpah NuGet package.

However, when I build my project, the test does not appear in the testers explorer. And when I tried to start the test from the context menu, it does not cope with this error: Error: Error: Called start() outside of a test context while already started .

Can someone please tell me where I am going wrong?


EDIT For anyone looking for a solution with require.js, this worked for me here. Now my Chutzpah.json looks like this:

 { "Framework": "qunit", "CodeCoverageExcludes": [ "*/require.config.js" ], "TestHarnessReferenceMode": "AMD", "TestHarnessLocationMode": "SettingsFileAdjacent", "TypeScriptModuleKind": "AMD", "AMDBaseUrl": "", "EnableTestFileBatching": true, "Compile": { "Mode": "External", "Extensions": [ ".ts" ], "ExtensionsWithNoOutput": [ ".d.ts" ] }, "References": [ { "Path": "require.js" }, { "Path": "require.config.js" }, ], "Tests": [ { "Path": "jsTests" } ] } 
+6
source share
1 answer

Chutzpah no longer binds the Typescript compiler inside it (since version 4). You must tell Chutzpah where to find the generated .js files (or / and how to compile them if you want).

See the documentation for the Compile parameter as well as these sample code .

Most people will use external compilation mode when working with Visual Studio, since VS can compile .ts files for you, and you just need to tell Chutzpah where to find them. It will look like this:

 { "Compile": { "Mode": "External", "Extensions": [".ts"], "ExtensionsWithNoOutput": [".d.ts"] }, "References": [ {"Includes": ["*/src/*.ts"], "Excludes": ["*/src/*.d.ts"] } ], "Tests": [ { "Includes": ["*/test/*.ts"], "Excludes": ["*/test/*.d.ts"] } ] } 
+4
source

All Articles