twd-cli 1.0.1 → 1.0.2
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/CHANGELOG.md +28 -0
- package/bin/twd-cli.js +2 -2
- package/package.json +9 -2
- package/src/index.js +20 -5
- package/test-example-app/README.md +75 -0
- package/test-example-app/eslint.config.js +23 -0
- package/test-example-app/index.html +13 -0
- package/test-example-app/package-lock.json +3679 -0
- package/test-example-app/package.json +32 -0
- package/test-example-app/public/vite.svg +1 -0
- package/test-example-app/src/App.css +42 -0
- package/test-example-app/src/App.tsx +35 -0
- package/test-example-app/src/App.twd.test.ts +45 -0
- package/test-example-app/src/assets/react.svg +1 -0
- package/test-example-app/src/index.css +68 -0
- package/test-example-app/src/main.tsx +19 -0
- package/test-example-app/tsconfig.app.json +28 -0
- package/test-example-app/tsconfig.json +7 -0
- package/test-example-app/tsconfig.node.json +26 -0
- package/test-example-app/vite.config.ts +13 -0
- package/tests/config.test.js +122 -0
- package/tests/runTests.test.js +8 -0
- package/vitest.config.js +26 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
## <small>1.0.2 (2025-11-24)</small>
|
|
2
|
+
|
|
3
|
+
* feat: add basic cli feature ([23bde8c](https://github.com/BRIKEV/twd-cli/commit/23bde8c))
|
|
4
|
+
* feat: add basic testing for library contributing ([a041280](https://github.com/BRIKEV/twd-cli/commit/a041280))
|
|
5
|
+
* feat: add basic unit testing ([b0dba77](https://github.com/BRIKEV/twd-cli/commit/b0dba77))
|
|
6
|
+
* feat: add dependencies and package json ([bb3500f](https://github.com/BRIKEV/twd-cli/commit/bb3500f))
|
|
7
|
+
* feat: add example app ([011cd68](https://github.com/BRIKEV/twd-cli/commit/011cd68))
|
|
8
|
+
* feat: add example app with twd tests ([eb1130d](https://github.com/BRIKEV/twd-cli/commit/eb1130d))
|
|
9
|
+
* feat: remove ci workflow ([9b902f7](https://github.com/BRIKEV/twd-cli/commit/9b902f7))
|
|
10
|
+
* feat: restore previous command ([17afe99](https://github.com/BRIKEV/twd-cli/commit/17afe99))
|
|
11
|
+
* fix: deploy script ([2e14fed](https://github.com/BRIKEV/twd-cli/commit/2e14fed))
|
|
12
|
+
* fix: remove config variable ([0f4af94](https://github.com/BRIKEV/twd-cli/commit/0f4af94))
|
|
13
|
+
* fix: script process handling ([d5fb894](https://github.com/BRIKEV/twd-cli/commit/d5fb894))
|
|
14
|
+
|
|
15
|
+
## <small>1.0.1 (2025-11-24)</small>
|
|
16
|
+
|
|
17
|
+
* chore: update version to v1.0.1 ([038a51c](https://github.com/BRIKEV/twd-cli/commit/038a51c))
|
|
18
|
+
* fix: deploy script ([2e14fed](https://github.com/BRIKEV/twd-cli/commit/2e14fed))
|
|
19
|
+
* fix: remove config variable ([0f4af94](https://github.com/BRIKEV/twd-cli/commit/0f4af94))
|
|
20
|
+
* feat: add basic cli feature ([23bde8c](https://github.com/BRIKEV/twd-cli/commit/23bde8c))
|
|
21
|
+
* feat: add dependencies and package json ([bb3500f](https://github.com/BRIKEV/twd-cli/commit/bb3500f))
|
|
22
|
+
* feat: remove ci workflow ([9b902f7](https://github.com/BRIKEV/twd-cli/commit/9b902f7))
|
|
23
|
+
* ci: basic github action integration ([780a0df](https://github.com/BRIKEV/twd-cli/commit/780a0df))
|
|
24
|
+
* ci: comment integration ([c56b89c](https://github.com/BRIKEV/twd-cli/commit/c56b89c))
|
|
25
|
+
* Initial commit ([bc3eb91](https://github.com/BRIKEV/twd-cli/commit/bc3eb91))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
package/bin/twd-cli.js
CHANGED
|
@@ -6,9 +6,9 @@ const command = process.argv[2];
|
|
|
6
6
|
|
|
7
7
|
if (command === 'run') {
|
|
8
8
|
try {
|
|
9
|
-
await runTests();
|
|
9
|
+
const hasFailures = await runTests();
|
|
10
|
+
process.exit(hasFailures ? 1 : 0);
|
|
10
11
|
} catch (error) {
|
|
11
|
-
console.error('Error running tests:', error);
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twd-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "CLI tool for running TWD tests with Puppeteer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"twd-cli": "./bin/twd-cli.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "
|
|
11
|
+
"test": "vitest",
|
|
12
|
+
"test:ci": "vitest --run --coverage",
|
|
13
|
+
"conventional-changelog": "conventional-changelog -i CHANGELOG.md",
|
|
12
14
|
"execute:cli": "node ./bin/twd-cli.js"
|
|
13
15
|
},
|
|
14
16
|
"keywords": [
|
|
@@ -26,5 +28,10 @@
|
|
|
26
28
|
},
|
|
27
29
|
"engines": {
|
|
28
30
|
"node": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@vitest/coverage-v8": "^4.0.13",
|
|
34
|
+
"conventional-changelog": "^7.1.1",
|
|
35
|
+
"vitest": "^4.0.13"
|
|
29
36
|
}
|
|
30
37
|
}
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import puppeteer from 'puppeteer';
|
|
4
|
-
import { reportResults
|
|
4
|
+
import { reportResults } from 'twd-js/runner-ci';
|
|
5
5
|
import { loadConfig } from './config.js';
|
|
6
6
|
|
|
7
7
|
export async function runTests() {
|
|
@@ -25,12 +25,27 @@ export async function runTests() {
|
|
|
25
25
|
await page.goto(config.url);
|
|
26
26
|
|
|
27
27
|
// Wait for the selector to be available
|
|
28
|
-
await page.waitForSelector(
|
|
28
|
+
await page.waitForSelector('[data-testid="twd-sidebar"]', { timeout: config.timeout });
|
|
29
29
|
console.log('Page loaded. Starting tests...');
|
|
30
30
|
|
|
31
31
|
// Execute all tests
|
|
32
32
|
const { handlers, testStatus } = await page.evaluate(async () => {
|
|
33
|
-
|
|
33
|
+
const TestRunner = window.__testRunner;
|
|
34
|
+
const testStatus = [];
|
|
35
|
+
const runner = new TestRunner({
|
|
36
|
+
onStart: () => {},
|
|
37
|
+
onPass: (test) => {
|
|
38
|
+
testStatus.push({ id: test.id, status: "pass" });
|
|
39
|
+
},
|
|
40
|
+
onFail: (test, err) => {
|
|
41
|
+
testStatus.push({ id: test.id, status: "fail", error: err.message });
|
|
42
|
+
},
|
|
43
|
+
onSkip: (test) => {
|
|
44
|
+
testStatus.push({ id: test.id, status: "skip" });
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const handlers = await runner.runAll();
|
|
48
|
+
return { handlers: Array.from(handlers.values()), testStatus };
|
|
34
49
|
});
|
|
35
50
|
|
|
36
51
|
console.log(`Tests to report: ${testStatus.length}`);
|
|
@@ -68,11 +83,11 @@ export async function runTests() {
|
|
|
68
83
|
await browser.close();
|
|
69
84
|
console.log('Browser closed.');
|
|
70
85
|
|
|
71
|
-
|
|
86
|
+
return hasFailures;
|
|
72
87
|
|
|
73
88
|
} catch (error) {
|
|
74
89
|
console.error('Error running tests:', error);
|
|
75
90
|
await browser.close();
|
|
76
|
-
|
|
91
|
+
throw error;
|
|
77
92
|
}
|
|
78
93
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
|
|
13
|
+
|
|
14
|
+
Note: This will impact Vite dev & build performances.
|
|
15
|
+
|
|
16
|
+
## Expanding the ESLint configuration
|
|
17
|
+
|
|
18
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
export default defineConfig([
|
|
22
|
+
globalIgnores(['dist']),
|
|
23
|
+
{
|
|
24
|
+
files: ['**/*.{ts,tsx}'],
|
|
25
|
+
extends: [
|
|
26
|
+
// Other configs...
|
|
27
|
+
|
|
28
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
29
|
+
tseslint.configs.recommendedTypeChecked,
|
|
30
|
+
// Alternatively, use this for stricter rules
|
|
31
|
+
tseslint.configs.strictTypeChecked,
|
|
32
|
+
// Optionally, add this for stylistic rules
|
|
33
|
+
tseslint.configs.stylisticTypeChecked,
|
|
34
|
+
|
|
35
|
+
// Other configs...
|
|
36
|
+
],
|
|
37
|
+
languageOptions: {
|
|
38
|
+
parserOptions: {
|
|
39
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
40
|
+
tsconfigRootDir: import.meta.dirname,
|
|
41
|
+
},
|
|
42
|
+
// other options...
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
])
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
// eslint.config.js
|
|
52
|
+
import reactX from 'eslint-plugin-react-x'
|
|
53
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
54
|
+
|
|
55
|
+
export default defineConfig([
|
|
56
|
+
globalIgnores(['dist']),
|
|
57
|
+
{
|
|
58
|
+
files: ['**/*.{ts,tsx}'],
|
|
59
|
+
extends: [
|
|
60
|
+
// Other configs...
|
|
61
|
+
// Enable lint rules for React
|
|
62
|
+
reactX.configs['recommended-typescript'],
|
|
63
|
+
// Enable lint rules for React DOM
|
|
64
|
+
reactDom.configs.recommended,
|
|
65
|
+
],
|
|
66
|
+
languageOptions: {
|
|
67
|
+
parserOptions: {
|
|
68
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
69
|
+
tsconfigRootDir: import.meta.dirname,
|
|
70
|
+
},
|
|
71
|
+
// other options...
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
])
|
|
75
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import tseslint from 'typescript-eslint'
|
|
6
|
+
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
7
|
+
|
|
8
|
+
export default defineConfig([
|
|
9
|
+
globalIgnores(['dist']),
|
|
10
|
+
{
|
|
11
|
+
files: ['**/*.{ts,tsx}'],
|
|
12
|
+
extends: [
|
|
13
|
+
js.configs.recommended,
|
|
14
|
+
tseslint.configs.recommended,
|
|
15
|
+
reactHooks.configs.flat.recommended,
|
|
16
|
+
reactRefresh.configs.vite,
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
globals: globals.browser,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
])
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>test-example-app</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|