Closed kategengler closed 6 years ago
Awesome, thank you for reporting. This might be a duplicate, but I vaguely recall the other issue being in ember-qunit or ember-mocha repo. I'll try to dig into this this weekend...
@rwjblue last related update: https://github.com/ember-cli/ember-cli-qunit/issues/169#issuecomment-284129257
Seems like we need to include ember-testing.js
in production test builds
I began digging into this as I thought you should be able to workaround the issue with something like:
// ember-cli-build.js
app.import(app.bowerDirectory + '/ember/ember-testing.js', { type: 'test', prepend: true });
But this does not work, because ember-testing.js
does not properly add things to the global Ember
object. It requires the ember-testing
module but doesn't assign the exports to anything.
In other words, it does this:
require('ember-testing');
when it needs to do this:
let testing = require('ember-testing');
Ember.Test = testing.Test;
Ember.Test.Adapter = testing.Adapter;
Ember.Test.QUnitAdapter = testing.QUnitAdapter;
Ember.setupForTesting = testing.setupForTesting;
Basically, it is missing this section of code.
I feel like this should be fixed upstream in ember.js, so that ember-testing.js
can be used properly, but that won't fix previous releases. Another alternative is to write a shim that does the proper thing with ember-testing.js
.
@trentmwillis - Yes, agreed
I've opened a PR to fix part of this upstream: https://github.com/emberjs/ember.js/pull/15112 However, there will also need to be a fix in Ember-CLI since the path to ember-testing.js currently only works with the Bower distribution of Ember.
Fix for including ember-testing when using ember-source: https://github.com/ember-cli/ember-cli/pull/6944.
After these fixes, ember-testing loads, but it errors out. I'm investigating why, looks to be related to feature flagging in Ember itself. Nevermind, I guess I had something borked with all my npm link
s.
I'm not sure if these is related but in ember-cli-qunit 4.0.0, I see a global failure:
beforeEach failed on global failure: Cannot read property 'setContext' of null
TypeError: Cannot read property 'setContext' of null
at Object.beforeEach (http://localhost:7357/assets/test-support.js:8325:16)
at callHook (http://localhost:7357/assets/test-support.js:4072:25)
at runHook (http://localhost:7357/assets/test-support.js:4095:7)
at Object.advance (http://localhost:7357/assets/test-support.js:3691:26)
at Test.queue (http://localhost:7357/assets/test-support.js:4264:22)
at test (http://localhost:7357/assets/test-support.js:4498:12)
at Object.onError (http://localhost:7357/assets/test-support.js:5212:5)
at window.onerror (http://localhost:7357/assets/test-support.js:6558:18)
Uncaught TypeError: Cannot read property 'pushResult' of undefined
Among others...
It's hard to understand where this is coming from - the tests all pass in headless Chrome.
Our pipeline is building first with --environment=production but then we have to rebuild again to execute our tests as part of a following step. Is there a workaround to avoid the second build and execute tests on a production build @trentmwillis at this point?
@robydrupo I don't believe there is anyway to do a "tests-only" build (which is what it sounds like you want).
I'm going to close this issue as I believe the original problem has been solved (as noted in this comment). Other problems should be tracked in different issues.
ember test --environment=production
fails on newly generated app using ember-cli 2.12.0 (also observed on ember-cli 2.11.1)First checked that
ember test
passes as expected.Then tried
ember test --environment=production
, which has failures and hangs with the following output:I pushed the generated app here https://github.com/kategengler/ember-cli-2.12-generated-app for convenience.
Output from
ember version --verbose && npm --version
: