0

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?

teaman
  • 469
  • 7
  • 18

1 Answers1

2
  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.
C Snover
  • 17,908
  • 5
  • 29
  • 39
  • To add to @csnover's answer, the loader used by Intern throws error you described because it cannot find the `dojo` package. This error is not due to the fact that tests are being run on module dependencies. – bitpshr Jun 21 '13 at 23:59
  • Thanks! I added the packages (dojo, dijit, dgrid, etc) and that now gets me to a new error: `node node_modules/intern/client.js config=tests/intern Defaulting to "console" reporter ReferenceError: document is not defined at /home/bholm/Projects/src/sandbox/web/libs/dojo/selector/_loader.js:5:15 at execModule (/home/bholm/Projects/src/sandbox/node_modules/intern/node_modules/dojo/dojo.js:512:54) at /home/bholm/Projects/src/sandbox/node_modules/intern/node_modules/dojo/dojo.js:579:7 ...` What "document" does it refer to? – teaman Jun 22 '13 at 00:42
  • In checking that file, document appears to be the global DOM document. Why would it not be defined? Something is missing from this configuration. – teaman Jun 22 '13 at 00:51
  • That separate question is answered in http://stackoverflow.com/questions/17285719/why-is-my-intern-test-failing-with-document-is-not-defined – C Snover Jun 25 '13 at 02:52