ember-testem 0.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/LICENSE.md +9 -0
- package/README.md +18 -0
- package/dist/bin/ember-test.js +34 -0
- package/dist/src/run.js +5 -0
- package/dist/src/steps/create-options.js +9 -0
- package/dist/src/steps/index.js +2 -0
- package/dist/src/steps/run-tests/run-tests-in-ci.js +29 -0
- package/dist/src/steps/run-tests/run-tests-in-dev.js +36 -0
- package/dist/src/steps/run-tests.js +15 -0
- package/dist/src/types/index.js +1 -0
- package/package.json +56 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Isaac J. Lee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# ember-testem
|
|
2
|
+
|
|
3
|
+
_Forward- and backward-compatible testing for Ember projects_
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Compatibility
|
|
7
|
+
|
|
8
|
+
- Node.js v22 or above
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Contributing
|
|
12
|
+
|
|
13
|
+
See the [Contributing](../../CONTRIBUTING.md) guide for details.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
|
|
18
|
+
This project is licensed under the [MIT License](./LICENSE.md).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
import yargs from 'yargs';
|
|
4
|
+
import { hideBin } from 'yargs/helpers';
|
|
5
|
+
import { run } from '../src/run.js';
|
|
6
|
+
// Provide a title to the process in `ps`
|
|
7
|
+
process.title = 'ember-test';
|
|
8
|
+
// Set codemod options
|
|
9
|
+
const argv = yargs(hideBin(process.argv))
|
|
10
|
+
.option('path', {
|
|
11
|
+
describe: 'Relative path to the test build',
|
|
12
|
+
type: 'string',
|
|
13
|
+
})
|
|
14
|
+
.option('root', {
|
|
15
|
+
describe: 'Where to run the codemod',
|
|
16
|
+
type: 'string',
|
|
17
|
+
})
|
|
18
|
+
.option('server', {
|
|
19
|
+
alias: 's',
|
|
20
|
+
describe: 'Launch test browser',
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
})
|
|
23
|
+
.option('test-port', {
|
|
24
|
+
describe: 'Port for running tests. Pass 0 to automatically pick an available port.',
|
|
25
|
+
type: 'number',
|
|
26
|
+
})
|
|
27
|
+
.parseSync();
|
|
28
|
+
const codemodOptions = {
|
|
29
|
+
buildPath: argv['path'] ?? 'dist',
|
|
30
|
+
projectRoot: argv['root'] ?? process.cwd(),
|
|
31
|
+
server: argv['server'],
|
|
32
|
+
testPort: argv['test-port'],
|
|
33
|
+
};
|
|
34
|
+
void run(codemodOptions);
|
package/dist/src/run.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import Testem from 'testem';
|
|
3
|
+
export async function runTestsInCI(options) {
|
|
4
|
+
const { buildPath, projectRoot, testPort } = options;
|
|
5
|
+
const testemInstance = new Testem();
|
|
6
|
+
const startOptions = {
|
|
7
|
+
launch: false,
|
|
8
|
+
port: testPort,
|
|
9
|
+
};
|
|
10
|
+
testemInstance.setDefaultOptions({
|
|
11
|
+
...startOptions,
|
|
12
|
+
config_dir: projectRoot,
|
|
13
|
+
cwd: join(projectRoot, buildPath),
|
|
14
|
+
parallel: 1,
|
|
15
|
+
});
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
testemInstance.startCI(startOptions, (exitCode, error) => {
|
|
18
|
+
if (error) {
|
|
19
|
+
reject(error);
|
|
20
|
+
}
|
|
21
|
+
else if (exitCode !== 0) {
|
|
22
|
+
reject(new Error(`testem finished with the non-zero exit code ${exitCode}`));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
resolve();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { watch } from 'chokidar';
|
|
3
|
+
import Testem from 'testem';
|
|
4
|
+
export async function runTestsInDev(options) {
|
|
5
|
+
const { buildPath, projectRoot, testPort } = options;
|
|
6
|
+
const testemInstance = new Testem();
|
|
7
|
+
const startOptions = {
|
|
8
|
+
launch: false,
|
|
9
|
+
port: testPort,
|
|
10
|
+
};
|
|
11
|
+
testemInstance.setDefaultOptions({
|
|
12
|
+
...startOptions,
|
|
13
|
+
config_dir: projectRoot,
|
|
14
|
+
cwd: join(projectRoot, buildPath),
|
|
15
|
+
});
|
|
16
|
+
const watcher = watch([buildPath], {
|
|
17
|
+
awaitWriteFinish: true,
|
|
18
|
+
usePolling: true,
|
|
19
|
+
});
|
|
20
|
+
watcher.on('change', () => {
|
|
21
|
+
testemInstance.restart();
|
|
22
|
+
});
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
testemInstance.startDev(startOptions, (exitCode, error) => {
|
|
25
|
+
if (error) {
|
|
26
|
+
reject(error);
|
|
27
|
+
}
|
|
28
|
+
else if (exitCode !== 0) {
|
|
29
|
+
reject(new Error(`testem finished with a non-zero exit code (${exitCode})`));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
resolve();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { runTestsInCI } from './run-tests/run-tests-in-ci.js';
|
|
2
|
+
import { runTestsInDev } from './run-tests/run-tests-in-dev.js';
|
|
3
|
+
export async function runTests(options) {
|
|
4
|
+
try {
|
|
5
|
+
if (options.launchBrowser) {
|
|
6
|
+
await runTestsInDev(options);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
await runTestsInCI(options);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.error(error.message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ember-testem",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"codemod",
|
|
7
|
+
"ember-codemod",
|
|
8
|
+
"emberjs"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/ijlee2/ember-test.git"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Isaac J. Lee",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/src/run.js",
|
|
18
|
+
"bin": {
|
|
19
|
+
"ember-test": "dist/bin/ember-test.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"chokidar": "^5.0.0",
|
|
26
|
+
"testem": "^3.21.0",
|
|
27
|
+
"yargs": "^18.2.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@codemod-utils/tests": "^3.3.0",
|
|
31
|
+
"@shared-configs/eslint-config-node": "0.0.0",
|
|
32
|
+
"@shared-configs/prettier": "0.0.0",
|
|
33
|
+
"@shared-configs/typescript": "0.0.0",
|
|
34
|
+
"@types/node": "^22.20.4",
|
|
35
|
+
"@types/yargs": "^17.0.35",
|
|
36
|
+
"concurrently": "^10.0.5",
|
|
37
|
+
"eslint": "^10.11.0",
|
|
38
|
+
"prettier": "^3.9.9",
|
|
39
|
+
"typescript": "^6.0.3"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": "22.* || >= 24"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "sh build.sh --production",
|
|
46
|
+
"format": "prettier . --cache --write",
|
|
47
|
+
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"",
|
|
48
|
+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" && pnpm format",
|
|
49
|
+
"lint:format": "prettier . --cache --check",
|
|
50
|
+
"lint:js": "eslint . --cache",
|
|
51
|
+
"lint:js:fix": "eslint . --fix",
|
|
52
|
+
"lint:types": "tsc --noEmit",
|
|
53
|
+
"test": "sh build.sh --test && mt dist-for-testing --quiet",
|
|
54
|
+
"update-test-fixtures": "./update-test-fixtures.sh"
|
|
55
|
+
}
|
|
56
|
+
}
|