@nx/playwright 21.0.0-beta.1 → 21.0.0-beta.3
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/playwright",
|
|
3
|
-
"version": "21.0.0-beta.
|
|
3
|
+
"version": "21.0.0-beta.3",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"homepage": "https://nx.dev",
|
|
6
6
|
"private": false,
|
|
@@ -35,26 +35,18 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
38
|
-
"@nx/devkit": "21.0.0-beta.
|
|
39
|
-
"@nx/eslint": "21.0.0-beta.
|
|
40
|
-
"@nx/js": "21.0.0-beta.
|
|
38
|
+
"@nx/devkit": "21.0.0-beta.3",
|
|
39
|
+
"@nx/eslint": "21.0.0-beta.3",
|
|
40
|
+
"@nx/js": "21.0.0-beta.3",
|
|
41
41
|
"tslib": "^2.3.0",
|
|
42
42
|
"minimatch": "9.0.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@playwright/test": "^1.36.0"
|
|
46
|
-
"@nx/webpack": "file:../webpack",
|
|
47
|
-
"@nx/vite": "file:../vite"
|
|
45
|
+
"@playwright/test": "^1.36.0"
|
|
48
46
|
},
|
|
49
47
|
"peerDependenciesMeta": {
|
|
50
48
|
"@playwright/test": {
|
|
51
49
|
"optional": true
|
|
52
|
-
},
|
|
53
|
-
"@nx/webpack": {
|
|
54
|
-
"optional": true
|
|
55
|
-
},
|
|
56
|
-
"@nx/vite": {
|
|
57
|
-
"optional": true
|
|
58
50
|
}
|
|
59
51
|
},
|
|
60
52
|
"executors": "./executors.json",
|
|
@@ -115,10 +115,10 @@ async function configurationGeneratorInternal(tree, rawOptions) {
|
|
|
115
115
|
name: importPath,
|
|
116
116
|
version: '0.0.1',
|
|
117
117
|
private: true,
|
|
118
|
-
nx: {
|
|
119
|
-
name: options.project,
|
|
120
|
-
},
|
|
121
118
|
};
|
|
119
|
+
if (options.project !== importPath) {
|
|
120
|
+
packageJson.nx = { name: options.project };
|
|
121
|
+
}
|
|
122
122
|
(0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
|
|
123
123
|
}
|
|
124
124
|
ignoreTestOutput(tree);
|
|
@@ -26,13 +26,13 @@ export default defineConfig({
|
|
|
26
26
|
webServer: {
|
|
27
27
|
command: '<%= webServerCommand %>',
|
|
28
28
|
url: '<%= webServerAddress %>',
|
|
29
|
-
reuseExistingServer:
|
|
29
|
+
reuseExistingServer: true,
|
|
30
30
|
cwd: workspaceRoot
|
|
31
31
|
},<% } else {%>
|
|
32
32
|
// webServer: {
|
|
33
33
|
// command: 'npm run start',
|
|
34
34
|
// url: 'http://127.0.0.1:3000',
|
|
35
|
-
// reuseExistingServer:
|
|
35
|
+
// reuseExistingServer: true,
|
|
36
36
|
// cwd: workspaceRoot,
|
|
37
37
|
// },<% } %>
|
|
38
38
|
projects: [
|
|
@@ -84,8 +84,9 @@ async function default_1(tree) {
|
|
|
84
84
|
: 'preview', projectToMigrate.configFileType === 'webpack'
|
|
85
85
|
? 'serveStaticTargetName'
|
|
86
86
|
: 'previewTargetName', projectToMigrate.configFileType === 'webpack'
|
|
87
|
-
? (
|
|
88
|
-
: (
|
|
87
|
+
? require('@nx/webpack/plugin').createNodesV2
|
|
88
|
+
: require('@nx/vite/plugin')
|
|
89
|
+
.createNodesV2)) ??
|
|
89
90
|
getServeStaticLikeTarget(tree, graph, projectToMigrate.projectName, projectToMigrate.configFileType === 'webpack'
|
|
90
91
|
? '@nx/web:file-server'
|
|
91
92
|
: '@nx/vite:preview-server');
|
|
@@ -131,14 +132,6 @@ async function default_1(tree) {
|
|
|
131
132
|
await (0, add_e2e_ci_target_defaults_1.default)(tree);
|
|
132
133
|
await (0, devkit_1.formatFiles)(tree);
|
|
133
134
|
}
|
|
134
|
-
async function getDynamicImportedModule(moduleName, error) {
|
|
135
|
-
try {
|
|
136
|
-
return (await Promise.resolve(`${moduleName}`).then(s => require(s)));
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
throw new Error(error);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
135
|
async function getServeStaticTargetNameForConfigFile(tree, pluginName, configFile, defaultTargetName, targetNamePluginOption, createNodesV2) {
|
|
143
136
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
144
137
|
const matchingPluginRegistrations = nxJson.plugins?.filter((p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName);
|
package/src/plugins/plugin.js
CHANGED
|
@@ -14,7 +14,14 @@ const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
|
14
14
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
15
15
|
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
16
16
|
function readTargetsCache(cachePath) {
|
|
17
|
-
|
|
17
|
+
try {
|
|
18
|
+
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false'
|
|
19
|
+
? (0, devkit_1.readJsonFile)(cachePath)
|
|
20
|
+
: {};
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
function writeTargetsToCache(cachePath, results) {
|
|
20
27
|
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
@@ -78,12 +85,12 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
|
|
|
78
85
|
let metadata;
|
|
79
86
|
const testOutput = getTestOutput(playwrightConfig);
|
|
80
87
|
const reporterOutputs = getReporterOutputs(playwrightConfig);
|
|
88
|
+
const webserverCommandTasks = getWebserverCommandTasks(playwrightConfig);
|
|
81
89
|
const baseTargetConfig = {
|
|
82
90
|
command: 'playwright test',
|
|
83
91
|
options: {
|
|
84
92
|
cwd: '{projectRoot}',
|
|
85
93
|
},
|
|
86
|
-
parallelism: false,
|
|
87
94
|
metadata: {
|
|
88
95
|
technologies: ['playwright'],
|
|
89
96
|
description: 'Runs Playwright Tests',
|
|
@@ -97,6 +104,12 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
|
|
|
97
104
|
},
|
|
98
105
|
},
|
|
99
106
|
};
|
|
107
|
+
if (webserverCommandTasks.length) {
|
|
108
|
+
baseTargetConfig.dependsOn = getDependsOn(webserverCommandTasks);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
baseTargetConfig.parallelism = false;
|
|
112
|
+
}
|
|
100
113
|
targets[options.targetName] = {
|
|
101
114
|
...baseTargetConfig,
|
|
102
115
|
cache: true,
|
|
@@ -290,6 +303,53 @@ function addSubfolderToOutput(output, subfolder) {
|
|
|
290
303
|
}
|
|
291
304
|
return (0, node_path_1.join)(output, subfolder);
|
|
292
305
|
}
|
|
306
|
+
function getWebserverCommandTasks(playwrightConfig) {
|
|
307
|
+
if (!playwrightConfig.webServer) {
|
|
308
|
+
return [];
|
|
309
|
+
}
|
|
310
|
+
const tasks = [];
|
|
311
|
+
const webServer = Array.isArray(playwrightConfig.webServer)
|
|
312
|
+
? playwrightConfig.webServer
|
|
313
|
+
: [playwrightConfig.webServer];
|
|
314
|
+
for (const server of webServer) {
|
|
315
|
+
if (!server.reuseExistingServer) {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
const task = parseTaskFromCommand(server.command);
|
|
319
|
+
if (task) {
|
|
320
|
+
tasks.push(task);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return tasks;
|
|
324
|
+
}
|
|
325
|
+
function parseTaskFromCommand(command) {
|
|
326
|
+
const nxRunRegex = /^(?:(?:npx|yarn|bun|pnpm|pnpm exec|pnpx) )?nx run (\S+:\S+)$/;
|
|
327
|
+
const infixRegex = /^(?:(?:npx|yarn|bun|pnpm|pnpm exec|pnpx) )?nx (\S+ \S+)$/;
|
|
328
|
+
const nxRunMatch = command.match(nxRunRegex);
|
|
329
|
+
if (nxRunMatch) {
|
|
330
|
+
const [project, target] = nxRunMatch[1].split(':');
|
|
331
|
+
return { project, target };
|
|
332
|
+
}
|
|
333
|
+
const infixMatch = command.match(infixRegex);
|
|
334
|
+
if (infixMatch) {
|
|
335
|
+
const [target, project] = infixMatch[1].split(' ');
|
|
336
|
+
return { project, target };
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
function getDependsOn(tasks) {
|
|
341
|
+
const projectsPerTask = new Map();
|
|
342
|
+
for (const { project, target } of tasks) {
|
|
343
|
+
if (!projectsPerTask.has(target)) {
|
|
344
|
+
projectsPerTask.set(target, []);
|
|
345
|
+
}
|
|
346
|
+
projectsPerTask.get(target).push(project);
|
|
347
|
+
}
|
|
348
|
+
return Array.from(projectsPerTask.entries()).map(([target, projects]) => ({
|
|
349
|
+
projects,
|
|
350
|
+
target,
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
293
353
|
function normalizeOutput(path, workspaceRoot, projectRoot) {
|
|
294
354
|
const fullProjectRoot = (0, node_path_1.resolve)(workspaceRoot, projectRoot);
|
|
295
355
|
const fullPath = (0, node_path_1.resolve)(fullProjectRoot, path);
|