ember-testem 0.5.3 → 0.7.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/README.md CHANGED
@@ -5,20 +5,24 @@ _Backward- and forward-compatible testing for Ember projects_
5
5
 
6
6
  ## Why?
7
7
 
8
- Until now, testing Ember apps and addons required `ember-cli`, a monolith package that is written in JavaScript and has little relevance in v2 apps and v2 addons. Ember's test ecosystem (e.g. `ember-exam`, `@percy/ember`) is at risk because it is built on `ember-cli`.
8
+ Until now, testing Ember apps and addons required `ember-cli`, a monolith package that is written in JavaScript and has less relevance in v2 apps and v2 addons. Production projects may be at risk because tools like `ember-exam` and `@percy/ember` are built on `ember-cli`.
9
9
 
10
10
  `ember-testem` aims to show that:
11
11
 
12
12
  - The fix is minimal, backward-, and forward-compatible (apps with strict resolver, apps without `ember-cli`).
13
13
  - We can keep using `qunit` and `testem`. No need to switch to another test framework and rewrite tests.
14
- - We can keep using battle-tested packages like `@embroider/try`, `@percy/ember`, `ember-a11y-testing`, `ember-qunit`, `ember-test-selectors`, `miragejs`, and `qunit-dom`.
14
+ - It works with battle-tested packages like `@embroider/try`, `@percy/ember`, `ember-a11y-testing`, `ember-qunit`, `ember-test-selectors`, `miragejs`, and `qunit-dom`.
15
15
 
16
16
 
17
17
  ## Quickstart
18
18
 
19
19
  > [!TIP]
20
20
  >
21
- > From the root of your Ember app or addon, run `pnpx install-ember-testem` to automate the setup.
21
+ > From the root of your Ember app or addon, run `install-ember-testem` to set up `ember-testem`.
22
+ >
23
+ > ```sh
24
+ > pnpx install-ember-testem
25
+ > ```
22
26
 
23
27
  1\. Install `ember-testem` as a development dependency. The package provides an executable named `ember-test`.
24
28
 
@@ -118,9 +122,11 @@ See [my-v1-app](../../tests/my-v1-app) for an example.
118
122
 
119
123
  <summary>V2 addons</summary>
120
124
 
125
+ See [my-v2-addon](../../tests/my-v2-addon) for an example.
126
+
121
127
  In general, I recommend creating a test app as a separate package (using workspaces). This way, you can separate dependencies for source code and testing (avoid past issues with v1 addons). You would set up `ember-testem` by following the steps for v2 apps.
122
128
 
123
- If you still want to create the test app in the same package, you will need to install and configure additional dependencies. See [my-v2-addon](../../tests/my-v2-addon) for an example.
129
+ If you still want to create the test app in the same package, you will need to install and configure additional dependencies. You can use `install-ember-testem` to get started.
124
130
 
125
131
  ```json
126
132
  {
@@ -131,13 +137,6 @@ If you still want to create the test app in the same package, you will need to i
131
137
  }
132
138
  ```
133
139
 
134
- Files that need changes:
135
-
136
- - Babel (`babel.test.config.mjs`)
137
- - Dependencies (`package.json`)
138
- - TypeScript (`tsconfig.json`, `tsconfig.build.json`)
139
- - Vite (`vite.test.config.mts`)
140
-
141
140
  </details>
142
141
 
143
142
  <details>
@@ -228,7 +227,7 @@ ember-test --path dist-for-testing
228
227
 
229
228
  By default, `ember-testem` runs tests on port `7357`.
230
229
 
231
- Pass `--port` (or `--test-port`, currently supported for backward compatibility) to pick a different port. You can pass `0` to pick any available port (useful for testing multiple projects in parallel).
230
+ Pass `--port` to pick a different port. You can pass `0` to pick any available port (useful for testing multiple projects in parallel).
232
231
 
