I'm running a Unit test experiment on our existing Webapp folder structure. When I run the tests on an AMD and non-AMD js file, the unit tests run but I don't get code coverage for each test. I'm assuming it's because the directory structure (see below); moved 'node_modules' and 'intern_tests' one level down ('internjs'). It all works (run + coverage) if I move 'node_modules' and 'intern_tests' folder under the Webapp folder. I'm running version 2.1.1. Does code coverage work with this type of directory structure?
Folder structure:
WebApp (top)
|- example_apps (example AMD and non-AMD apps)
|- internjs ( run tests from here )
|- node_modules
|- intern_tests
|- unit (test js apps under example_apps)
Non-AMD unit test:
define([
'intern!object',
'intern/chai!assert',
// made a package under intern.js
'intern/order!exampleApps/calc.js'
], function (registerSuite, assert) {
registerSuite({ ....
AMD unit test:
define([
'intern!object',
'intern/chai!assert',
'intern/chai!config',
'exampleApps/hello'
], function (registerSuite, assert, config, hello) {
registerSuite({ ...
intern_unit.js:
loader: {
// Packages that should be registered with the loader in each testing environment
packages: [ { name: 'exampleApps', location: '../example_apps' } ]
},
// Non-functional test suite(s) to run in each browser
suites: [
'intern_tests/unit/unit_hello',
'intern_tests/unit/unit_calc2'
],
Output:
./node_modules/.bin/intern-client config=intern_tests/intern_unit
PASS: main - hello - greet (1ms)
0/1 tests failed
PASS: main - test_calc - sum (0ms)
0/1 tests failed
0/2 tests failed
Note, it runs but no code coverage on the two js files under 'example_apps' directory one level up.
I figured it out. I had to run the scripts from WebApp (top). Below is the new configuration.
Command line:
intern_unit.js
Non-AMD test script:
AMD test script: