@trackunit/iris-app-playwright 0.1.39 → 0.2.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/README.md
CHANGED
|
@@ -33,7 +33,7 @@ This creates:
|
|
|
33
33
|
- `playwright/support/fixtures.ts` — re-exports `test`, `expect`, and `describe`
|
|
34
34
|
- `playwright/fixtures/auth.json` — fill in credentials
|
|
35
35
|
- `playwright/tests/app.spec.ts` — sample login spec
|
|
36
|
-
- `e2e
|
|
36
|
+
- `e2e` and `e2e-ui` targets in `project.json`
|
|
37
37
|
|
|
38
38
|
### 2. Fill in credentials
|
|
39
39
|
|
|
@@ -64,10 +64,10 @@ describe("My Feature", () => {
|
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
66
|
# Against dev environment (headless)
|
|
67
|
-
yarn nx run my-app:e2e
|
|
67
|
+
yarn nx run my-app:e2e --configuration=dev
|
|
68
68
|
|
|
69
69
|
# Interactive UI mode
|
|
70
|
-
yarn nx run my-app:e2e-
|
|
70
|
+
yarn nx run my-app:e2e-ui --configuration=local
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
> **Outside the devcontainer:** Playwright browser binaries are not bundled. Run
|
|
@@ -193,7 +193,7 @@ Defaults to Playwright's behaviour (`undefined`, project-level setting wins). Se
|
|
|
193
193
|
Set the `codeowner` environment variable to append a `[team-name]` suffix to all describe titles in the test report:
|
|
194
194
|
|
|
195
195
|
```bash
|
|
196
|
-
codeowner=team-gluon-fe yarn nx run my-app:e2e
|
|
196
|
+
codeowner=team-gluon-fe yarn nx run my-app:e2e --configuration=dev
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
Use the `describe` wrapper exported from `@trackunit/iris-app-playwright/support` (not Playwright's built-in `test.describe`) to get this behaviour.
|
package/package.json
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.playwrightConfigurationGenerator = playwrightConfigurationGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const PLAYWRIGHT_TSCONFIG_REFERENCE = "./playwright/tsconfig.json";
|
|
6
|
+
/**
|
|
7
|
+
* Registers the scaffolded `playwright/tsconfig.json` as a project reference in the
|
|
8
|
+
* project's root `tsconfig.json`. Without this, the playwright tsconfig is orphaned:
|
|
9
|
+
* a solution-style root tsconfig only type-checks what it references, so editors and
|
|
10
|
+
* `tsc-validate` never pick up the spec files.
|
|
11
|
+
*
|
|
12
|
+
* No-ops when the project has no root `tsconfig.json`, or when the reference is already
|
|
13
|
+
* present (so re-runs stay idempotent).
|
|
14
|
+
*/
|
|
15
|
+
function addPlaywrightTsConfigReference(tree, projectRoot) {
|
|
16
|
+
const tsConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, "tsconfig.json");
|
|
17
|
+
if (!tree.exists(tsConfigPath)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
(0, devkit_1.updateJson)(tree, tsConfigPath, tsConfig => {
|
|
21
|
+
const references = tsConfig.references ?? [];
|
|
22
|
+
const alreadyReferenced = references.some(reference => reference.path === PLAYWRIGHT_TSCONFIG_REFERENCE);
|
|
23
|
+
if (alreadyReferenced) {
|
|
24
|
+
return tsConfig;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
...tsConfig,
|
|
28
|
+
references: [...references, { path: PLAYWRIGHT_TSCONFIG_REFERENCE }],
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
5
32
|
/**
|
|
6
33
|
* Generates Playwright E2E test configuration for an existing project.
|
|
7
34
|
*
|
|
@@ -47,7 +74,7 @@ async function playwrightConfigurationGenerator(tree, options) {
|
|
|
47
74
|
...existingProjectConfig,
|
|
48
75
|
targets: {
|
|
49
76
|
...existingProjectConfig.targets,
|
|
50
|
-
"e2e-
|
|
77
|
+
"e2e-ui": {
|
|
51
78
|
executor: "nx:run-commands",
|
|
52
79
|
options: {
|
|
53
80
|
command: `playwright test --config=playwright.config.ts --headed --ui`,
|
|
@@ -55,7 +82,7 @@ async function playwrightConfigurationGenerator(tree, options) {
|
|
|
55
82
|
},
|
|
56
83
|
configurations,
|
|
57
84
|
},
|
|
58
|
-
|
|
85
|
+
e2e: {
|
|
59
86
|
executor: "nx:run-commands",
|
|
60
87
|
options: {
|
|
61
88
|
command: `playwright test --config=playwright.config.ts`,
|
|
@@ -69,9 +96,13 @@ async function playwrightConfigurationGenerator(tree, options) {
|
|
|
69
96
|
...options,
|
|
70
97
|
tmpl: "",
|
|
71
98
|
});
|
|
99
|
+
addPlaywrightTsConfigReference(tree, projectRoot);
|
|
72
100
|
await (0, devkit_1.formatFiles)(tree);
|
|
73
101
|
return () => {
|
|
74
|
-
devkit_1.logger.info(`\n\n
|
|
102
|
+
devkit_1.logger.info(`\n\n✅ 🚀 \nPlease update credentials in:
|
|
103
|
+
${(0, devkit_1.joinPathFragments)(projectRoot, "playwright/fixtures/auth.json")}
|
|
104
|
+
and open this file to get started writing tests:
|
|
105
|
+
${(0, devkit_1.joinPathFragments)(projectRoot, "playwright/tests/app.spec.ts")}`);
|
|
75
106
|
};
|
|
76
107
|
}
|
|
77
108
|
//# sourceMappingURL=generator.js.map
|