Stuck upgrading to Ember 3.4.4

Howdy! :wave:

Background can be found in this topic. (apologizes for the incoming wall of text)

After upgrading to 3.4.4 I’m now seeing this when I attempt to run my test suite:

Global error: Uncaught ReferenceError: QUnit is not defined at http://localhost:7357/assets/test-support.js, line 59296

Global error: Uncaught Error: Could not find module `ember-mocha` imported from `thcic-frontend/tests/test-helper` at http://localhost:7357/assets/vendor.js, line 252

Global error: Uncaught Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 27798

Global error: Uncaught Error: Could not find module `ember-cli/test-loader` imported from `(require)` at http://localhost:7357/assets/vendor.js, line 19187

DEPRECATION: Getting the '@each' property on object  is deprecated [deprecation id: ember-metal.getting-each] See https://emberjs.com/deprecations/v3.x#toc_getting-the-each-property for more details.
        at logDeprecationStackTrace (http://localhost:7357/assets/vendor.js:28041:29)
        at HANDLERS.<computed> (http://localhost:7357/assets/vendor.js:28143:17)
        at raiseOnDeprecation (http://localhost:7357/assets/vendor.js:28065:17)
        at HANDLERS.<computed> (http://localhost:7357/assets/vendor.js:28143:17)
        at invoke (http://localhost:7357/assets/vendor.js:28152:17)
        at deprecate (http://localhost:7357/assets/vendor.js:28124:34)
        at Array.<anonymous> (http://localhost:7357/assets/vendor.js:64334:47)
        at ComputedProperty.get (http://localhost:7357/assets/vendor.js:56534:36)
        at Array.CPGETTER_FUNCTION (http://localhost:7357/assets/vendor.js:54804:31)

Uncaught ReferenceError: QUnit is not defined at http://localhost:7357/assets/test-support.js, line 59296

Uncaught Error: Could not find module `ember-mocha` imported from `thcic-frontend/tests/test-helper` at http://localhost:7357/assets/vendor.js, line 252 

Uncaught Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 27798

Uncaught Error: Could not find module `ember-cli/test-loader` imported from `(require)` at http://localhost:7357/assets/vendor.js, line 19187

Steps I took to get here:

  • updated forwards-compatible packages for Ember 2.18.2 application
  • ran ember-cli-update --to 3.0
  • fixed merge conflicts; test suite Green
  • Replaced ember-cli-mocha@0.15.0 with ember-mocha@0.14.0; fixed 1 test
  • removed ember-cli-update as an addon and globally installed it
  • ran ember-cli-update and did Semver String ‘3.4.4’
  • fixed merge conflicts
  • fixed component template; had an errant <
  • test suite hung; I normally run ember test --reporter dot --silent
  • singled out a test using --filter; noticed the errors
  • searched source for "qunit" in the tests; found an import in a tests/helper file
  • commented out the contents of the file and reran the test to no avail
  • Went to the web, tried the following:
  1. removed node_modules and reinstalled packages
  2. downgraded ember-mocha to 0.13.1; npm uninstall & ember install
  3. downgraded ember-mocha to 0.13.0; npm uninstall & ember install

I feel I am truly stuck.

Warning: Javascript is not my ‘first’ language. And I still struggle with Ember and JS-development in general. So, assume a complete rookie here. Your questions will not offend me because I’m trying to learn. I don’t know what I don’t know.

Thank you, in advance, to any and all assistance. :heart:

Sounds like something is wrong with the mocha install/configuration. When you installed mocha did you use npm install ember-mocha or just edit package.json and run npm install or did you use ember install?

I ask because ember addons have special files called blueprints which do any extra config/changes required to set up an addon. So if you install a package via npm install it doesn’t run the blueprints and you have to run them manually, usually with ember g package-name.

My suggestion would be to try removing ember-mocha from your package.json, then try ember install ember-mocha and see if the blueprint fixes anything. I noticed you also said you tried ember-mocha at 0.14 but it’s probably worth trying the latest (0.16) which should install by default with the command i mentioned.

EDIT: if the 0.16 breaking changes cause you issues than maybe try 0.15.1 instead, that still has the blueprint.

1 Like

Thanks :+1: This has gotten over this first hurdle.

I used ember install ember-mocha, after removing it from package.json and, indeed, saw a different installion.

FWIW, ember-mocha@0.14.0 does not have the blueprint, and running ember g ember-mocha resulted in a failed operation.

Time to fix test failures! :smiley:

woot! different errors equals progress in my book :laughing:

And hang in there, upgrades can be tricky sometimes but very worth it. And of course post again if you get stuck!

1 Like

Rather than create a separate topic I’m opting to continue the conversation in this thread, especially because I’m still at the ‘upgrade to 3.4’ stage.

Right now I feel it’s my lack of Javascript experience impeding my progress, so there’s that.

I ran, what I feel are the appropriate code mods. I even ran the ember-mocha codemods. I already know I have tests to clean up, but what’s happening now is definitely not expected.

In a the non-upgraded branch, when I run ember test -r dot --silent --filter "Acceptance" I get:

291 tests complete

In the upgrade branch I get:

4 tests complete

That’s it; no additional errors/failures. This has produced a number of questions:

  1. Where are the other tests?
  2. Why didn’t they get included with the others?
  3. How does ember test really work?

Any guidance will be greatly appreciated.

At a high level Ember CLI uses a library called testem as a test runner, and then either ember-qunit or ember-mocha to integrate the ember project tests and ember application lifecycle with the respective testing framework. I think the CLI finds tests by looking for anything under /tests that ends in -test.js but i could be wrong about that.

To debug I’d start by looking into a few things…

  • what did the ember-mocha codemod change? (look at a diff for one of the tests)
  • what’s the diff on testem.js, tests/test-helper.js, tests/index.html
  • what happens if you run the test command without the extra flags e.g. `ember t --filter “Acceptance”? What are the four tests that do run? is there any difference between the file(s) that runs and the others?
  • what happens if you run ember s and go to the browser test runner localhost:4200/tests? anything different?
1 Like

All excellent advice, per usual, however I think I stumbled on my issue.

Because we’re linting during building, could it be that tests that fail that step aren’t included in the final test build?

I ask because when I run: npx eslint tests/acceptance I’m met with a large number of errors and warnings: 172 problems (157 errors, 15 warnings).

So, maybe I should fix those first. :smiley: