Reputation: 5357
I am trying to figure out how typescript-jasmine-chutzpah combination will finally test my typescript code. So I have a sample project (shown in the picture).
I have an app.ts file with the following content
class Calculator {
add = function(x:number, y:number) {
return x + y;
}
}
and the test file appTest.ts
/// <reference path="../typings/jasmine/jasmine.d.ts" />
/// <reference path="../../app.ts" />
/// <chutzpah_reference path="../jasmine/jasmine.js" />
/// <chutzpah_reference path="../../app.js" />
describe("Test Calc", function () {
it("add function", function () {
var calc = new Calculator(),
res = calc.add(4, 7);
expect(res).toBe(11);
});
});
If I run tests on testApp.ts the output will be "0 passed, 0 failed, 0 total (chutzpah)." but if I run the compiled testApp.js it seems to work fine "1 passed, 0 failed, 1 total (chutzpah)."
1) Why the tests in .ts file are not found? 2) Should I test my typescript code writing code in Typescript or directly with JavaScript?
Can someone help me figure out this simple test set up and make it work? Notice that I don't use chutzpah.json at the moment.
Upvotes: 1
Views: 4595
Reputation: 5357
As I was reading the docs (or some other articles), it was clearthat chutzpah.json was optional for a simple test to run, but the only way to make it work, was to add chutzpah.json at the root of the project with the following content:
{
"Framework": "jasmine",
"References": [
{ "Path": "app.js" },
{ "Path": "scripts/jasmine/jasmine.js" }
],
"Tests": [
{ "Path": "scripts/tests/apptest.js" }
]
}
So, for any future reference, chutzpah.json is required in order chutzpah to run the tests. Also, note that the "chutzpah_reference"s are not needed anymore in the test file.
Upvotes: 2
Reputation: 16762
If you do not use a chutzpah.json file it will not work. Please follow this example to see how to make it work properly.
Upvotes: 2