Failing to set up basic unit test solution with chutzpah, typescript and requirejs

1.4k Views Asked by At

For some reason, all of my (even basic) attempts to set up unit testing with Chutzpah, TypeScript and RequireJS fail miserably.

I tried several combinations based on the examples but either I get a timeout error or a file not found error (one which doesn't make any sense to me, since it's a Chutzpah-generated file). My guess would be that it's just something small (albeit not easy to find, perhaps), so maybe someone has an idea how I can resolve this error.

Testfile

/// <reference path="../../../typings/qunit/qunit.d.ts" />
/// <reference path="../../../typings/requirejs/require.d.ts" />

define([], () => {
    QUnit.module('DefineTests2');
    test('foo', () => {
        equal(0, 0);
    });
});

Output

------ Test started: File: C:\Users\...\test.DefineTests2.ts ------
Error: Error opening c:/users/.../Scripts/Game/Tests/Utilities/_Chutzpah.164.test.DefineTests2.js: The system cannot find the path specified.
While Running:C:\Users\...\Scripts\Game\Tests\Utilities\test.DefineTests2.ts
Error: Timeout occurred when executing test file
While Running:C:\Users\...\Scripts\Game\Tests\Utilities\test.DefineTests2.ts
========== Total Tests: 0 passed, 0 failed, 0 total ==========

chutzpah.json

{
    "Framework": "qunit",
    "TestHarnessReferenceMode": "AMD",
    "TestHarnessLocationMode": "SettingsFileAdjacent",
    "TypeScriptModuleKind": "AMD",
    "AMDBasePath": "Scripts/Game",
    "References": [ 
        { "Path": "Scripts/deps/requirejs/require.js" }, 
        { "Path" : "config.js" }
    ]
}

config.js

require.config({
    paths: {},
    shim: {}
});

Obviously this is already a very stripped down version, so hopefully any mistake should be easy to find for someone with more experience with Chutzpah.


[Supplement]

After changing Compilation mode to external (thanks Matthew Manela), the path looks a bit better, but something is still wrong, which I didn't notice earlier and additionally replaced with dots when I wrote this post, the displayed Path is missing two directories in its middle.

------ Test started: File: C:\Users\MyName\Source\Repos\MySolutionName\Main\MyProjectName\Scripts\Game\Tests\Utilities\test.DefineTests2.ts ------
Error: Error opening C:/Users/MyName/Source/Repos/MyProjectName/Scripts/Game/Tests/Utilities/test.DefineTests2.js: The system cannot find the path specified.
While Running:C:\Users\MyName\Source\Repos\MySolutionName\Main\MyProjectName\Scripts\Game\Tests\Utilities\test.DefineTests2.ts
Error: Timeout occurred when executing test file
While Running:C:\Users\MyName\Source\Repos\MySolutionName\Main\MyProjectName\Scripts\Game\Tests\Utilities\test.DefineTests2.ts
========== Total Tests: 0 passed, 0 failed, 0 total ==========

The line with "Error opening" has a slightly wrong path, it is missing \MySolutionName\Main, which explains why it doesn't find the file. The chutzpah.json is under MyProjectName, and so even Settings like TestHarnessLocationMode etc. shouldn't be related to that.

0

There are 0 best solutions below