-
Notifications
You must be signed in to change notification settings - Fork 8.2k
/
test-boot-ember-cli.js
67 lines (56 loc) · 2 KB
/
test-boot-ember-cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import config from "../config/environment";
import { setEnvironment } from "discourse-common/config/environment";
import { start } from "ember-qunit";
import loadEmberExam from "ember-exam/test-support/load";
import * as QUnit from "qunit";
import { setup } from "qunit-dom";
setEnvironment("testing");
document.addEventListener("discourse-booted", () => {
// eslint-disable-next-line no-undef
if (!EmberENV.TESTS_FILE_LOADED) {
throw new Error(
'The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".'
);
}
const script = document.getElementById("plugin-test-script");
if (script && !requirejs.entries["discourse/tests/plugin-tests"]) {
throw new Error(
`Plugin JS payload failed to load from ${script.src}. Is the Rails server running?`
);
}
let setupTests = require("discourse/tests/setup-tests").default;
const params = new URLSearchParams(window.location.search);
const skipCore = params.get("qunit_skip_core") === "1";
const disableAutoStart = params.get("qunit_disable_auto_start") === "1";
// eslint-disable-next-line no-undef
Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION = false;
document.body.insertAdjacentHTML(
"afterbegin",
`
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="ember-testing-container" style="position: fixed">
<div id="ember-testing"></div>
</div>
`
);
setup(QUnit.assert);
setupTests(config.APP);
let loader = loadEmberExam();
if (QUnit.config.seed === undefined) {
// If we're running in browser, default to random order. Otherwise, let Ember Exam
// handle randomization.
QUnit.config.seed = Math.random().toString(36).slice(2);
} else {
// Don't reorder when specifying a seed
QUnit.config.reorder = false;
}
loader.loadModules();
start({
setupTestContainer: false,
loadTests: false,
startTests: !disableAutoStart,
setupEmberOnerrorValidation: !skipCore,
});
});
window.EmberENV.TESTS_FILE_LOADED = true;