@nx/playwright 17.3.0-canary.20240116-42aefd8 → 17.3.0-canary.20240119-b5ffb85
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/package.json +5 -5
- package/src/generators/configuration/configuration.js +42 -4
- package/src/generators/configuration/files/playwright.config.ts.template +37 -1
- package/src/generators/configuration/schema.d.ts +1 -0
- package/src/generators/configuration/schema.json +5 -0
- package/src/generators/init/init.js +3 -30
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +3 -2
- package/src/plugins/plugin.js +2 -2
- package/src/utils/preset.d.ts +1 -10
- package/src/utils/preset.js +1 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/playwright",
|
|
3
|
-
"version": "17.3.0-canary.
|
|
3
|
+
"version": "17.3.0-canary.20240119-b5ffb85",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"homepage": "https://nx.dev",
|
|
6
6
|
"private": false,
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"directory": "packages/playwright"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nx/devkit": "17.3.0-canary.
|
|
36
|
-
"@nx/eslint": "17.3.0-canary.
|
|
37
|
-
"@nx/js": "17.3.0-canary.
|
|
35
|
+
"@nx/devkit": "17.3.0-canary.20240119-b5ffb85",
|
|
36
|
+
"@nx/eslint": "17.3.0-canary.20240119-b5ffb85",
|
|
37
|
+
"@nx/js": "17.3.0-canary.20240119-b5ffb85",
|
|
38
38
|
"tslib": "^2.3.0",
|
|
39
|
-
"minimatch": "
|
|
39
|
+
"minimatch": "9.0.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@playwright/test": "^1.36.0"
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configurationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
6
|
+
const versions_1 = require("@nx/js/src/utils/versions");
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
5
8
|
const path = require("path");
|
|
6
|
-
const init_1 = require("../init/init");
|
|
7
9
|
const add_linter_1 = require("../../utils/add-linter");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
+
const versions_2 = require("../../utils/versions");
|
|
11
|
+
const init_1 = require("../init/init");
|
|
10
12
|
async function configurationGenerator(tree, options) {
|
|
11
13
|
const tasks = [];
|
|
12
|
-
tasks.push(await (0, init_1.
|
|
14
|
+
tasks.push(await (0, init_1.initGenerator)(tree, {
|
|
13
15
|
skipFormat: true,
|
|
14
16
|
skipPackageJson: options.skipPackageJson,
|
|
15
17
|
}));
|
|
@@ -62,12 +64,48 @@ async function configurationGenerator(tree, options) {
|
|
|
62
64
|
const { ModuleKind } = (0, devkit_1.ensurePackage)('typescript', versions_1.typescriptVersion);
|
|
63
65
|
(0, devkit_1.toJS)(tree, { extension: '.cjs', module: ModuleKind.CommonJS });
|
|
64
66
|
}
|
|
67
|
+
recommendVsCodeExtensions(tree);
|
|
68
|
+
if (!options.skipPackageJson) {
|
|
69
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
70
|
+
// required since used in playwright config
|
|
71
|
+
'@nx/devkit': versions_2.nxVersion,
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
if (!options.skipInstall) {
|
|
75
|
+
tasks.push(getBrowsersInstallTask());
|
|
76
|
+
}
|
|
65
77
|
if (!options.skipFormat) {
|
|
66
78
|
await (0, devkit_1.formatFiles)(tree);
|
|
67
79
|
}
|
|
68
80
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
69
81
|
}
|
|
70
82
|
exports.configurationGenerator = configurationGenerator;
|
|
83
|
+
function getBrowsersInstallTask() {
|
|
84
|
+
return () => {
|
|
85
|
+
devkit_1.output.log({
|
|
86
|
+
title: 'Ensuring Playwright is installed.',
|
|
87
|
+
bodyLines: ['use --skipInstall to skip installation.'],
|
|
88
|
+
});
|
|
89
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
90
|
+
(0, child_process_1.execSync)(`${pmc.exec} playwright install`, { cwd: devkit_1.workspaceRoot });
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function recommendVsCodeExtensions(tree) {
|
|
94
|
+
if (tree.exists('.vscode/extensions.json')) {
|
|
95
|
+
(0, devkit_1.updateJson)(tree, '.vscode/extensions.json', (json) => {
|
|
96
|
+
json.recommendations ??= [];
|
|
97
|
+
const recs = new Set(json.recommendations);
|
|
98
|
+
recs.add('ms-playwright.playwright');
|
|
99
|
+
json.recommendations = Array.from(recs);
|
|
100
|
+
return json;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
(0, devkit_1.writeJson)(tree, '.vscode/extensions.json', {
|
|
105
|
+
recommendations: ['ms-playwright.playwright'],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
71
109
|
function setupE2ETargetDefaults(tree) {
|
|
72
110
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
73
111
|
if (!nxJson.namedInputs) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineConfig } from '@playwright/test';
|
|
1
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
2
2
|
import { nxE2EPreset } from '@nx/playwright/preset';
|
|
3
3
|
<% if(!webServerCommand || !webServerAddress) { %>// eslint-disable-next-line @typescript-eslint/no-unused-vars <% } %>
|
|
4
4
|
import { workspaceRoot } from '@nx/devkit';
|
|
@@ -35,4 +35,40 @@ export default defineConfig({
|
|
|
35
35
|
// reuseExistingServer: !process.env.CI,
|
|
36
36
|
// cwd: workspaceRoot,
|
|
37
37
|
// },<% } %>
|
|
38
|
+
projects: [
|
|
39
|
+
{
|
|
40
|
+
name: "chromium",
|
|
41
|
+
use: { ...devices["Desktop Chrome"] },
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
name: "firefox",
|
|
46
|
+
use: { ...devices["Desktop Firefox"] },
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
name: "webkit",
|
|
51
|
+
use: { ...devices["Desktop Safari"] },
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// Uncomment for mobile browsers support
|
|
55
|
+
/* {
|
|
56
|
+
name: 'Mobile Chrome',
|
|
57
|
+
use: { ...devices['Pixel 5'] },
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'Mobile Safari',
|
|
61
|
+
use: { ...devices['iPhone 12'] },
|
|
62
|
+
}, */
|
|
63
|
+
|
|
64
|
+
// Uncomment for branded browsers
|
|
65
|
+
/* {
|
|
66
|
+
name: 'Microsoft Edge',
|
|
67
|
+
use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Google Chrome',
|
|
71
|
+
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
|
72
|
+
} */
|
|
73
|
+
],
|
|
38
74
|
});
|
|
@@ -62,6 +62,11 @@
|
|
|
62
62
|
"default": false,
|
|
63
63
|
"hidden": true,
|
|
64
64
|
"x-priority": "internal"
|
|
65
|
+
},
|
|
66
|
+
"skipInstall": {
|
|
67
|
+
"type": "boolean",
|
|
68
|
+
"description": "Skip running `playwright install`. This is to ensure that playwright browsers are installed.",
|
|
69
|
+
"default": false
|
|
65
70
|
}
|
|
66
71
|
},
|
|
67
72
|
"required": ["project"]
|
|
@@ -3,46 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../utils/versions");
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
6
|
async function initGenerator(tree, options) {
|
|
8
7
|
const tasks = [];
|
|
9
8
|
if (!options.skipPackageJson) {
|
|
10
9
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
11
10
|
'@nx/playwright': versions_1.nxVersion,
|
|
12
|
-
// required since used in playwright config
|
|
13
|
-
'@nx/devkit': versions_1.nxVersion,
|
|
14
11
|
'@playwright/test': versions_1.playwrightVersion,
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
if (!options.skipFormat) {
|
|
18
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
19
|
-
}
|
|
20
|
-
if (tree.exists('.vscode/extensions.json')) {
|
|
21
|
-
(0, devkit_1.updateJson)(tree, '.vscode/extensions.json', (json) => {
|
|
22
|
-
json.recommendations ??= [];
|
|
23
|
-
const recs = new Set(json.recommendations);
|
|
24
|
-
recs.add('ms-playwright.playwright');
|
|
25
|
-
json.recommendations = Array.from(recs);
|
|
26
|
-
return json;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
tree.write('.vscode/extensions.json', JSON.stringify({
|
|
31
|
-
recommendations: ['ms-playwright.playwright'],
|
|
32
|
-
}, null, 2));
|
|
12
|
+
}, undefined, options.keepExistingVersions));
|
|
33
13
|
}
|
|
34
14
|
if (process.env.NX_PCV3 === 'true') {
|
|
35
15
|
addPlugin(tree);
|
|
36
16
|
}
|
|
37
|
-
if (!options.
|
|
38
|
-
|
|
39
|
-
devkit_1.output.log({
|
|
40
|
-
title: 'Ensuring Playwright is installed.',
|
|
41
|
-
bodyLines: ['use --skipInstall to skip installation.'],
|
|
42
|
-
});
|
|
43
|
-
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
44
|
-
(0, child_process_1.execSync)(`${pmc.exec} playwright install`, { cwd: devkit_1.workspaceRoot });
|
|
45
|
-
});
|
|
17
|
+
if (!options.skipFormat) {
|
|
18
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
46
19
|
}
|
|
47
20
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
48
21
|
}
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
"description": "Do not add dependencies to `package.json`.",
|
|
18
18
|
"x-priority": "internal"
|
|
19
19
|
},
|
|
20
|
-
"
|
|
20
|
+
"keepExistingVersions": {
|
|
21
21
|
"type": "boolean",
|
|
22
|
-
"
|
|
22
|
+
"x-priority": "internal",
|
|
23
|
+
"description": "Keep existing dependencies versions",
|
|
23
24
|
"default": false
|
|
24
25
|
}
|
|
25
26
|
},
|
package/src/plugins/plugin.js
CHANGED
|
@@ -7,7 +7,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
8
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
9
9
|
const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
10
|
-
const
|
|
10
|
+
const minimatch_1 = require("minimatch");
|
|
11
11
|
const load_config_file_1 = require("../utils/load-config-file");
|
|
12
12
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
13
13
|
const js_1 = require("@nx/js");
|
|
@@ -136,7 +136,7 @@ function createMatcher(pattern) {
|
|
|
136
136
|
else {
|
|
137
137
|
return (path) => {
|
|
138
138
|
try {
|
|
139
|
-
return minimatch(path, pattern);
|
|
139
|
+
return (0, minimatch_1.minimatch)(path, pattern);
|
|
140
140
|
}
|
|
141
141
|
catch (e) {
|
|
142
142
|
throw new Error(`Error matching ${path} with ${pattern}: ${e.message}`);
|
package/src/utils/preset.d.ts
CHANGED
|
@@ -4,16 +4,6 @@ export interface NxPlaywrightOptions {
|
|
|
4
4
|
* @default './src'
|
|
5
5
|
**/
|
|
6
6
|
testDir?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Include Mobile Chome and Mobile Safari browsers in test projects
|
|
9
|
-
* @default false
|
|
10
|
-
**/
|
|
11
|
-
includeMobileBrowsers?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Include Microsoft Edge and Google Chrome browsers in test projects
|
|
14
|
-
* @default false
|
|
15
|
-
**/
|
|
16
|
-
includeBrandedBrowsers?: boolean;
|
|
17
7
|
}
|
|
18
8
|
/**
|
|
19
9
|
* nx E2E Preset for Playwright
|
|
@@ -25,6 +15,7 @@ export interface NxPlaywrightOptions {
|
|
|
25
15
|
* - chromium
|
|
26
16
|
* - firefox
|
|
27
17
|
* - webkit
|
|
18
|
+
* These are generated by default.
|
|
28
19
|
*
|
|
29
20
|
* you can easily extend this within your playwright config via spreading the preset
|
|
30
21
|
* @example
|
package/src/utils/preset.js
CHANGED
|
@@ -15,6 +15,7 @@ const test_1 = require("@playwright/test");
|
|
|
15
15
|
* - chromium
|
|
16
16
|
* - firefox
|
|
17
17
|
* - webkit
|
|
18
|
+
* These are generated by default.
|
|
18
19
|
*
|
|
19
20
|
* you can easily extend this within your playwright config via spreading the preset
|
|
20
21
|
* @example
|
|
@@ -34,44 +35,6 @@ function nxE2EPreset(pathToConfig, options) {
|
|
|
34
35
|
const offset = (0, node_path_1.relative)(normalizedPath, devkit_1.workspaceRoot);
|
|
35
36
|
const testResultOuputDir = (0, node_path_1.join)(offset, 'dist', '.playwright', projectPath, 'test-output');
|
|
36
37
|
const reporterOutputDir = (0, node_path_1.join)(offset, 'dist', '.playwright', projectPath, 'playwright-report');
|
|
37
|
-
const projects = [
|
|
38
|
-
{
|
|
39
|
-
name: 'chromium',
|
|
40
|
-
use: { ...test_1.devices['Desktop Chrome'] },
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'firefox',
|
|
44
|
-
use: { ...test_1.devices['Desktop Firefox'] },
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: 'webkit',
|
|
48
|
-
use: { ...test_1.devices['Desktop Safari'] },
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
if (options?.includeMobileBrowsers) {
|
|
52
|
-
projects.push(...[
|
|
53
|
-
{
|
|
54
|
-
name: 'Mobile Chrome',
|
|
55
|
-
use: { ...test_1.devices['Pixel 5'] },
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: 'Mobile Safari',
|
|
59
|
-
use: { ...test_1.devices['iPhone 12'] },
|
|
60
|
-
},
|
|
61
|
-
]);
|
|
62
|
-
}
|
|
63
|
-
if (options?.includeBrandedBrowsers) {
|
|
64
|
-
projects.push(...[
|
|
65
|
-
{
|
|
66
|
-
name: 'Microsoft Edge',
|
|
67
|
-
use: { ...test_1.devices['Desktop Edge'], channel: 'msedge' },
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'Google Chrome',
|
|
71
|
-
use: { ...test_1.devices['Desktop Chrome'], channel: 'chrome' },
|
|
72
|
-
},
|
|
73
|
-
]);
|
|
74
|
-
}
|
|
75
38
|
return (0, test_1.defineConfig)({
|
|
76
39
|
testDir: options?.testDir ?? './src',
|
|
77
40
|
outputDir: testResultOuputDir,
|
|
@@ -92,7 +55,6 @@ function nxE2EPreset(pathToConfig, options) {
|
|
|
92
55
|
},
|
|
93
56
|
],
|
|
94
57
|
],
|
|
95
|
-
projects,
|
|
96
58
|
});
|
|
97
59
|
}
|
|
98
60
|
exports.nxE2EPreset = nxE2EPreset;
|