teaman
teaman

Reputation: 479

Intern excludeInstrumentation regex fails to exclude modules

I'm new to Intern and trying to figure out how to configure it for our project. Our file hierarchy is not exactly the same as the examples in the intern-tutorial or readme for intern on github. I think I have the package locations correctly specified as it does not complain about not finding the test module. It even seems to run the test I have setup but it then tries to run tests on the rest of the modules defined in my package module being targeted. It first tries to load .../dojo/_base/declare.js. So I tried to specify the excludeInstrumentation property value.

I specified it as:

excludeInstrumentation: /^(?:dojo|dijit|dgrid|tests)\//

but it doesn't exclude it. My target module has this in the define:

define([
  'dojo/_base/declare',
  'dojo/_base/lang',
  'dojo/dom-construct',
  'dojo/on',
  'dojo/query',
...
  'dijit/layout/BorderContainer',
  'dijit/layout/ContentPane',
  'dijit/form/TextBox',
...
  'dgrid/OnDemandGrid',
  'dgrid/Keyboard',
...

But I get errors:

node node_modules/intern/client.js config=tests/intern
Defaulting to "console" reporter
Error: Failed to load module dojo/_base/declare from 
  /home/bholm/Projects/src/sandbox/dojo/_base/declare.js 
  (parent: ev/grids/FilterGrid)
at /home/bholm/Projects/src/sandbox/node_modules/intern/node_modules/dojo/dojo.js:742:12
at fs.js:207:20
at Object.oncomplete (fs.js:107:15)

I should note that the dojo, dijit and dgrid packages are actually located in: /home/bholm/Projects/src/sandbox/libs/dojo/... (notice the addition of libs in the path).

I forgot to add my loader property in the config file intern.js:

loader: {
    //baseUrl: '..',
    packages: [
        { name: 'intern', location: 'node_modules/intern' },
        { name: 'ev', location: 'web/libs/ev' }
    ]
},

Any ideas on why the regex is not excluding?

Upvotes: 0

Views: 585

Answers (1)

C Snover
C Snover

Reputation: 18766

  1. Do not put the intern package in your loader configuration. Only put application-specific configuration in the loader configuration.
  2. excludeInstrumentation is only to prevent your scripts from being modified with code coverage data when passed through the Intern proxy. It does not change the way the loader works, or stop your AMD dependencies from being requested and loaded normally.
  3. If your application uses 3rd party packages (dojo, dijit, etc.) that are not directly within baseUrl, you need to make sure that they are configured in packages, just like they need to be configured when running the actual application.

Upvotes: 2

Related Questions