tomdale / ember-cli-addon-tests

31 stars 18 forks source link

Creating two apps with manual npm install step throws #215

Open jelhan opened 4 years ago

jelhan commented 4 years ago

Seeing an error thrown by npm itself if I create two apps with manual npm install steps in the same mocha instance:

const expect = require('chai').expect;
const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp;

describe('creating two apps', function() {
  this.timeout(300000);

  it('creates first app', async function() {
    let app = new AddonTestApp();

    await app.create('default', {
      noFixtures: true,
      skipNpm: true,
    });
    await app.run('npm', 'install');
  });

  it('creates second app with different dependencies', async function() {
    let app = new AddonTestApp();

    await app.create('default', {
      noFixtures: true,
      skipNpm: true,
    });
    await app.run('npm', 'install');
  });
});
  creating two apps
    ✓ creates first app (47737ms)
    1) creates second app with different dependencies
npm WARN 
deprecated exists-sync@0.0.4: Please replace with usage of fs.existsSync

npm
 ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm
 ERR!     <https://npm.community>

  1 passing (3m)
  1 failing

  1) creating two apps
       creates second app with different dependencies:
     Error: the object {
  "code": 1
  "errors": [
    "npm WARN "
    "deprecated exists-sync@0.0.4: Please replace with usage of fs.existsSync\n"
    "npm"
    " ERR! cb() never called!\n"
    "\n"
    "npm ERR! This is an error with npm itself. Please report this error at:\nnpm"
    " ERR!     <https://npm.community>\n"
  ]
  "output": []
  "signal": [null]
} was thrown, throw an Error :)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:189:7)
$ ember -v
ember-cli: 3.13.1
node: 8.16.1
os: linux x64

$ npm -v
6.4.1

Please note that this only happening if app.run('npm', 'install') is called twice. It seems to work fine if installed as part of app.create('default', { noFixtures: true }) and not calling app.run('npm', 'install') manually.

A work-a-round is splitting it up into multiple files and running a mocha instance per file.

I've faced this in https://github.com/rwjblue/ember-cli-content-security-policy/pull/113.