theintern / intern

A next-generation code testing stack for JavaScript.
https://theintern.io/
Other
4.36k stars 310 forks source link

NPM Install fails #862

Closed nwhite89 closed 6 years ago

nwhite89 commented 6 years ago

Expected behavior

Install intern v2

Current behavior

NPM install fails reporting zip file no longer exists

npm ERR! fetch failed https://github.com/csnover/dojo2-core/archive/ebfa11ba3972944218623a4bd9d124cb8108d70c.tar.gz

Steps to reproduce (for bugs)

npm install intern@2.2.2

Environment

Intern version: 2.2.2 Node version: v6.10.2 NPM version: v3.10.10 Browser version: n/a

jason0x43 commented 6 years ago

That repo is gone, but we could publish a new package that uses the dojo-2alpha npm package.

Just out of curiosity, is there a reason you're using Intern 2 vs Intern 3?

nwhite89 commented 6 years ago

In all honesty I hadn't gotten around trying to but I have done now.

alvaroortega commented 6 years ago

Hello, I'm having exactly the same issue causing our dev env is broken. I checked and I saw the version 3 has some backwards incompatibilities and also 4 does.

version 4 seems to be significantly different to version 2 so I decided to upgrade to version 3 first and see how it goes. NPM was able to finish so our dev env is back and running tho we cannot run the tests suites anymore.

We use a customised interns runner with PhantomJS 2.1.1 and this is what I got:

Running "fa_internjs:unit" (fa_internjs) task
Client configured to: http://localhost:8888/node_modules/fa-internjs-runner/node_modules/intern/client.html?config=app%2Fdist%2Ftests%2Fintern.js&reporters=%2Fnode_modules%2Ffa-internjs-runner%2Freporters%2Fphantom.js
Phantomjs test runner running PhantomJS: 2.1.1
>> Client HTML config replaced
Server listening to port: 8888
>> Server started

info: Error: Failed to load module /node_modules/fa-internjs-runner/app/dist/tests/intern.js from /node_modules/fa-internjs-runner/app/dist/tests/intern.js (parent: *11)
info:
info:   http://localhost:8888/node_modules/fa-internjs-runner/node_modules/intern/browser_modules/dojo/loader.js:518 in handler

app/dist/tests/internjs is in the root directory but for some reason dojo loader is searching there.

Also just out of curiosity. We just noticed this issue when we tried to bootstrap a fresh clone of our repo. Was the removal of this dependency noticed somewhere we missed? It seems the version 2 can't be used anymore.

Thanks

marzetas commented 6 years ago

Same issue here.

@jason0x43 Please do, it will alleviate the pain while moving to intern 3 (or 4)

jason0x43 commented 6 years ago

Ah, the dangers of relying on non-organizational GitHub dependencies. Luckily, we managed to scrounge up a copy of the missing one and published it to npm. Intern 2.2.3 is out now and uses the new dependency.

alvaroortega commented 6 years ago

I'll give it a try right now. And let you know, thanks. Our target is to upgrade our tech stack but better if you are not under pressure of a broken build pipe hehe.

Any thoughts on my issue above tho? I have tried setting a basePath I have tried changing loader by loaderOptions on intern.js as I understood from here https://github.com/theintern/intern/releases/tag/3.0.0

and setting a basePath property but no luck.

jason0x43 commented 6 years ago

Have you defined the app package in your loaderOptions? It looks like app/dist/tests/ was resolved to /node_modules/fa-internjs-runner/app/dist/tests.

alvaroortega commented 6 years ago

not there. is a config option I pass to the task runner. What I'm not sure is when /node_modules/fa-internjs-runner is being injected to the path.

I can see on client.hmlt this bit:

var initialBaseUrl = (function () {
    var result = /[?&]initialBaseUrl=([^&]*)/.exec(location.search);
    if (result) {
    var baseUrl = decodeURIComponent(result[1]);
    if (/^(?:\w+:)?\/\//.test(baseUrl)) {
        throw new Error('Cross-origin loading of test modules is not allowed for security reasons');
    }
    return baseUrl;
    }
    else {
    // For users running client.html directly, assume that the initial base URL is two levels up
    // (the parent directory of node_modules/intern); this is most common.
        // Users that need something special can provide a different `initialBaseUrl`.
    return internPath.replace(/(?:\/+[^\/]*){2}\/?$/, '/');
     }
})();

From the comment I guess I should define initialBaseUrl on intern.js? Within the loaderOptions properties?

jason0x43 commented 6 years ago

Define a baseUrl in loaderOptions, like:

loaderOptions: {
    baseUrl: '../../',
    ...
}
alvaroortega commented 6 years ago

No luck, same results. Also I have tried installing 2.2.3 but this time I'm getting xhrRequest Failing. I observed that now the dojo dependency is called "@theintern/dojo": "2.0.0-alpha.1" which creates an extra level. I have sorted out modifying the client.html to point to the correct path.

I have created a ticket #871 and I tried to create a PR but I'm not allow to commit a branch into the repo

alvaroortega commented 6 years ago

Upgrading to version 3.4.6 is looking good now. Apart from the changes on the config file I need to rewrite the reporter now according to these notes: https://github.com/theintern/intern/releases?after=3.0.4

I have had to add the config param initialBaseUrl to tell the client where the config file is. Also basePath needs to be now a self property of the config file, not par of loaderOptions

alvaroortega commented 6 years ago

@jason0x43 I got intern 3.4.6 up and running fine on my environment now. I have one last question I think.

In order to allow writing tests using ES6 we have babel. using grunt i got a custom task that among other things basically injects that dependency into client.html module:

<title>Browser test runner</title>
<script src="browser_modules/dojo/loader.js"></script>
<script src="/app/libs/babel-polyfill/dist/polyfill.min.js"></script>

It works but I wonder if there is a civilised way to add this external support. Any ideas?

Thanks

jason0x43 commented 6 years ago

The original issue was fixed in https://github.com/theintern/intern/commit/f8ad1c1d435641702ae20d769823d14382e78b64

jason0x43 commented 6 years ago

Regarding the grunt question, you could use a plugin to load babel or polyfills in the browser before tests run. Just load the polyfill script as a plugin:

{
    "browser": {
        "plugins": "/apps/libs/babel-polyfill/dist/polyfill.min.js"
    }
}

That will cause the browser executor to script-inject the polyfill script into the page before testing starts.

alvaroortega commented 6 years ago

thanks for that. This seems to be available only for version 4 no? we are using version 3.4.6

jason0x43 commented 6 years ago

Ah, yes. In that case, you could use a setup function in the config, maybe something like the following:

// intern.js
define(..., function () {
  // ...

  setup: function () {
    return new Promise(function (resolve) {
      require([ 'apps/libs/babel-polyfill/dist/polyfill.min.js' ], resolve);
    });
  }
});