ember-exam 8.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-plan.json +21 -0
- package/README.md +80 -17
- package/addon-test-support/-private/async-iterator.js +4 -4
- package/addon-test-support/-private/{ember-exam-qunit-test-loader.js → ember-exam-test-loader.js} +6 -6
- package/addon-test-support/-private/filter-test-modules.js +7 -7
- package/addon-test-support/-private/patch-testem-output.js +5 -1
- package/addon-test-support/-private/split-test-modules.js +7 -17
- package/addon-test-support/-private/weight-test-modules.js +2 -3
- package/addon-test-support/.eslintrc +6 -0
- package/addon-test-support/index.js +1 -0
- package/addon-test-support/load.js +2 -2
- package/addon-test-support/start.js +5 -19
- package/index.js +0 -31
- package/lib/.eslintrc +5 -0
- package/lib/commands/exam/iterate.js +26 -24
- package/lib/commands/exam.js +38 -44
- package/lib/commands/task/test-server.js +1 -1
- package/lib/commands/task/test.js +1 -1
- package/lib/utils/config-reader.js +1 -1
- package/lib/utils/execution-state-manager.js +2 -2
- package/lib/utils/file-system-helper.js +1 -1
- package/lib/utils/test-page-helper.js +2 -2
- package/lib/utils/testem-events.js +13 -13
- package/lib/utils/tests-options-validator.js +26 -36
- package/package.json +69 -103
- package/CHANGELOG.md +0 -594
- package/addon-test-support/-private/ember-exam-mocha-test-loader.js +0 -87
- package/addon-test-support/-private/get-test-loader.js +0 -30
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"solution": {
|
|
3
|
+
"ember-exam": {
|
|
4
|
+
"impact": "minor",
|
|
5
|
+
"oldVersion": "9.0.0",
|
|
6
|
+
"newVersion": "9.1.0",
|
|
7
|
+
"constraints": [
|
|
8
|
+
{
|
|
9
|
+
"impact": "minor",
|
|
10
|
+
"reason": "Appears in changelog section :rocket: Enhancement"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"impact": "patch",
|
|
14
|
+
"reason": "Appears in changelog section :house: Internal"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"pkgJSONPath": "./package.json"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"description": "## Release (2025-03-05)\n\nember-exam 9.1.0 (minor)\n\n#### :rocket: Enhancement\n* `ember-exam`\n * [#1313](https://github.com/ember-cli/ember-exam/pull/1313) Use ember-exam with vite ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n\n#### :house: Internal\n* `ember-exam`\n * [#1336](https://github.com/ember-cli/ember-exam/pull/1336) Update release-plan ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n * [#1333](https://github.com/ember-cli/ember-exam/pull/1333) Fix lints since eslint-plugin-ember was upgraded ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n * [#1332](https://github.com/ember-cli/ember-exam/pull/1332) Revert #1188 ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n * [#1330](https://github.com/ember-cli/ember-exam/pull/1330) Revert \"Update dependency ember-qunit to v9\" ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n * [#1329](https://github.com/ember-cli/ember-exam/pull/1329) Revert \"Update pnpm to v10.5.2\" ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n * [#1322](https://github.com/ember-cli/ember-exam/pull/1322) Setup Release plan ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n * [#1314](https://github.com/ember-cli/ember-exam/pull/1314) Convert to pnpm ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n * [#1289](https://github.com/ember-cli/ember-exam/pull/1289) Add .codeclimate.yml to .npmignore ([@SergeAstapov](https://github.com/SergeAstapov))\n\n#### Committers: 2\n- Sergey Astapov ([@SergeAstapov](https://github.com/SergeAstapov))\n- [@NullVoxPopuli](https://github.com/NullVoxPopuli)\n"
|
|
21
|
+
}
|
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
# Ember Exam
|
|
2
|
-
|
|
2
|
+

|
|
3
3
|
[](https://badge.fury.io/js/ember-exam)
|
|
4
4
|
[](https://emberobserver.com/addons/ember-exam)
|
|
5
|
-
[](https://codeclimate.com/github/trentmwillis/ember-exam)
|
|
6
|
-
[](https://codeclimate.com/github/trentmwillis/ember-exam/coverage)
|
|
7
5
|
|
|
8
|
-
Ember Exam is an addon to allow you more control over how you run your tests when used in conjunction with [
|
|
6
|
+
Ember Exam is an addon to allow you more control over how you run your tests when used in conjunction with [ember-qunit](https://github.com/emberjs/ember-qunit). It provides the ability to randomize, split, parallelize, and load-balance your test suite by adding a more robust CLI command.
|
|
9
7
|
|
|
10
8
|
It started as a way to help reduce flaky tests and encourage healthy test driven development. It's like [Head & Shoulders](http://www.headandshoulders.com/) for your tests!
|
|
11
9
|
|
|
@@ -15,6 +13,7 @@ The [documentation website](https://ember-cli.github.io/ember-exam/) contains ex
|
|
|
15
13
|
|
|
16
14
|
## Table of Contents
|
|
17
15
|
|
|
16
|
+
- [Compatibility](#compatibility)
|
|
18
17
|
- [Installation](#installation)
|
|
19
18
|
- [How To Use](#how-to-use)
|
|
20
19
|
* [Version < `3.0.0`](#version--300)
|
|
@@ -24,17 +23,23 @@ The [documentation website](https://ember-cli.github.io/ember-exam/) contains ex
|
|
|
24
23
|
+ [Split Test Parallelization](#split-test-parallelization)
|
|
25
24
|
* [Test Load Balancing](#test-load-balancing)
|
|
26
25
|
- [Test Failure Reproduction](#test-failure-reproduction)
|
|
26
|
+
* [Preserve Test Name](#preserve-test-name)
|
|
27
27
|
- [Advanced Configuration](#advanced-configuration)
|
|
28
28
|
* [Ember Try & CI Integration](#ember-try--ci-integration)
|
|
29
29
|
* [Test Suite Segmentation](#test-suite-segmentation)
|
|
30
30
|
|
|
31
|
+
## Compatibility
|
|
32
|
+
|
|
33
|
+
* Ember.js v4.8 or above
|
|
34
|
+
* Ember CLI v4.8 or above
|
|
35
|
+
* Node.js v18 or above
|
|
31
36
|
|
|
32
37
|
## Installation
|
|
33
38
|
|
|
34
39
|
Installation is as easy as running:
|
|
35
40
|
|
|
36
41
|
```bash
|
|
37
|
-
$
|
|
42
|
+
$ npm install --save-dev ember-exam
|
|
38
43
|
```
|
|
39
44
|
|
|
40
45
|
## How To Use
|
|
@@ -63,16 +68,53 @@ $ ember exam --load-balance --parallel --server
|
|
|
63
68
|
|
|
64
69
|
The idea is that you can replace `ember test` with `ember exam` and never look back.
|
|
65
70
|
|
|
66
|
-
To get the unique features of Ember Exam (described in-depth below), you will need to **replace** the use of `start()` from `
|
|
71
|
+
To get the unique features of Ember Exam (described in-depth below), you will need to **replace** the use of `start()` from `ember-qunit` in `test-helper.js` with `start()` from `ember-exam`:
|
|
67
72
|
|
|
68
73
|
```js
|
|
69
74
|
// test-helper.js
|
|
70
|
-
import start from 'ember-exam/test-support
|
|
75
|
+
import { start } from 'ember-exam/test-support';
|
|
71
76
|
|
|
72
|
-
// Options passed to `start` will be passed-through to ember-qunit
|
|
77
|
+
// Options passed to `start` will be passed-through to ember-qunit
|
|
73
78
|
start();
|
|
74
79
|
```
|
|
75
80
|
|
|
81
|
+
## How to use with Vite
|
|
82
|
+
|
|
83
|
+
All of the above applies, but we need to tell vite to build the app before telling ember/exam to run tests on that output.
|
|
84
|
+
|
|
85
|
+
Update your test-helper.js or test-helper.ts, to have add the ember-exam `start` function:
|
|
86
|
+
```diff
|
|
87
|
+
// ...
|
|
88
|
+
import { setApplication } from '@ember/test-helpers';
|
|
89
|
+
import { setup } from 'qunit-dom';
|
|
90
|
+
- import { start as qunitStart, setupEmberOnerrorValidation } from 'ember-qunit';
|
|
91
|
+
+ import { setupEmberOnerrorValidation } from 'ember-qunit';
|
|
92
|
+
+ import { start as startEmberExam } from 'ember-exam/test-support';
|
|
93
|
+
|
|
94
|
+
export function start() {
|
|
95
|
+
setApplication(Application.create(config.APP));
|
|
96
|
+
|
|
97
|
+
setup(QUnit.assert);
|
|
98
|
+
setupEmberOnerrorValidation();
|
|
99
|
+
|
|
100
|
+
- qunitStart();
|
|
101
|
+
+ // Options passed to `start` will be passed-through to ember-qunit
|
|
102
|
+
+ startEmberExam();
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Testing development:
|
|
107
|
+
```bash
|
|
108
|
+
NODE_ENV=development vite build --mode test
|
|
109
|
+
ember exam --path dist
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Testing production:
|
|
113
|
+
```bash
|
|
114
|
+
vite build --mode test
|
|
115
|
+
ember exam --path dist
|
|
116
|
+
```
|
|
117
|
+
|
|
76
118
|
### Version < `3.0.0`
|
|
77
119
|
|
|
78
120
|
|
|
@@ -114,7 +156,7 @@ ember exam --split=2 --random
|
|
|
114
156
|
Randomizing tests with seed: hwr74nkk55vzpvi
|
|
115
157
|
```
|
|
116
158
|
|
|
117
|
-
_Note: You must be using QUnit version `1.23.0` or greater for this feature to work properly.
|
|
159
|
+
_Note: You must be using QUnit version `1.23.0` or greater for this feature to work properly.
|
|
118
160
|
|
|
119
161
|
#### Randomization Iterator
|
|
120
162
|
|
|
@@ -138,8 +180,6 @@ $ ember exam:iterate <num> --options <options>
|
|
|
138
180
|
|
|
139
181
|
The `options` should be a string matching what you would use via the CLI.
|
|
140
182
|
|
|
141
|
-
_Note: This feature is not currently supported by Mocha._
|
|
142
|
-
|
|
143
183
|
### Generating Module Metadata File For Test Execution
|
|
144
184
|
|
|
145
185
|
```bash
|
|
@@ -188,8 +228,6 @@ and it looks something like below:
|
|
|
188
228
|
]
|
|
189
229
|
```
|
|
190
230
|
|
|
191
|
-
_Note: This feature is not currently supported by Mocha._
|
|
192
|
-
|
|
193
231
|
|
|
194
232
|
### Splitting
|
|
195
233
|
|
|
@@ -209,7 +247,7 @@ The `partition` option allows you to specify which test group to run after using
|
|
|
209
247
|
$ ember exam --split=4 --partition=1 --partition=2
|
|
210
248
|
```
|
|
211
249
|
|
|
212
|
-
_Note: Ember Exam splits tests by modifying the
|
|
250
|
+
_Note: Ember Exam splits tests by modifying the ember-qunit's `TestLoader` to bucket each test file into a partition, where each partition has an even number of test files. This makes it possible to have unbalanced partitions. To run your tests with balanced partitions, consider using `--load-balance`. For more info, see [_Test Load Balancing_](#test-load-balancing).
|
|
213
251
|
|
|
214
252
|
#### Split Test Parallelization
|
|
215
253
|
|
|
@@ -281,7 +319,7 @@ $ ember exam --file-path='/my-application/tests/unit/*.js'
|
|
|
281
319
|
$ ember exam --parallel=<num> --load-balance
|
|
282
320
|
```
|
|
283
321
|
|
|
284
|
-
The `load-balance` option allows you to load balance test files against multiple browsers. It will order the test files by test types, e.g. acceptance | integration | unit
|
|
322
|
+
The `load-balance` option allows you to load balance test files against multiple browsers. It will order the test files by test types, e.g. acceptance | integration | unit, and load balance the ordered test files between the browsers dynamically rather than statically.
|
|
285
323
|
**Note:** parallel must be used along with load-balance to specify a number of browser(s)
|
|
286
324
|
|
|
287
325
|
The `load-balance` option was added to version 1.1 to address execution performance when running against a large test suite.
|
|
@@ -318,7 +356,6 @@ ok 3 Chrome 66.0 - Exam Partition 1 - browser Id 3 - some the other test
|
|
|
318
356
|
2. You must be using `ember-cli` version 3.2.0 or greater for load balancing and test failure reproduction features to work properly.
|
|
319
357
|
3. You must be using `ember-qunit` version 4.1.1 or greater for this feature to work properly.
|
|
320
358
|
4. You must be using `qunit` version 2.13.0 or greater for this feature to work properly.
|
|
321
|
-
5. This feature is not currently supported by Mocha.
|
|
322
359
|
|
|
323
360
|
##### Test Failure Reproduction
|
|
324
361
|
|
|
@@ -373,7 +410,33 @@ $ ember exam --replay-execution=test-execution-000000.json
|
|
|
373
410
|
1. You must be using `ember-cli` version 3.2.0 or greater for load-balnce and test failure reproduction features to work properly.
|
|
374
411
|
2. You must be using `ember-qunit` version 4.1.1 or greater for this feature to work properly.
|
|
375
412
|
3. You must be using `qunit` version 2.8.0 or greater for this feature to work properly.
|
|
376
|
-
|
|
413
|
+
|
|
414
|
+
#### Preserve Test Name
|
|
415
|
+
|
|
416
|
+
When using `--split` and/or `--load-balance` the output will look something like:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
# ember exam --split=2 --partition=1 --parallel=3 --load-balance
|
|
420
|
+
ok 1 Chrome 66.0 - Exam Partition 1 - browser Id 1 - some test
|
|
421
|
+
ok 2 Chrome 66.0 - Exam Partition 1 - browser Id 2 - another test
|
|
422
|
+
ok 3 Chrome 66.0 - Exam Partition 1 - browser Id 3 - some the other test
|
|
423
|
+
```
|
|
424
|
+
However, if you change the amount of parallelization, or randomize across partitions, the output will change for the same test, which may be an issue if you are tracking test insights over time.
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
# ember exam --split=2 --partition=1 --parallel=2 --load-balance
|
|
428
|
+
ok 1 Chrome 66.0 - Exam Partition 1 - browser Id 2 - some test
|
|
429
|
+
ok 2 Chrome 66.0 - Exam Partition 1 - browser Id 1 - another test
|
|
430
|
+
ok 3 Chrome 66.0 - Exam Partition 1 - browser Id 2 - some the other test
|
|
431
|
+
```
|
|
432
|
+
You can add `--preserve-test-name` to remove the dynamic segments of the output (partition and browser) to ensure the output test names are always the same.
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
# ember exam --split=2 --partition=1 --parallel=3 --load-balance --preserve-test-name
|
|
436
|
+
ok 1 Chrome 66.0 - some test
|
|
437
|
+
ok 2 Chrome 66.0 - another test
|
|
438
|
+
ok 3 Chrome 66.0 - some the other test
|
|
439
|
+
```
|
|
377
440
|
|
|
378
441
|
## Advanced Configuration
|
|
379
442
|
|
|
@@ -51,7 +51,7 @@ export default class AsyncIterator {
|
|
|
51
51
|
handleResponse(response) {
|
|
52
52
|
if (this._waiting === false) {
|
|
53
53
|
throw new Error(
|
|
54
|
-
`${this.toString()} Was not expecting a response, but got a response
|
|
54
|
+
`${this.toString()} Was not expecting a response, but got a response`,
|
|
55
55
|
);
|
|
56
56
|
} else {
|
|
57
57
|
this._waiting = false;
|
|
@@ -82,7 +82,7 @@ export default class AsyncIterator {
|
|
|
82
82
|
this._done = true;
|
|
83
83
|
this._testem.removeEventCallbacks(
|
|
84
84
|
this._response,
|
|
85
|
-
this._boundHandleResponse
|
|
85
|
+
this._boundHandleResponse,
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -111,13 +111,13 @@ export default class AsyncIterator {
|
|
|
111
111
|
|
|
112
112
|
if (this._emberExamExitOnError) {
|
|
113
113
|
let err = new Error(
|
|
114
|
-
`EmberExam: Promise timed out after ${this._timeout} s while waiting for response for ${this._request}
|
|
114
|
+
`EmberExam: Promise timed out after ${this._timeout} s while waiting for response for ${this._request}`,
|
|
115
115
|
);
|
|
116
116
|
reject(err);
|
|
117
117
|
} else {
|
|
118
118
|
// eslint-disable-next-line no-console
|
|
119
119
|
console.error(
|
|
120
|
-
`EmberExam: Promise timed out after ${this._timeout} s while waiting for response for ${this._request}. Closing browser to exit gracefully
|
|
120
|
+
`EmberExam: Promise timed out after ${this._timeout} s while waiting for response for ${this._request}. Closing browser to exit gracefully.`,
|
|
121
121
|
);
|
|
122
122
|
resolve(iteratorCompleteResponse);
|
|
123
123
|
}
|
package/addon-test-support/-private/{ember-exam-qunit-test-loader.js → ember-exam-test-loader.js}
RENAMED
|
@@ -13,7 +13,7 @@ import QUnit from 'qunit';
|
|
|
13
13
|
* @class EmberExamQUnitTestLoader
|
|
14
14
|
* @extends {TestLoader}
|
|
15
15
|
*/
|
|
16
|
-
export default class
|
|
16
|
+
export default class EmberExamTestLoader extends TestLoader {
|
|
17
17
|
constructor(testem, urlParams, qunit = QUnit) {
|
|
18
18
|
super();
|
|
19
19
|
this._testModules = [];
|
|
@@ -82,7 +82,7 @@ export default class EmberExamQUnitTestLoader extends TestLoader {
|
|
|
82
82
|
this._testModules = filterTestModules(
|
|
83
83
|
this._testModules,
|
|
84
84
|
modulePath,
|
|
85
|
-
filePath
|
|
85
|
+
filePath,
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -91,18 +91,18 @@ export default class EmberExamQUnitTestLoader extends TestLoader {
|
|
|
91
91
|
this._testModules = splitTestModules(
|
|
92
92
|
weightTestModules(this._testModules),
|
|
93
93
|
split,
|
|
94
|
-
partitions
|
|
94
|
+
partitions,
|
|
95
95
|
);
|
|
96
96
|
this._testem.emit(
|
|
97
97
|
'testem:set-modules-queue',
|
|
98
98
|
this._testModules,
|
|
99
|
-
browserId
|
|
99
|
+
browserId,
|
|
100
100
|
);
|
|
101
101
|
} else {
|
|
102
102
|
this._testModules = splitTestModules(
|
|
103
103
|
this._testModules,
|
|
104
104
|
split,
|
|
105
|
-
partitions
|
|
105
|
+
partitions,
|
|
106
106
|
);
|
|
107
107
|
this._testModules.forEach((moduleName) => {
|
|
108
108
|
super.require(moduleName);
|
|
@@ -120,7 +120,7 @@ export default class EmberExamQUnitTestLoader extends TestLoader {
|
|
|
120
120
|
loadIndividualModule(moduleName) {
|
|
121
121
|
if (moduleName === undefined) {
|
|
122
122
|
throw new Error(
|
|
123
|
-
'Failed to load a test module. `moduleName` is undefined in `loadIndividualModule`.'
|
|
123
|
+
'Failed to load a test module. `moduleName` is undefined in `loadIndividualModule`.',
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
super.require(moduleName);
|
|
@@ -41,7 +41,7 @@ function wildcardFilter(module, moduleFilter) {
|
|
|
41
41
|
function stringFilter(modules, moduleFilter) {
|
|
42
42
|
return modules.filter(
|
|
43
43
|
(module) =>
|
|
44
|
-
module.includes(moduleFilter) || wildcardFilter(module, moduleFilter)
|
|
44
|
+
module.includes(moduleFilter) || wildcardFilter(module, moduleFilter),
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -57,7 +57,7 @@ function regexFilter(modules, modulePathRegexFilter) {
|
|
|
57
57
|
const exclude = modulePathRegexFilter[1];
|
|
58
58
|
|
|
59
59
|
return modules.filter(
|
|
60
|
-
(module) => (!exclude && re.test(module)) || (exclude && !re.test(module))
|
|
60
|
+
(module) => (!exclude && re.test(module)) || (exclude && !re.test(module)),
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -98,21 +98,21 @@ function filterTestModules(modules, modulePath, filePath) {
|
|
|
98
98
|
if (modulePathRegex) {
|
|
99
99
|
return result.concat(
|
|
100
100
|
regexFilter(modules, modulePathRegex).filter(
|
|
101
|
-
(module) => result.indexOf(module) === -1
|
|
102
|
-
)
|
|
101
|
+
(module) => result.indexOf(module) === -1,
|
|
102
|
+
),
|
|
103
103
|
);
|
|
104
104
|
} else {
|
|
105
105
|
return result.concat(
|
|
106
106
|
stringFilter(modules, modulePath).filter(
|
|
107
|
-
(module) => result.indexOf(module) === -1
|
|
108
|
-
)
|
|
107
|
+
(module) => result.indexOf(module) === -1,
|
|
108
|
+
),
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
}, []);
|
|
112
112
|
|
|
113
113
|
if (filteredTestModules.length === 0) {
|
|
114
114
|
throw new Error(
|
|
115
|
-
`No tests matched with the filter: ${modulePath || filePath}
|
|
115
|
+
`No tests matched with the filter: ${modulePath || filePath}.`,
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
return filteredTestModules;
|
|
@@ -15,7 +15,11 @@ export function updateTestName(urlParams, testName) {
|
|
|
15
15
|
const partition = urlParams.get('partition') || 1;
|
|
16
16
|
const browser = urlParams.get('browser') || 1;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const preserveTestName = !!urlParams.get('preserveTestName');
|
|
19
|
+
|
|
20
|
+
if (preserveTestName) {
|
|
21
|
+
return testName;
|
|
22
|
+
} else if (split && loadBalance) {
|
|
19
23
|
testName = `Exam Partition ${partition} - Browser Id ${browser} - ${testName}`;
|
|
20
24
|
} else if (split) {
|
|
21
25
|
testName = `Exam Partition ${partition} - ${testName}`;
|
|
@@ -8,25 +8,16 @@ function createGroups(num) {
|
|
|
8
8
|
return groups;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
const filtered = arr.filter(filter);
|
|
11
|
+
function splitIntoGroups(arr, numGroups) {
|
|
13
12
|
const groups = createGroups(numGroups);
|
|
14
13
|
|
|
15
|
-
for (let i = 0; i <
|
|
16
|
-
groups[i % numGroups].push(
|
|
14
|
+
for (let i = 0; i < arr.length; i++) {
|
|
15
|
+
groups[i % numGroups].push(arr[i]);
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
return groups;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
function isLintTest(name) {
|
|
23
|
-
return name.match(/\.(jshint|(es)?lint-test)$/);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function isNotLintTest(name) {
|
|
27
|
-
return !isLintTest(name);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
21
|
/**
|
|
31
22
|
* Splits the list of modules into unique subset of modules
|
|
32
23
|
* return the subset indexed by the partition
|
|
@@ -43,8 +34,7 @@ export default function splitTestModules(modules, split, partitions) {
|
|
|
43
34
|
throw new Error('You must specify a split greater than 0');
|
|
44
35
|
}
|
|
45
36
|
|
|
46
|
-
const
|
|
47
|
-
const otherTestGroups = filterIntoGroups(modules, isNotLintTest, split);
|
|
37
|
+
const testGroups = splitIntoGroups(modules, split);
|
|
48
38
|
const tests = [];
|
|
49
39
|
|
|
50
40
|
for (let i = 0; i < partitions.length; i++) {
|
|
@@ -53,21 +43,21 @@ export default function splitTestModules(modules, split, partitions) {
|
|
|
53
43
|
throw new Error(
|
|
54
44
|
"You must specify numbers for partition (you specified '" +
|
|
55
45
|
partitions +
|
|
56
|
-
"')"
|
|
46
|
+
"')",
|
|
57
47
|
);
|
|
58
48
|
}
|
|
59
49
|
|
|
60
50
|
if (split < partition) {
|
|
61
51
|
throw new Error(
|
|
62
52
|
'You must specify partitions numbered less than or equal to your split value of ' +
|
|
63
|
-
split
|
|
53
|
+
split,
|
|
64
54
|
);
|
|
65
55
|
} else if (partition < 1) {
|
|
66
56
|
throw new Error('You must specify partitions numbered greater than 0');
|
|
67
57
|
}
|
|
68
58
|
|
|
69
59
|
const group = partition - 1;
|
|
70
|
-
tests.push(...
|
|
60
|
+
tests.push(...testGroups[group]);
|
|
71
61
|
}
|
|
72
62
|
|
|
73
63
|
return tests;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
const TEST_TYPE_WEIGHT = {
|
|
2
|
-
eslint: 1,
|
|
3
2
|
unit: 10,
|
|
4
3
|
integration: 20,
|
|
5
4
|
acceptance: 150,
|
|
6
5
|
};
|
|
7
|
-
const WEIGHT_REGEX = /\/(
|
|
6
|
+
const WEIGHT_REGEX = /\/(unit|integration|acceptance)\//;
|
|
8
7
|
const DEFAULT_WEIGHT = 50;
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Return the weight for a given module name, a file path to the module
|
|
12
|
-
* Ember tests consist of Acceptance, Integration,
|
|
11
|
+
* Ember tests consist of Acceptance, Integration, and Unit tests. In general, acceptance takes
|
|
13
12
|
* longest time to execute, followed by integration and unit.
|
|
14
13
|
* The weight assigned to a module corresponds to its test type execution speed, with slowest being the highest in weight.
|
|
15
14
|
* If the test type is not identifiable from the modulePath, weight default to 50 (ordered after acceptance, but before integration)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as start } from './start';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import EmberExamTestLoader from './-private/ember-exam-test-loader';
|
|
1
2
|
import { patchTestemOutput } from './-private/patch-testem-output';
|
|
2
|
-
import getTestLoader from './-private/get-test-loader';
|
|
3
3
|
|
|
4
4
|
let loaded = false;
|
|
5
5
|
|
|
@@ -17,7 +17,7 @@ export default function loadEmberExam() {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
loaded = true;
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
const testLoader = new EmberExamTestLoader(window.Testem);
|
|
22
22
|
|
|
23
23
|
if (window.Testem) {
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import loadEmberExam from 'ember-exam/test-support/load';
|
|
2
|
-
import {
|
|
3
|
-
dependencySatisfies,
|
|
4
|
-
macroCondition,
|
|
5
|
-
importSync,
|
|
6
|
-
} from '@embroider/macros';
|
|
2
|
+
import { start as qunitStart } from 'ember-qunit';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
|
-
* Equivalent to ember-qunit
|
|
5
|
+
* Equivalent to ember-qunit's loadTest() except this does not create a new TestLoader instance
|
|
10
6
|
*
|
|
11
7
|
* @function loadTests
|
|
12
8
|
* @param {*} testLoader
|
|
@@ -14,7 +10,7 @@ import {
|
|
|
14
10
|
function loadTests(testLoader) {
|
|
15
11
|
if (testLoader === undefined) {
|
|
16
12
|
throw new Error(
|
|
17
|
-
'A testLoader instance has not been created. You must call `loadEmberExam()` before calling `loadTest()`.'
|
|
13
|
+
'A testLoader instance has not been created. You must call `loadEmberExam()` before calling `loadTest()`.',
|
|
18
14
|
);
|
|
19
15
|
}
|
|
20
16
|
|
|
@@ -23,7 +19,7 @@ function loadTests(testLoader) {
|
|
|
23
19
|
|
|
24
20
|
/**
|
|
25
21
|
* Ember-exam's own start function to set up EmberExamTestLoader, load tests and calls start() from
|
|
26
|
-
* ember-qunit
|
|
22
|
+
* ember-qunit
|
|
27
23
|
*
|
|
28
24
|
* @function start
|
|
29
25
|
* @param {*} qunitOptions
|
|
@@ -34,15 +30,5 @@ export default function start(qunitOptions) {
|
|
|
34
30
|
|
|
35
31
|
const testLoader = loadEmberExam();
|
|
36
32
|
loadTests(testLoader);
|
|
37
|
-
|
|
38
|
-
let emberTestFramework;
|
|
39
|
-
if (macroCondition(dependencySatisfies('ember-qunit', '*'))) {
|
|
40
|
-
emberTestFramework = importSync('ember-qunit');
|
|
41
|
-
} else if (macroCondition(dependencySatisfies('ember-mocha', '*'))) {
|
|
42
|
-
emberTestFramework = importSync('ember-mocha');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (emberTestFramework.start) {
|
|
46
|
-
emberTestFramework.start(modifiedOptions);
|
|
47
|
-
}
|
|
33
|
+
qunitStart(modifiedOptions);
|
|
48
34
|
}
|
package/index.js
CHANGED
|
@@ -2,41 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
const VersionChecker = require('ember-cli-version-checker');
|
|
6
|
-
|
|
7
5
|
module.exports = {
|
|
8
6
|
name: require('./package').name,
|
|
9
7
|
|
|
10
8
|
includedCommands() {
|
|
11
9
|
return require('./lib/commands');
|
|
12
10
|
},
|
|
13
|
-
|
|
14
|
-
init() {
|
|
15
|
-
this._super.init.apply(this, arguments);
|
|
16
|
-
let versionChecker = new VersionChecker(this.project);
|
|
17
|
-
|
|
18
|
-
const hasMagicallyProvidedQUnit = versionChecker
|
|
19
|
-
.for('ember-qunit')
|
|
20
|
-
.lt('5.0.0-beta.1');
|
|
21
|
-
|
|
22
|
-
let options = {
|
|
23
|
-
exclude: ['ember-mocha', 'mocha'],
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// Ember-qunit < 5 provides an AMD shim for qunit but newer versions now use
|
|
27
|
-
// ember-auto-import to include qunit. This means that qunit is no
|
|
28
|
-
// longer available for addons (if the parent app is using ember-qunit > 5) to
|
|
29
|
-
// directly import under embroider unless they are using ember-auto-import
|
|
30
|
-
// themselves. This condidionally falls back to not using ember-auto-import
|
|
31
|
-
// when the parent app is providing qunit because without this we would double
|
|
32
|
-
// include qunit resulting in a runtime error (qunit detects if it as
|
|
33
|
-
// already be added to the window object and errors if so).
|
|
34
|
-
if (hasMagicallyProvidedQUnit) {
|
|
35
|
-
this.options = this.options || {};
|
|
36
|
-
options.exclude.push('qunit');
|
|
37
|
-
this.options.autoImport = options;
|
|
38
|
-
} else {
|
|
39
|
-
this.options.autoImport = options;
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
11
|
};
|