TwoLeggedMammal
TwoLeggedMammal

Reputation: 53

Ember CLI test intermittently failing

I'm having a problem where when running my Ember tests. Once in every 3-5 tries it hits errors before running any tests. When I run in server mode I can see this output:

ReferenceError: Can't find variable: EmberENV at http://localhost:7357/3256/tests/index.html?hidepassed, line 42

ReferenceError: Can't find variable: define at http://localhost:7357/assets/test-loader-53146f185443881bff29aab3e80079e2.js, line 3

ReferenceError: Can't find variable: define at http://localhost:7357/assets/tests-a72d35574ec0d1ab014d4af21210a23a.js, line 1

When I look at the offensive files referenced, they looks like this:

/* globals requirejs, require */
(function() {
define("ember-cli/test-loader",
  [],
  function() {
    "use strict";

    var moduleIncludeMatchers = [];
    var moduleExcludeMatchers = [];

    function addModuleIncludeMatcher(fn) {
      moduleIncludeMatchers.push(fn);
    }; 

etc...

As I understand, define() is a function introduced by requirejs, so it seems like it's just not loading before the tests begin. Any idea why this would be, and if there is any way to ensure things are loaded in the proper order?

Other important things; this doesn't seem to be an issue with the individual tests, as deleting them, especially the first which would be hit doesn't make a difference. This looks like it started happening occasionally after a big check in, where among other things, we went from 130 to 174 tests, but nothing particularly strange seems to have been introduced. I've also tried cutting out pieces of the new code with no change, BUT if I revert to the previous version it seems to still work correctly every time. It could just be a matter of the codebase growing larger.

For versions of dependencies:

EmberCLI: 1.13.13
node: 5.4.1
PhantomJS: 2.1.1

Anything else that would be helpful to provide? Thanks.

Upvotes: 2

Views: 310

Answers (2)

zhujy_8833
zhujy_8833

Reputation: 571

Forgot to report back here that it has been fixed in my case. First of all this issue was reported here: https://github.com/ariya/phantomjs/issues/14173, and it's likely caused by some inline import @import url(...) used in css.

The fix in my case is to write an alternative test runner which ignore the network request, similar to what @wagenet suggested in the above issue.

Hopefully that works for other use cases.

Upvotes: 1

Jon
Jon

Reputation: 1

We had the same issue and were able to fix it by updating qunit to 1.20.0 in bower.json

"qunit": "~1.20.0",

Upvotes: 0

Related Questions