Ember-mocha still supported in Ember v4?

I’m in the process of upgrading an app from Ember v3.28 to v4.4 and running into some issues w/ the test setup. I’m wondering if perhaps Ember-mocha is no longer supported? I noticed in the Ember docs (Introduction - Testing - Ember Guides) that from v4.3 to v4.4 the mention of ember-mocha disappeared. Further, the ember-mocha project hasn’t been updated since 2019, so it only mentions “Compatibility: Ember.js v3.4 or above” so that’s where my suspicions lie at the moment.

Additional details on my issue:

  • I already resolved all deprecation warnings on v3.28 before upgrading
  • Upgrading using the recommended method of ember-cli-update
  • Error details: “Global error: Uncaught ReferenceError: Ember is not defined at assets/test-support.js” “Global error: Uncaught Error: Could not find module @ember/test-helpers imported from tests/test-helper at assets/vendor.js” “Global error: Uncaught Error: The tests file was not loaded. Make sure your tests index.html includes “assets/tests.js”. at tests/index.html”

While I don’t use mocha, I have heard it doesn’t work in v4. There is a PR to deprecate it going forward, unless someone steps in to pick-up the maintenance. Deprecate `ember-mocha` by bertdeblock · Pull Request #858 · emberjs/rfcs · GitHub

Seconding Panman8201, ember-mocha is effectively dead. Switch to QUnit, you’ll probably want to add some assertion methods to QUnit in {{app-name}}/tests/helpers, using QUnit.assert.pushResult, to replace some expressiveness not found with the QUnit API (like assert.isEmpty or assert.includes).

I know there was at least one PR in ember-mocha that attempted to bring it up to date, but there was no engagement from the repository side to advance that further.

One “gotcha” you might hit with your current tests is that Mocha throws an error from its assert methods, so only one can fail in any given test. QUnit will run the whole test, so your tests may generate both failed assertions and then TypeErrors if you did things like

assert.notNull(objectOrNull);
assert.isTrue(objectOrNull.property)

etc.

My coworkers and I migrated our monorepo with 5 apps + an addon over about 3 months amidst our normal work. One of the benefits is that we can now use ember-exam to parallelize and randomize tests, so we are better off for having migrated, even though we aren’t yet ready to move to Ember 4 due to other deprecations.

I would add that there’s no inherent reason ember-mocha can’t be updated to keep working, it’s just that nobody has stepped forward to do it. If a team has a large amount of ember-mocha tests, it may well be easier for that team to spend some time to produce an updated fork of ember-mocha rather than port all their tests.

I’ll just mention here that we at Q2 currently use a fork of ember-mocha on our ember 4 application: GitHub - toddjordan/ember-mocha at embroider-updates