Search code examples
javascriptautomated-testsintern

Intern 4 tests fail to load the Dojo2 loader


I'm migrating from Intern 3/requirejs to Intern 4/dojo2. I'm trying to run a test and immediately after the capabilities checks it will fail before ever loading my tests with this error:

Listening on localhost:9000 (ws 9001)
Tunnel started

‣ Created remote session chrome 66.0.3359.139 on XP (bc531663-f9f7-4cba-9038-6ab15808e9a0)
Suite chrome 66.0.3359.139 on XP FAILED
Error: Unable to load /..\node_modules\intern/loaders/dojo2.js
  at HTMLScriptElement.<anonymous>  <node_modules\intern\browser\remote.js:667:23264>
TOTAL: tested 1 platforms, 0 passed, 0 failed; suite error occurred

It's 404ing on that file from http://localhost:9000/__intern/browser/remote.html because it's trying to get dojo2.js from the wrong path by the looks of it. If I replace dojo2 in my config script with __intern/loaders/dojo2.js it will then 404 on /node_modules/@dojo/loader/loader.js. It looks like it's just looking for the wrong paths, is there something I can do to fix this?

intern.json

{
    "loader": {
        "script": "dojo2",
        "config": {
            "waitSeconds": 60,
            "packages": [ {
                    "name": "objects",
                    "location": "objects"
                }, {
                    "name": "edits",
                    "location": "./",
                    "main": "edits"
                }, {
                    "name": "prepare",
                    "location": "TESTS",
                    "main": "prepare"
                }, {
                    "name": "common",
                    "location": "./",
                    "main": "common"
                }, {
                    "name": "socket",
                    "location": "http://localhost:2020/socket.io",
                    "main": "socket.io"
                }
            ]
        }
    },
    "suites": [
        "./functional/InitTests.js"
    ],
    "environments": [ {
            "browserName": "chrome"
        }
    ],
    "tunnelOptions": {
        "drivers": [
            "chrome"
        ],
        "port": 4444,
        "version": "3.4.0",
        "maxConcurrency": 1,
        "runnerClientReporter": {
            "writeHtml": false
        }
    },
    "tunnel": "null",
    "leaveRemoteOpen": true,
    "grep": ""
}

Solution

  • There are a few potential issues:

    • Have you installed @dojo/loader? The loader scripts require that the associated loader be installed as a peer of Intern.
    • When using an AMD loader, specify tests as module IDs rather than file names
    • Does ./functional/InitTests.js actually contain functional tests? If so, it should be specified under functionalSuites.