ember-mocha icon indicating copy to clipboard operation
ember-mocha copied to clipboard

Ember-Mocha + Ember-Cli-Mocha = invalid /tests HTML

Open mike-north opened this issue 7 years ago • 3 comments

A project with both ember-cli-mocha and ember-mocha as top-level ember addons will result in duplicate fixture HTML being rendered. Unfortunately, this also means that more than one DOM element has the same id. This is not allowed.

screen shot 2018-07-31 at 11 20 06 am

The end result is that tests will pass, but the developer will not be able to easily inspect the rendered app in the 50% scaled frame (the second set of DOM elements) due to the real testing being done in the first set of DOM elements.

Removing ember-cli-mocha from the app's package.json resolves this problem.

Possible root cause

the contentFor hook of this addon is https://github.com/emberjs/ember-mocha/blob/13be23a36a6af0f6f1cffe934b905a2bbe1fd39e/index.js#L66-L77

and for ember-cli-mocha https://github.com/ember-cli/ember-cli-mocha/blob/64d8742b7fdc8535f76b545fb7fc7c6d6c97b01c/index.js#L10-L13

  contentFor(type) {
    let output = this.eachAddonInvoke('contentFor', [type]);
    return output.join('\n');
  },

It's possible that this results in ember-mocha's fixture HTML being inserted twice

mike-north avatar Jul 31 '18 18:07 mike-north

ember-cli-mocha and ember-mocha should not be installed at the same time. ember-cli-mocha already brings its own ember-mocha dependency, but ultimately we should just use ember-mocha directly from now on

Turbo87 avatar Mar 18 '19 16:03 Turbo87

@Turbo87 any reason why we shouldn't check for invalid dependency situations in this addon's included hook?

mike-north avatar Mar 18 '19 17:03 mike-north

no, makes sense to check it. though we need to be careful to not warn for the app -> ember-cli-mocha -> ember-mocha dependency scenario.

Turbo87 avatar Mar 18 '19 18:03 Turbo87