Question

I'm trying to write a custom reporter outside the intern/lib/reporters location and don't understand what absolute mid's for custom reporters should look like. e.g.

test configuration at /var/www/tmp/intern-tutorial/intern-tutorial/tests/intern.js

reporters : ["/var/www/tmp/intern-tutorial/customreporters/bugreporter"]

or

reporters : ["../customreporters/bugreporter"]

And bugreporter module:

    define([
    'dojo/node!istanbul/lib/collector',
    'dojo/node!istanbul/lib/report/cobertura',
], function (Collector, Reporter) {
    var collector = new Collector(),
        reporter = new Reporter();

    return {
        '/coverage': function (sessionId, coverage) {
            //debugger;
            console.log("heeeere 1");
            collector.add(coverage);
        },
        '/runner/end': function () {
            //debugger;
            console.log("heeeere 2");
            reporter.writeReport(collector, true);
        }
    };
});

Using this configuration I get the error:

Error: Failed to load module dojo/node from /var/www/tmp/intern-tutorial/dojo/node.js (parent: dojo/node!17!*)
at injectUrl (/var/www/tmp/intern-tutorial/node_modules/intern/node_modules/dojo/dojo.js:743:12)
Était-ce utile?

La solution

An absolute module ID is a module ID that contains no .. or . parts, and is a module ID. Your first example is a path, not a module ID. Your second example is a relative module ID, not an absolute module ID. If your baseUrl is /var/www/tmp/intern-tutorial, your correct absolute module ID is customreporters/bugreporter.

All that said, the error you are experiencing is because you are trying to load modules from a dojo directory that does not exist. Intern does not expose its internal copy of Dojo as dojo except to itself using map. If the software you are testing uses Dojo, you need your own copy. If you are trying to use Intern’s copy of Dojo, you need to either map it yourself or reference the canonical module ID (intern/node_modules/dojo).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top