From @joeskeen on October 12, 2016 16:15
tns version: 2.4.0-2016-10-06-6743
OS: OS X El Capitan 10.11.6
If you add a TypeScript unit test file (/app/tests/*.ts), it won't get executed on the first test run, only the second one. Steps to reproduce:
-
Clone the sample-Groceries repo and check out the angular-start branch
-
run tns test init using Jasmine as test framework. This will create a single JS test file under /app/tests.
-
run tns test ios. In the console you will see the following:
Oct 12 08:46:07 AC02NPBKPG3QD sampleGroceries[6490]: CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:212:24: NSUTR: beginning test run
NativeScript / 10.0 (10.0; iPhone): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
NativeScript / 10.0 (10.0; iPhone): Executed 1 of 1 SUCCESS (0.009 secs / 0.002 secs)
Oct 12 08:46:07 AC02NPBKPG3QD sampleGroceries[6490]: CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:258:24: NSUTR: completeAck
Note that it only runs one spec (the JS one that was already there). Go ahead and kill the test process.
-
create a file in /app/tests called myTest.ts, and add a simple test inside (you can copy/paste the code from the JS one and change some of the strings to make them unique). You also may have to add a type reference or declaration to get it to compile.
-
run tns test ios again. You will see it only runs one test (not recognizing the new one).
-
kill the process and run it again. This time you will see output like this:
NativeScript / 10.0 (10.0; iPhone): Executed 0 of 2 SUCCESS (0 secs / 0 secs)
NativeScript / 10.0 (10.0; iPhone): Executed 2 of 2 SUCCESS (0.013 secs / 0.002 secs)
So it appears that TS files in the /app/tests/ folder do get transpiled, but not until after the .js files are collected for testing by Karma. This means that if we want to use TS for testing in continuous integration, we have to run the test suite twice.
Copied from original issue: NativeScript/nativescript-unit-test-runner#22
From @joeskeen on October 12, 2016 16:15
tnsversion: 2.4.0-2016-10-06-6743OS: OS X El Capitan 10.11.6
If you add a TypeScript unit test file (
/app/tests/*.ts), it won't get executed on the first test run, only the second one. Steps to reproduce:Clone the
sample-Groceriesrepo and check out theangular-startbranchrun
tns test initusing Jasmine as test framework. This will create a single JS test file under/app/tests.run
tns test ios. In the console you will see the following:Note that it only runs one spec (the JS one that was already there). Go ahead and kill the test process.
create a file in
/app/testscalledmyTest.ts, and add a simple test inside (you can copy/paste the code from the JS one and change some of the strings to make them unique). You also may have to add a type reference or declaration to get it to compile.run
tns test iosagain. You will see it only runs one test (not recognizing the new one).kill the process and run it again. This time you will see output like this:
So it appears that TS files in the
/app/tests/folder do get transpiled, but not until after the.jsfiles are collected for testing by Karma. This means that if we want to use TS for testing in continuous integration, we have to run the test suite twice.Copied from original issue: NativeScript/nativescript-unit-test-runner#22