233
232
  ```sh
234
233
  ember-test --port 0
@@ -263,7 +262,7 @@ ember-test --random gflqlwrm59j
263
262
 
264
263
  ## Compatibility
265
264
 
266
- - Node.js v22.17 or above
265
+ - Node.js v22 or above
267
266
 
268
267
 
269
268
  ## Contributing
@@ -39,15 +39,10 @@ const argv = yargs(hideBin(process.argv))
39
39
  describe: 'Launch test browser',
40
40
  type: 'boolean',
41
41
  })
42
- .option('test-port', {
43
- describe: 'Port for running tests. Pass 0 to automatically pick an available port.',
44
- type: 'number',
45
- })
46
- .deprecateOption('test-port', 'Use --port instead.')
47
42
  .parseSync();
48
43
  const codemodOptions = {
49
44
  buildPath: argv['path'],
50
- port: argv['test-port'] ?? argv['port'],
45
+ port: argv['port'],
51
46
  projectRoot: argv['root'] ?? process.cwd(),
52
47
  qunit: {
53
48
  filter: argv['filter'],
@@ -3,12 +3,12 @@ import Testem from 'testem';
3
3
  import { getQueryParams } from '../../utils/run-tests/get-query-params.js';
4
4
  export async function runTestsInCI(options) {
5
5
  const { buildPath, port, projectRoot } = options;
6
- const testemInstance = new Testem();
6
+ const testem = new Testem();
7
7
  const startOptions = {
8
8
  launch: false,
9
9
  port,
10
10
  };
11
- testemInstance.setDefaultOptions({
11
+ testem.setDefaultOptions({
12
12
  ...startOptions,
13
13
  config_dir: projectRoot,
14
14
  cwd: join(projectRoot, buildPath),
@@ -16,7 +16,7 @@ export async function runTestsInCI(options) {
16
16
  query_params: getQueryParams(options),
17
17
  });
18
18
  return new Promise((resolve, reject) => {
19
- testemInstance.startCI(startOptions, (exitCode, error) => {
19
+ testem.startCI(startOptions, (exitCode, error) => {
20
20
  if (error) {
21
21
  reject(error);
22
22
  }
@@ -1,34 +1,34 @@
1
1
  import { join } from 'node:path';
2
- import { watch } from 'chokidar';
2
+ import chokidar from 'chokidar';
3
3
  import Testem from 'testem';
4
4
  import { getQueryParams } from '../../utils/run-tests/get-query-params.js';
5
5
  export async function runTestsInDev(options) {
6
6
  const { buildPath, port, projectRoot } = options;
7
- const testemInstance = new Testem();
7
+ const testem = new Testem();
8
8
  const startOptions = {
9
9
  launch: false,
10
10
  port,
11
11
  };
12
- testemInstance.setDefaultOptions({
12
+ testem.setDefaultOptions({
13
13
  ...startOptions,
14
14
  config_dir: projectRoot,
15
15
  cwd: join(projectRoot, buildPath),
16
16
  query_params: getQueryParams(options),
17
17
  });
18
- const watcher = watch([buildPath], {
18
+ const watcher = chokidar.watch([buildPath], {
19
19
  awaitWriteFinish: true,
20
20
  backend: 'polling',
21
21
  });
22
22
  watcher.on('change', () => {
23
- testemInstance.restart();
23
+ testem.restart();
24
24
  });
25
25
  return new Promise((resolve, reject) => {
26
- testemInstance.startDev(startOptions, (exitCode, error) => {
26
+ testem.startDev(startOptions, (exitCode, error) => {
27
27
  if (error) {
28
28
  reject(error);
29
29
  }
30
30
  else if (exitCode !== 0) {
31
- reject(new Error(`testem finished with a non-zero exit code (${exitCode})`));
31
+ reject(new Error(`testem finished with the non-zero exit code ${exitCode}`));
32
32
  }
33
33
  else {
34
34
  resolve();
@@ -1,10 +1,16 @@
1
+ function generateSeed() {
2
+ return Math.random().toString(36).slice(2);
3
+ }
1
4
  export function createSeed(seed) {
2
5
  switch (seed) {
3
6
  case undefined: {
4
7
  return undefined;
5
8
  }
6
9
  case '': {
7
- const seedNew = Math.random().toString(36).slice(2);
10
+ let seedNew = generateSeed();
11
+ while (seedNew === '') {
12
+ seedNew = generateSeed();
13
+ }
8
14
  console.log(`Randomizing tests with seed: ${seedNew}`);
9
15
  return seedNew;
10
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-testem",
3
- "version": "0.5.3",
3
+ "version": "0.7.0",
4
4
  "description": "Backward- and forward-compatible testing for Ember projects",
5
5
  "keywords": [
6
6
  "ci",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "chokidar": "^6.0.0",
29
- "testem": "^4.0.0-beta.1",
29
+ "testem": "^4.0.0-beta.3",
30
30
  "yargs": "^18.2.0"
31
31
  },
32
32
  "devDependencies": {
@@ -35,14 +35,16 @@
35
35
  "@shared-configs/prettier": "0.0.0",
36
36
  "@shared-configs/typescript": "0.0.0",
37
37
  "@types/node": "^22.20.5",
38
+ "@types/sinon": "^22.0.2",
38
39
  "@types/yargs": "^17.0.35",
39
40
  "concurrently": "^10.0.6",
40
41
  "eslint": "^10.13.0",
41
42
  "prettier": "^3.9.10",
43
+ "sinon": "^22.1.0",
42
44
  "typescript": "^6.0.3"
43
45
  },
44
46
  "engines": {
45
- "node": "^22.17.0 || >= 24"
47
+ "node": "22.* || >= 24"
46
48
  },
47
49
  "scripts": {
48
50
  "build": "sh build.sh --production",