0

With Intern revision 1.7, I was able to run node node_modules/intern/bin/intern-client.js config=test/internNode on Windows (Git Bash) and on CentOS (within a VirtualBox VM). If at least one test was failing, the coverage report was not generated.

With Intern revision 2.0, coverage reports are never generated on Windows, only on CentOS. They are now even generated if a test fails...

It does not seem that any of the Intern dependency is platform dependent. Is it possible one has a glitch due to a path just formated for Linux?

A+, Dom


Update with the configuration file:

  • The module FileScanner retrieves all files matching the given regular expression in the specified folders. It avoids having to document a static list of test files to run.
  • The test suite runs code to verify both the client logic and the server logic.

.

/*global define*/
define([
    'intern/node_modules/dojo/has',
    'src/tests/FileScanner'
], function (has, FileScanner) {
    'use strict';

    has.add('tests-api', true); // To enable entry points for test purposes
    has.add('dojo-debug-messages', false); //

    var unitTestFiles = new FileScanner.getFiles(['src/client/ubi', 'src/server'], /(?:\w+\/)*\w+Test\.js$/),
        functionTestFiles = [];

    return {
        useLoader: {
            'host-node': 'dojo/dojo'
        },

        loader: {
            map: {
                '*': {
                    'dojo/has': 'intern/node_modules/dojo/has',
                    'dojo/node': 'intern/node_modules/dojo/node',
                    'dojo/text': 'ubi/utils/tests/dojo/textMock',
                    'dojo/parser': 'ubi/utils/tests/dojo/parserMock',
                    'dijit/_TemplatedMixin': 'ubi/utils/tests/dijit/_TemplatedMixinMock',
                    'dijit/_WidgetBase': 'ubi/utils/tests/dijit/_WidgetBaseMock',
                    'dijit/_WidgetsInTemplateMixin':  'ubi/utils/tests/dijit/_WidgetsInTemplateMixinMock',
                    'dijit/_AttachMixin': 'ubi/utils/tests/dijit/_AttachMixinMock',

                    // To limit side-effects of the GFX library
                    'dojox/charting/Chart': 'ubi/utils/tests/noopMock',
                    'dojox/charting/widget/Chart': 'ubi/utils/tests/noopMock',
                    'dojox/charting/axis2d/Default': 'ubi/utils/tests/noopMock',
                    'dojox/charting/plot2d/Lines': 'ubi/utils/tests/noopMock',
                    'dojox/charting/plot2d/Markers': 'ubi/utils/tests/noopMock',
                    'dojox/charting/plot2d/Pie': 'ubi/utils/tests/noopMock',
                    'dojox/charting/action2d/Highlight': 'ubi/utils/tests/noopMock',
                    'dojox/charting/action2d/Magnify': 'ubi/utils/tests/noopMock',
                    'dojox/charting/action2d/MoveSlice': 'ubi/utils/tests/noopMock',
                    'dojox/charting/action2d/PlotAction': 'ubi/utils/tests/noopMock',
                    'ubi/charting/themes/omega': 'ubi/utils/tests/noopMock'
                }
            },
            packages: [{
                name: 'dojo',
                location: 'src/libs/dojo'
            }, {
                name: 'dijit',
                location: 'src/libs/dijit'
            }, {
                name: 'dojox',
                location: 'src/libs/dojox'
            }, {
                name: 'ubi',
                location: 'src/client/ubi'
            }, {
                name: 'server',
                location: 'src/server'
            }, {
                name: 'tests',
                location: 'src/tests'
            }]
        },

        suites: unitTestFiles,

        functionalSuites: functionTestFiles,

        excludeInstrumentation: /(?:node_modules|libs|tests)/
    };
});

Update with the Gruntfile plugin configuration:

  • The unitTest variable is fetched with a value given as a parameter to the grunt command
  • I use it to run one test suite at a time

.

intern: {
    'unit-tests': {
        options: {
            runType: 'client',
            config: 'src/tests/internNode',
            reporters: ['console', 'lcovhtml'],
            reportDir: 'target/code-coverage',
            suites: unitTest === null ? [] : [unitTest]
        }
    }
}
Dom Derrien
  • 462
  • 2
  • 10
  • Note that removing the `excludeInstrumentation` attribute from the Intern config let the reports being generated. I found this trick in https://stackoverflow.com/questions/23290853/how-to-include-modules-for-code-coverage-when-using-intern-for-nodejs-unit-testi – Dom Derrien Aug 29 '14 at 19:20
  • You will need to at least provide your configuration in order for anyone to be able to respond to your question. – C Snover Aug 30 '14 at 20:34
  • As I did not change the configuration file during the upgrade process, I don't think it's related... However, I'm going to update the question with that piece of information. – Dom Derrien Sep 02 '14 at 11:12
  • Thanks. It was important to verify what the `excludeInstrumentation` looked like before digging. – C Snover Sep 02 '14 at 18:36

1 Answers1

1

There is a defect in Intern that is causing this issue. A patch to resolve the issue is at https://github.com/theintern/intern/pull/255 and will be landed for Intern 2.1 (and maybe another 2.0 point release).

C Snover
  • 17,908
  • 5
  • 29
  • 39
  • Thanks for the update Colin. I hope the fix to the [Intern issue #71](https://github.com/theintern/intern/issues/71#issuecomment-44213335) will make it 2.1 too. – Dom Derrien Sep 03 '14 at 02:13
  • FYI, I've just updated my local `runner.js` copy with the update to normalize the basePath and it does not correct the issue as my tests are run by `client.js`, not `runner.js`. See my Gruntfile config above ;) – Dom Derrien Sep 03 '14 at 12:52
  • 1
    Yeah, the same line exists in `lib/realClient.js` so it won’t work there too. – C Snover Sep 05 '14 at 01:21
  • You're right: calling `path.normalize()` on the generated `basePath` line 78 fixes the behavior. Thanks for having identified the right file to fix ;) – Dom Derrien Sep 05 '14 at 19:30