0

I recently upgraded my "ember-cli" to "2.10.0" and "ember-cli-qunit" to "3.0.1" but each test module is getting run twice. However when I try the code in jsbin I am unable to recreate the issue. My test looks like:

import Qunit from 'qunit';
Qunit.module("[Reporting]", function (hooks) {

    hooks.before(function () {
        console.log("before");            
    });

    hooks.after(function () {
        console.log("after");            
    });

    Qunit.test("test 1", function (assert) {
        console.log("test 1");  
        assert.equal(1,1);
    });

    Qunit.test("test 2", function (assert) {
        console.log("test 2"); 
        assert.equal(1,1);
    });
}

I can see that my quint version is 2.1.1 and jquery version is 1.11.3.

My Index.html file looks like this;

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Studio Tests</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    {{content-for 'head'}}
    {{content-for 'test-head'}}

    <link rel="stylesheet" href="assets/vendor.css">
    <link rel="stylesheet" href="assets/studio-blessed1.css">
    <link rel="stylesheet" href="assets/studio.css">
    <link rel="stylesheet" href="assets/test-support.css">
    <style>#blanket-main { position: relative; z-index: 99999; }</style>

    {{content-for 'head-footer'}}
    {{content-for 'test-head-footer'}}
  </head>
  <body>

    {{content-for 'body'}}
    {{content-for 'test-body'}}
    <script src="assets/vendor.js"></script>
    <script src="assets/test-support.js"></script>
    <script src="assets/studio.js"></script>
    <script src="assets/blanket-options.js"></script>
    <script src="assets/blanket-loader.js"></script>
    <script src="testem.js"></script>
    <script src="assets/tests.js"></script>

    {{content-for 'body-footer'}}
    {{content-for 'test-body-footer'}}
  </body>
</html>
Deewendra Shrestha
  • 2,313
  • 1
  • 23
  • 53

1 Answers1

0

I found the issue with my test. I was trying to configure the set of tests that would loaded based on a query parameter I send when running the tests. The way I was trying to do that basically wrong.

In my test-helper.js, I had added :

import Resolver from 'studio/resolver';
import {setResolver} from 'ember-qunit';
import TestLoader from 'ember-cli-test-loader/test-support';

setResolver(Resolver.create());

//ADDED THIS PROTOTYPE AS PER MENTIONED IN https://github.com/ember-cli/ember-cli-test-loader
TestLoader.prototype.shouldLoadModule = function(moduleName) {
    //return (moduleName.match(/[-_]test$/));
    var additionalCondition = true;
    var dirName = QUnit.urlParams.directory;
    if (dirName) {
        additionalCondition = moduleName.indexOf(dirName + '/') === 0 && (moduleName.indexOf('/', dirName.length + 1) === -1);
    }
    return additionalCondition;
};

TestLoader.load();

But instead I had to do:

import Ember from 'ember';
import resolver from './helpers/resolver';
import {
    setResolver
} from 'ember-qunit';
import TestLoader from 'ember-cli-test-loader/test-support';

Ember.$(document).ready(function () {
    TestLoader.prototype.shouldLoadModule = function (moduleName) {
        //return (moduleName.match(/[-_]test$/));
        var additionalCondition = true;
        var dirName = QUnit.urlParams.directory;
        if (dirName) {
            additionalCondition = moduleName.indexOf(dirName + '/') === 0 && (moduleName.indexOf('/', dirName.length + 1) === -1);
        }
        return additionalCondition;
    };
});

setResolver(resolver);

But now I am getting following error when calling andThen helper method:

Assertion after the final `assert.async` was resolved

So:

//THIS FAILS(BUT USED TO WORK BEFORE QUINT UPGRADE)
test("DUMMY TEST 2", function (assert) {
    clickSomeElement();
    andThen(()=> {
        assert.equal(1, 1);
    });
});

I am using really classic version of ember "1.10.1". Not sure if it was caused by it! Could use some help resolving it. Posted here too: https://github.com/ember-cli/ember-cli/issues/6293

Deewendra Shrestha
  • 2,313
  • 1
  • 23
  • 53