Upgrading Ember Project

So I have been spending the day upgrading our project from version 2.16.2. I made it all the way to 3.3 and then jumped to 3.6. But when it would build and our sandbox would load, the app itself loads in the iFrame but never reaches the route.

I see two errors in the console:

VM737 vendor.js:22239 Uncaught TypeError: url.indexOf is not a function at jQuery.fn.init.jQuery.fn.load (VM737 vendor.js:22239) at VM737 vendor.js:93746 at VM737 vendor.js:93746

Followed by:

VM737 vendor.js:252 Uncaught Error: Could not find module ember-load-initializers imported from psst/app at missingModule (VM737 vendor.js:252) at findModule (VM737 vendor.js:263) at Module.findDeps (VM737 vendor.js:173) at findModule (VM737 vendor.js:267) at requireModule (VM737 vendor.js:29) at VM738 psst.js:51134

I am not the original author and I know that we did a lot of shoe horning around problems in Ember even earlier than 2.16 when it was written. Is this a know issue with a work around? I deleted all the old tmp directories (including dist), removed node_modules, and reinstalled everything. We never used bower components so that was not an issue.

This happened as well when I tried to go from 2.16.2 straight to 3.17.0 but the second error was ember resolver instead of the initializer. But the jQuery error was still there.

This was just a project to convince work we could upgrade to get some of the newer fixes and functionality. Our app is stable at its current version and at 3.3 but if possible I would like to finish up. We have another more important and larger application that will follow suit in upgrading so this will help that team as well.

Thanks, Brian

I would focus on the first exception first. Assuming it happens while evaluating vendor.js, it would cause the second exception by preventing other modules like ember-load-initializers from ever getting defined.

If you dig into the stack trace for that first exception, you should be able to figure out what code it’s happening in, and then figure out where that code comes from. It will either be some addon you’re using, or it will be something added by app.import() in your ember-cli-build.js file (formerly brocfile).

Thanks I found the offending import. Not sure I understand why it is causing problems but we try to load foundation by first using a funnel:

nodeModulesToVendor: [ new Funnel(new UnwatchedDir(‘node_modules/@vcc/threeds-manager-api/build’), { files: [‘threeds-manager-api.js’] }), new Funnel(new UnwatchedDir(‘node_modules/foundation-sites/dist’), { files: [‘foundation.min.js’] }), ],

Then import it. I checked to make sure the file is where the funnel thinks it should be in node modules. We do other modules that way as well.

Once we get past that though I still get an error :loader.js:247 Uncaught Error: Could not find module ember imported from ember-i18n/services/i18n. Seems to be on a post message but that is as far back as the call stack goes. Solutions I saw by searching are using shims but those are deprecated and we never used them before the upgrade. There was something else about lodash which we do include in the same manner above but removing that does not remove the error.

There is no module ember anymore in newer releases. It’s all splitted in modules under @ember/ namespace. I guess you need to upgrade ember-i18n. If you are already on latest version you might need to do migration to ember-intl first as ember-i18n is deprecated.

Yeah I found the issue. The upgrade of ember must have upgraded the jquery included and that broke foundations. I was able to update foundation but got a SASS compilation error. So for the time being I am focusing on not moving forward with Ember beyond 3.3. Later I will try to continue but I have to get unit tests running in 3.3 and getting weird global error:…

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

Global error: Uncaught Error: Could not find module @ember/test-helpers imported from psst/tests/test-helper at localhost:444/asse ts/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 localhost:444/assets/vendor.js, line 24138

Global error: Uncaught Error: Could not find module ember-cli/test-loader imported from (require) at localhost:444/assets/vendor.j s, line 252

Not sure what is causing this when running ember test --server. I can see the line (last line):

QUnit.extend(QUnit.assert, { dom: function dom(target, rootElement) { rootElement = rootElement || this.dom.rootElement || document; return new DOMAssertions(target || rootElement, rootElement, this); } });

}(QUnit));

Used to work on 2.16 and I didn’t really change the way that I did it but I cannot find any documentation that said there was a different way unless I broke something in the testem file. Not sure where else to look.

Hmm. I think the error with QUnit may be that you upgraded your app to 3.3. Around v3.0 or 3.1, Ember QUnit updated its testing API.

You may want to check out https://github.com/emberjs/ember-qunit/blob/master/docs/migration.md and articles written in 2018, 19 to learn more about how to update your tests. You may also want to start using QUnit DOM for readable assertions, as this becomes a default in later 3.x versions.

Best,

Actually the root cause is the migration from ember-cli-mocha to ember-mocha. The migration read me has the instructions to simply use yarn remove ember-cli-mocha and yarn add -D ember-mocha but that leaves the old test-helpers file sitting around with a reference to QUnit. However if you use ember install ember-mocha it overwrites the test-helpers file and that solves the issue.

Now I just have the unit tests failing because the embedded inline content is no longer seeming to be added to the test framework run. We have some preflight tasks that we add as inline content that are undefined in the new test runs. That will probably be fun to figure out why that is happening.

1 Like

Anyone know what causes this error in unit tests: Error: Please pass the subject owner to beforeEach()

Other than foundation changes making everything super small compared to older versions, that is the major hurdle I have left to fix to finish off the upgrade to 3.4 (since 3.3 was not supported in ember-mocha).

See https://github.com/emberjs/ember-mocha/issues/544, I think it’s the same issue as yours.