Search code examples
javascriptdojoamdintern

Intern directory structure in 1.1 and circular dependency errors


I've been struggling with what is the recommended directory structure for an Intern setup using Intern 1.1. I note that a change was made from 1.0 to 1.1 that affects where the intern dir is located.

I note that the dependency for intern package includes dojo but appears to refer to dojo v2: "dojo": "git+https://github.com/csnover/dojo2-core.git#1a7d8fa" I'm not sure why that is since v2 is not out yet.

I have struggled for several days now to get a very simple test file to run without success. My hierarchy is this:

web/ (root)
    node_modules/
        intern/
    tests/
        FilterGridTest.js
        intern.js
    libs/
        dojo/
        dijit/
        dgrid/
        ....
        ev/
            grids/
                FilterGrid.js (file being tested)

The upper part of my FilterGridTest.js file is:

define([
    'intern!object',
    'intern/chai!assert',
    'intern/chai!expect',
   'ev/grids/FilterGrid'
], function (registerSuite, assert, expect, FilterGrid) {
    registerSuite({
        name: 'FilterGrid Test',
    ...

I have tried a variety of modifications and either intern can't load the test file or it gets circular dependency errors:

Circular dependency: *5 -> tests/FilterGridTest -> ev/grids/FilterGrid -> dojo/dom-construct -> dojo/dom-attr -> dojo/dom-prop -> dojo/dom-construct

My intern.js file has this loader property:

loader: {
    //baseUrl: 'libs/',
    // Packages that should be registered with the loader in each testing environment
    packages: [
        { name: 'dojo', location: 'libs/dojo' },
        { name: 'dijit', location: 'libs/dijit' },
        { name: 'dgrid', location: 'libs/dgrid' },
        { name: 'put-selector', location: 'libs/put-selector' },
        { name: 'xstyle', location: 'libs/xstyle' },
        { name: 'ev', location: 'libs/ev' },
        { name: 'web', location: '.'}
    ]
},

where web is my web root and has a package.json file.

I don't know what is causing this error or how to fix it.


Solution

  • Circular dependencies notifications are not errors. Dojo 1, which you are using, has circular dependencies which it handles correctly. Dojo 1’s AMD loader will also report circular dependencies, but this functionality is disabled by default, whereas it is enabled by default in the loader used by Intern.