@pplancq/react-template 2.4.5 → 2.5.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/CHANGELOG.md +23 -0
- package/_README.md +31 -22
- package/_gitignore +4 -0
- package/eslint.config.mjs +3 -0
- package/mrc.playwright.config.ts +29 -0
- package/package.json +27 -16
- package/playwright.config.ts +48 -0
- package/scripts/playwright.js +38 -0
- package/scripts/test.js +20 -0
- package/tests/demo.test.ts +10 -0
- package/tests/utils/playwright.globalSetup.ts +12 -0
- package/tests/utils/playwright.globalTeardown.ts +11 -0
- package/tests/utils/playwright.testWithCoverage.ts +34 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## @pplancq/react-template [2.5.0](https://github.com/pplancq/dev-tools/compare/@pplancq/react-template@2.4.5...@pplancq/react-template@2.5.0) (2025-06-09)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **react-template:** add Playwright support in ESLint configuration and update linting scripts ([c8b11ce](https://github.com/pplancq/dev-tools/commit/c8b11cef09478edd6a2fad02fc14e2828b3239b7))
|
|
6
|
+
* **react-template:** add Playwright testing setup and configuration ([f4f7089](https://github.com/pplancq/dev-tools/commit/f4f7089540e743fa8e4b7c03e3f534758c61b159))
|
|
7
|
+
* **react-template:** add watch mode for Playwright tests using nodemon ([ecb400a](https://github.com/pplancq/dev-tools/commit/ecb400a52a076aa58c6f9065441c049c9d3c44b4))
|
|
8
|
+
* **react-template:** enhance Playwright testing setup with coverage reporting ([d7b1422](https://github.com/pplancq/dev-tools/commit/d7b14229773bc5b4b1e1defa83a258f214a21d21))
|
|
9
|
+
* **react-template:** update test scripts and add concurrent execution for unit and e2e tests ([05f0205](https://github.com/pplancq/dev-tools/commit/05f0205e81c17e8c9b5cb6a90358d3de3f954a9e))
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency react-hook-form to ^7.57.0 ([502badf](https://github.com/pplancq/dev-tools/commit/502badf5767175f9944bec67e673d54ec4fb837e))
|
|
14
|
+
* **deps:** update dependency react-router to ^7.6.2 ([f0da2c0](https://github.com/pplancq/dev-tools/commit/f0da2c08810dd3396fd79174f1f9289e26784521))
|
|
15
|
+
* **deps:** update react-query mono repo to ^5.80.6 ([fbdbdc2](https://github.com/pplancq/dev-tools/commit/fbdbdc2255cb6619ee1d9aca6e749627267ec93a))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
* **@pplancq/eslint-config:** upgraded to 4.1.0
|
|
21
|
+
* **@pplancq/postcss-config:** upgraded to 2.1.12
|
|
22
|
+
* **@pplancq/webpack-config:** upgraded to 1.9.17
|
|
23
|
+
|
|
1
24
|
## @pplancq/react-template [2.4.5](https://github.com/pplancq/dev-tools/compare/@pplancq/react-template@2.4.4...@pplancq/react-template@2.4.5) (2025-06-02)
|
|
2
25
|
|
|
3
26
|
### Bug Fixes
|
package/_README.md
CHANGED
|
@@ -19,10 +19,9 @@ cd mon-projet
|
|
|
19
19
|
2. Install dependencies.
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install
|
|
22
|
+
npm install
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
In the project directory, you can run the following commands:
|
|
27
26
|
|
|
28
27
|
### `npm start`
|
|
@@ -36,11 +35,22 @@ You will also see lint errors in the console.
|
|
|
36
35
|
|
|
37
36
|
### `npm test`
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
Runs all tests (unit and e2e).
|
|
39
|
+
|
|
40
|
+
> You can add the `--coverage` flag to generate a coverage report for both unit and e2e tests.
|
|
41
|
+
> Example: `npm run test -- --coverage`
|
|
42
|
+
|
|
43
|
+
### `npm run test:unit`
|
|
44
|
+
|
|
45
|
+
Runs unit tests using Vitest.
|
|
46
|
+
|
|
47
|
+
### `npm run test:unit:watch`
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
Runs unit tests in watch mode using Vitest.
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
### `npm run test:e2e`
|
|
52
|
+
|
|
53
|
+
Runs end-to-end tests using Playwright.
|
|
44
54
|
|
|
45
55
|
### `npm run build`
|
|
46
56
|
|
|
@@ -115,20 +125,20 @@ To migrate from webpack to vite.
|
|
|
115
125
|
|
|
116
126
|
Here is the project folder structure, with a brief description of each folder:
|
|
117
127
|
|
|
118
|
-
| Folder
|
|
119
|
-
|
|
|
120
|
-
| **📁 src**
|
|
121
|
-
| [**📁 ui**](./src/ui/README.md)
|
|
122
|
-
| [**📁 components**](./src/components/README.md)
|
|
123
|
-
| [**📁 providers**](./src/providers/README.md)
|
|
124
|
-
| [**📁 pages**](./src/pages/README.md)
|
|
125
|
-
| [**📁 forms**](./src/forms/README.md)
|
|
126
|
-
| [**📁 hooks**](./src/hooks/README.md)
|
|
127
|
-
| [**📁 utils**](./src/utils/README.md)
|
|
128
|
-
| [**📁 routing**](./src/routing/README.md)
|
|
129
|
-
| [**📁 types**](./src/types/README.md)
|
|
130
|
-
| [**📁 assets**](./src/assets/README.md)
|
|
131
|
-
| [**📁 config**](./src/config/README.md)
|
|
128
|
+
| Folder | Description |
|
|
129
|
+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
130
|
+
| **📁 src** | **_The root directory of the application source code._** |
|
|
131
|
+
| [**📁 ui**](./src/ui/README.md) | Contains reusable components designed to be used across projects. Components can be basic (Atoms), more complex (Molecules), higher-level components (Organisms), or page templates (Templates). |
|
|
132
|
+
| [**📁 components**](./src/components/README.md) | Contains project-specific reusable components, for example, form components using React Hook Form. |
|
|
133
|
+
| [**📁 providers**](./src/providers/README.md) | This folder contains context providers or custom hooks that provide data to the entire application. |
|
|
134
|
+
| [**📁 pages**](./src/pages/README.md) | Contains the pages of the application. Each subfolder represents a distinct page or view of the application. |
|
|
135
|
+
| [**📁 forms**](./src/forms/README.md) | Contains the forms of the application, grouping hooks related to forms. |
|
|
136
|
+
| [**📁 hooks**](./src/hooks/README.md) | Includes custom hooks for various application features, such as API calls with React Query. |
|
|
137
|
+
| [**📁 utils**](./src/utils/README.md) | Contains utilities and services such as test files, utility functions, etc. |
|
|
138
|
+
| [**📁 routing**](./src/routing/README.md) | This folder is intended for native API calls using the `fetch`. function. These calls are essential for fetching real-time data from external sources, such as remote servers or web services. |
|
|
139
|
+
| [**📁 types**](./src/types/README.md) | Provides TypeScript type definitions to enhance the robustness of your code. |
|
|
140
|
+
| [**📁 assets**](./src/assets/README.md) | Contains static files such as images, fonts, etc., used in the application. |
|
|
141
|
+
| [**📁 config**](./src/config/README.md) | Contains all the important configurations and utilities needed for our project. |
|
|
132
142
|
|
|
133
143
|
## 🏗 <span id="component-structure">React Component Structure</span>
|
|
134
144
|
|
|
@@ -198,7 +208,6 @@ export const useComponentName = ({ foo }: UseComponentNameProps): UseComponentNa
|
|
|
198
208
|
bar: foo,
|
|
199
209
|
};
|
|
200
210
|
};
|
|
201
|
-
|
|
202
211
|
```
|
|
203
212
|
|
|
204
213
|
#### 📄 ComponentName.module.scss
|
|
@@ -209,7 +218,6 @@ The style specific to the component will be written in module form. This allows
|
|
|
209
218
|
.root {
|
|
210
219
|
background-color: red;
|
|
211
220
|
}
|
|
212
|
-
|
|
213
221
|
```
|
|
214
222
|
|
|
215
223
|
```typescript
|
|
@@ -221,6 +229,7 @@ export const ComponentName = () => {
|
|
|
221
229
|
);
|
|
222
230
|
};
|
|
223
231
|
```
|
|
232
|
+
|
|
224
233
|
### ❗ Naming Conventions
|
|
225
234
|
|
|
226
235
|
==> Component names, file names, and folder names should follow the **PascalCase** convention.
|
|
@@ -233,7 +242,7 @@ It is recommended to only include non-sensitive environment variables in the app
|
|
|
233
242
|
|
|
234
243
|
Ensure you understand the security implications before including environment variables in your bundle.
|
|
235
244
|
|
|
236
|
-
Please note that the web configuration pre-filters environment variables via the default prefix ‘
|
|
245
|
+
Please note that the web configuration pre-filters environment variables via the default prefix ‘FRONT*’. This means that only environment variables starting with ‘FRONT*’ will be included in the bundle. This is an additional layer of security to prevent the accidental exposure of sensitive environment variables.
|
|
237
246
|
|
|
238
247
|
## 🙇 <span id="learnmore">Learn More</span>
|
|
239
248
|
|
package/_gitignore
CHANGED
package/eslint.config.mjs
CHANGED
|
@@ -4,6 +4,9 @@ export default defineConfig({
|
|
|
4
4
|
enableReact: true,
|
|
5
5
|
enablePrettier: 'on',
|
|
6
6
|
enableVitest: true,
|
|
7
|
+
unitTestFiles: ['src/**/*.{test,spec,steps}.{js,jsx,ts,tsx}'],
|
|
8
|
+
enablePlaywright: true,
|
|
9
|
+
unitE2eFiles: ['tests/**/*.{test,spec}.{js,jsx,ts,tsx}'],
|
|
7
10
|
extendConfig: [
|
|
8
11
|
{
|
|
9
12
|
files: ['mocks/**/*'],
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CoverageReportOptions } from 'monocart-coverage-reports';
|
|
2
|
+
|
|
3
|
+
export const coverageOptions: CoverageReportOptions = {
|
|
4
|
+
enabled: process.env.CI ?? process.env.ENABLED_COVERAGE,
|
|
5
|
+
name: 'Playwright Coverage Report',
|
|
6
|
+
outputDir: './playwright-report/coverage',
|
|
7
|
+
baseDir: './src/',
|
|
8
|
+
reports: [
|
|
9
|
+
'text',
|
|
10
|
+
'text-summary',
|
|
11
|
+
['html', { subdir: 'html-coverage' }],
|
|
12
|
+
['lcovonly', { file: 'lcov-coverage.info' }],
|
|
13
|
+
['cobertura', { file: 'cobertura-coverage.xml' }],
|
|
14
|
+
],
|
|
15
|
+
sourceFilter: {
|
|
16
|
+
'**/node_modules/**': false,
|
|
17
|
+
'**/mocks/**': false,
|
|
18
|
+
'**/*.{test,spec,steps}.{js,jsx,ts,tsx}': false,
|
|
19
|
+
'vitest.setup.ts': false,
|
|
20
|
+
'**/*.{js,jsx,ts,tsx}': true,
|
|
21
|
+
},
|
|
22
|
+
watermarks: {
|
|
23
|
+
statements: [80, 90],
|
|
24
|
+
branches: [70, 80],
|
|
25
|
+
functions: [80, 90],
|
|
26
|
+
lines: [80, 90],
|
|
27
|
+
bytes: [80, 90],
|
|
28
|
+
},
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pplancq/react-template",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "react template",
|
|
6
6
|
"author": "pplancq <paul.plancq@outlook.fr>",
|
|
@@ -14,16 +14,23 @@
|
|
|
14
14
|
"start": "webpack serve",
|
|
15
15
|
"start:mock": "webpack serve --env FRONT_MOCK_ENABLE=true",
|
|
16
16
|
"build": "webpack --mode production",
|
|
17
|
-
"test": "
|
|
18
|
-
"test:
|
|
17
|
+
"test": "node scripts/test.js",
|
|
18
|
+
"test:unit": "vitest run",
|
|
19
|
+
"test:unit:watch": "vitest",
|
|
20
|
+
"test:e2e": "node scripts/playwright.js test",
|
|
21
|
+
"test:e2e:watch": "node scripts/playwright.js test --watch",
|
|
22
|
+
"test:e2e:ui": "node scripts/playwright.js test --ui",
|
|
19
23
|
"lint": "node scripts/lint.js",
|
|
20
|
-
"lint:eslint": "eslint \"{mocks,public,src}/**/*.{js,jsx,mjs,ts,tsx}\"",
|
|
21
|
-
"lint:eslint:fix": "eslint \"{mocks,public,src}/**/*.{js,jsx,mjs,ts,tsx}\" --fix",
|
|
24
|
+
"lint:eslint": "eslint \"{mocks,public,src,tests}/**/*.{js,jsx,mjs,ts,tsx}\"",
|
|
25
|
+
"lint:eslint:fix": "eslint \"{mocks,public,src,tests}/**/*.{js,jsx,mjs,ts,tsx}\" --fix",
|
|
22
26
|
"lint:stylelint": "stylelint \"src/**/*.{scss,css}\"",
|
|
23
27
|
"lint:stylelint:fix": "stylelint \"src/**/*.{scss,css}\" --fix",
|
|
24
28
|
"lint:prettier": "prettier \"{mocks,public,src}/**/*.!(js|jsx|mjs|ts|tsx|scss|css)\" --check --ignore-unknown",
|
|
25
29
|
"lint:prettier:fix": "prettier \"{mocks,public,src}/**/*.!(js|jsx|mjs|ts|tsx|scss|css)\" --write --ignore-unknown",
|
|
26
30
|
"lint:tsc": "tsc --noEmit",
|
|
31
|
+
"playwright:install": "playwright install",
|
|
32
|
+
"playwright:show-report": "playwright show-report",
|
|
33
|
+
"playwright:codegen": "playwright codegen",
|
|
27
34
|
"package:check": "npm exec --yes package-lock-utd@1.1.3",
|
|
28
35
|
"remove:demo": "node ./scripts/removeDemo.cjs",
|
|
29
36
|
"migrate:vite": "node ./scripts/migrateToVite.cjs",
|
|
@@ -39,16 +46,18 @@
|
|
|
39
46
|
],
|
|
40
47
|
"dependencies": {
|
|
41
48
|
"@hookform/resolvers": "^5.0.1",
|
|
42
|
-
"@tanstack/react-query": "^5.
|
|
43
|
-
"@tanstack/react-query-devtools": "^5.
|
|
49
|
+
"@tanstack/react-query": "^5.80.6",
|
|
50
|
+
"@tanstack/react-query-devtools": "^5.80.6",
|
|
44
51
|
"react": "^19.1.0",
|
|
45
52
|
"react-dom": "^19.1.0",
|
|
46
|
-
"react-hook-form": "^7.
|
|
47
|
-
"react-router": "^7.6.
|
|
53
|
+
"react-hook-form": "^7.57.0",
|
|
54
|
+
"react-router": "^7.6.2",
|
|
48
55
|
"yup": "^1.6.1"
|
|
49
56
|
},
|
|
50
57
|
"devDependencies": {
|
|
58
|
+
"@bdellegrazie/playwright-sonar-reporter": "^0.4.0",
|
|
51
59
|
"@commitlint/cli": "^19.8.1",
|
|
60
|
+
"@playwright/test": "^1.52.0",
|
|
52
61
|
"@pplancq/commitlint-config": "*",
|
|
53
62
|
"@pplancq/eslint-config": "*",
|
|
54
63
|
"@pplancq/postcss-config": "*",
|
|
@@ -59,16 +68,18 @@
|
|
|
59
68
|
"@testing-library/react": "^16.3.0",
|
|
60
69
|
"@testing-library/user-event": "^14.6.1",
|
|
61
70
|
"@types/react": "^19.1.6",
|
|
62
|
-
"@types/react-dom": "^19.1.
|
|
63
|
-
"@vitejs/plugin-react-swc": "^3.10.
|
|
64
|
-
"@vitest/coverage-v8": "^3.
|
|
71
|
+
"@types/react-dom": "^19.1.6",
|
|
72
|
+
"@vitejs/plugin-react-swc": "^3.10.1",
|
|
73
|
+
"@vitest/coverage-v8": "^3.2.2",
|
|
65
74
|
"concurrently": "^9.1.2",
|
|
66
|
-
"eslint": "^9.
|
|
75
|
+
"eslint": "^9.28.0",
|
|
67
76
|
"eslint-plugin-prettier": "^5.4.1",
|
|
68
77
|
"husky": "^9.1.7",
|
|
69
78
|
"jsdom": "^26.1.0",
|
|
70
79
|
"lint-staged": "^16.1.0",
|
|
71
|
-
"
|
|
80
|
+
"monocart-coverage-reports": "^2.12.6",
|
|
81
|
+
"msw": "^2.9.0",
|
|
82
|
+
"nodemon": "^3.1.10",
|
|
72
83
|
"prettier": "^3.5.3",
|
|
73
84
|
"stylelint": "^16.20.0",
|
|
74
85
|
"stylelint-prettier": "^5.0.3",
|
|
@@ -76,12 +87,12 @@
|
|
|
76
87
|
"typescript": "^5.8.3",
|
|
77
88
|
"vite-plugin-svgr": "^4.3.0",
|
|
78
89
|
"vite-tsconfig-paths": "^5.1.4",
|
|
79
|
-
"vitest": "^3.
|
|
90
|
+
"vitest": "^3.2.2",
|
|
80
91
|
"vitest-axe": "^1.0.0-pre.5",
|
|
81
92
|
"vitest-sonar-reporter": "^2.0.1",
|
|
82
93
|
"webpack": "^5.99.9",
|
|
83
94
|
"webpack-cli": "^6.0.1",
|
|
84
|
-
"webpack-dev-server": "^5.2.
|
|
95
|
+
"webpack-dev-server": "^5.2.2"
|
|
85
96
|
},
|
|
86
97
|
"engines": {
|
|
87
98
|
"node": ">=20.12.2"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
const appUrl = 'http://localhost:3000';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
testDir: 'tests',
|
|
7
|
+
outputDir: 'test-results',
|
|
8
|
+
fullyParallel: true,
|
|
9
|
+
forbidOnly: Boolean(process.env.CI),
|
|
10
|
+
retries: process.env.CI ? 2 : 0,
|
|
11
|
+
workers: process.env.CI ? 1 : undefined,
|
|
12
|
+
reporter: [
|
|
13
|
+
['list'],
|
|
14
|
+
['html', { open: 'never', outputFolder: 'playwright-report/html' }],
|
|
15
|
+
['junit', { outputFile: 'playwright-report/junit-report.xml' }],
|
|
16
|
+
[
|
|
17
|
+
'@bdellegrazie/playwright-sonar-reporter',
|
|
18
|
+
{ outputFile: 'playwright-report/sonar-results.xml', sonarcloud: true },
|
|
19
|
+
],
|
|
20
|
+
],
|
|
21
|
+
globalSetup: 'tests/utils/playwright.globalSetup.ts',
|
|
22
|
+
globalTeardown: 'tests/utils/playwright.globalTeardown.ts',
|
|
23
|
+
use: {
|
|
24
|
+
baseURL: appUrl,
|
|
25
|
+
trace: 'retain-on-failure',
|
|
26
|
+
screenshot: 'only-on-failure',
|
|
27
|
+
},
|
|
28
|
+
projects: [
|
|
29
|
+
{
|
|
30
|
+
name: 'chromium',
|
|
31
|
+
use: { ...devices['Desktop Chrome'] },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'firefox',
|
|
35
|
+
use: { ...devices['Firefox Desktop'] },
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'webkit',
|
|
39
|
+
use: { ...devices['Desktop Safari'] },
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
webServer: {
|
|
43
|
+
command: 'npm run start:mock',
|
|
44
|
+
url: appUrl,
|
|
45
|
+
stdout: 'pipe',
|
|
46
|
+
reuseExistingServer: !process.env.CI,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
|
|
3
|
+
const runCommand = (cmd, args = []) => {
|
|
4
|
+
console.info(`> ${cmd} ${args.join(' ')}`);
|
|
5
|
+
const result = spawnSync(cmd, args, { cwd: process.cwd(), stdio: 'inherit' });
|
|
6
|
+
if (result.status !== 0) {
|
|
7
|
+
throw result;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const main = async () => {
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
|
|
14
|
+
let playwrightArgs = [...args];
|
|
15
|
+
|
|
16
|
+
if (args.indexOf('--watch') !== -1) {
|
|
17
|
+
const filteredArgs = args.filter(a => a !== '--watch');
|
|
18
|
+
runCommand('npx', [
|
|
19
|
+
'nodemon',
|
|
20
|
+
'--watch',
|
|
21
|
+
'./tests/',
|
|
22
|
+
'--ext',
|
|
23
|
+
'js,jx,ts,tsx',
|
|
24
|
+
'--exec',
|
|
25
|
+
['node', 'scripts/playwright.js', ...filteredArgs].join(' '),
|
|
26
|
+
]);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (playwrightArgs.indexOf('--coverage') !== -1) {
|
|
31
|
+
process.env.ENABLED_COVERAGE = 'true';
|
|
32
|
+
playwrightArgs = playwrightArgs.filter(p => p !== '--coverage');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
runCommand('npx', ['playwright', ...playwrightArgs]);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
main().catch(e => process.exit(e.status));
|
package/scripts/test.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
import concurrently from 'concurrently';
|
|
3
|
+
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
|
|
6
|
+
let commands = ['npm:test:unit', 'npm:test:e2e'];
|
|
7
|
+
|
|
8
|
+
if (args.includes('--coverage')) {
|
|
9
|
+
commands = commands.map(command => `${command} -- --coverage`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { result } = concurrently(commands, {
|
|
13
|
+
prefixColors: 'auto',
|
|
14
|
+
maxProcesses: 1,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
result.then(
|
|
18
|
+
() => process.exit(0),
|
|
19
|
+
() => process.exit(1),
|
|
20
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { describe, it } from './utils/playwright.testWithCoverage';
|
|
3
|
+
|
|
4
|
+
describe('Demo Test', () => {
|
|
5
|
+
it('should have a title', async ({ page }) => {
|
|
6
|
+
await page.goto('/');
|
|
7
|
+
const title = page.getByText('WELCOME TO YOUR REACT STARTER KIT');
|
|
8
|
+
await expect(title).toBeVisible();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FullConfig } from '@playwright/test';
|
|
2
|
+
import { CoverageReport } from 'monocart-coverage-reports';
|
|
3
|
+
import { coverageOptions } from '../../mrc.playwright.config';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line import/no-default-export
|
|
6
|
+
export default (config: FullConfig) => {
|
|
7
|
+
if (config.webServer && coverageOptions.enabled) {
|
|
8
|
+
console.info('[playwright] Coverage enabled with monocart');
|
|
9
|
+
const mcr = new CoverageReport(coverageOptions);
|
|
10
|
+
mcr.cleanCache();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FullConfig } from '@playwright/test';
|
|
2
|
+
import { CoverageReport } from 'monocart-coverage-reports';
|
|
3
|
+
import { coverageOptions } from '../../mrc.playwright.config';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line import/no-default-export
|
|
6
|
+
export default async (config: FullConfig) => {
|
|
7
|
+
if (config.webServer && coverageOptions.enabled) {
|
|
8
|
+
const mcr = new CoverageReport(coverageOptions);
|
|
9
|
+
await mcr.generate();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { test as base } from '@playwright/test';
|
|
2
|
+
import { CoverageReport } from 'monocart-coverage-reports';
|
|
3
|
+
import { coverageOptions } from '../../mrc.playwright.config';
|
|
4
|
+
|
|
5
|
+
export const test = base.extend<{
|
|
6
|
+
testWithCoverage: string;
|
|
7
|
+
}>({
|
|
8
|
+
testWithCoverage: [
|
|
9
|
+
async ({ page }, use) => {
|
|
10
|
+
const isChromium = test.info().project.name === 'chromium';
|
|
11
|
+
|
|
12
|
+
if (isChromium && coverageOptions.enabled) {
|
|
13
|
+
await page.coverage.startJSCoverage({
|
|
14
|
+
resetOnNavigation: false,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
await use('testWithCoverage');
|
|
19
|
+
|
|
20
|
+
if (isChromium && coverageOptions.enabled) {
|
|
21
|
+
const coverageList = await page.coverage.stopJSCoverage();
|
|
22
|
+
const mcr = new CoverageReport(coverageOptions);
|
|
23
|
+
await mcr.add(coverageList);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
scope: 'test',
|
|
28
|
+
auto: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const it = test;
|
|
34
|
+
export const { describe } = test;
|