@nx/playwright 20.4.0-canary.20250116-a127177 → 20.4.0-canary.20250118-ee135b2

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": "20.4.0-canary.20250116-a127177",
3
+ "version": "20.4.0-canary.20250118-ee135b2",
4
4
  "type": "commonjs",
5
5
  "homepage": "https://nx.dev",
6
6
  "private": false,
@@ -35,11 +35,11 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@phenomnomnominal/tsquery": "~5.0.1",
38
- "@nx/devkit": "20.4.0-canary.20250116-a127177",
39
- "@nx/eslint": "20.4.0-canary.20250116-a127177",
40
- "@nx/webpack": "20.4.0-canary.20250116-a127177",
41
- "@nx/vite": "20.4.0-canary.20250116-a127177",
42
- "@nx/js": "20.4.0-canary.20250116-a127177",
38
+ "@nx/devkit": "20.4.0-canary.20250118-ee135b2",
39
+ "@nx/eslint": "20.4.0-canary.20250118-ee135b2",
40
+ "@nx/webpack": "20.4.0-canary.20250118-ee135b2",
41
+ "@nx/vite": "20.4.0-canary.20250118-ee135b2",
42
+ "@nx/js": "20.4.0-canary.20250118-ee135b2",
43
43
  "tslib": "^2.3.0",
44
44
  "minimatch": "9.0.3"
45
45
  },
@@ -4,6 +4,7 @@ exports.configurationGenerator = configurationGenerator;
4
4
  exports.configurationGeneratorInternal = configurationGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
7
+ const prompt_1 = require("@nx/devkit/src/generators/prompt");
7
8
  const js_1 = require("@nx/js");
8
9
  const generator_prompts_1 = require("@nx/js/src/utils/generator-prompts");
9
10
  const package_manager_workspaces_1 = require("@nx/js/src/utils/package-manager-workspaces");
@@ -36,7 +37,36 @@ async function configurationGeneratorInternal(tree, rawOptions) {
36
37
  });
37
38
  const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
38
39
  const tsconfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json');
39
- if (!tree.exists(tsconfigPath)) {
40
+ if (tree.exists(tsconfigPath)) {
41
+ if (isTsSolutionSetup) {
42
+ const tsconfig = {
43
+ extends: (0, js_1.getRelativePathToRootTsConfig)(tree, projectConfig.root),
44
+ compilerOptions: {
45
+ allowJs: true,
46
+ outDir: 'out-tsc/playwright',
47
+ sourceMap: false,
48
+ },
49
+ include: [
50
+ (0, devkit_1.joinPathFragments)(options.directory, '**/*.ts'),
51
+ (0, devkit_1.joinPathFragments)(options.directory, '**/*.js'),
52
+ 'playwright.config.ts',
53
+ ],
54
+ exclude: ['out-tsc', 'test-output'],
55
+ };
56
+ // skip eslint from typechecking since it extends from root file that is outside rootDir
57
+ if (options.linter === 'eslint') {
58
+ tsconfig.exclude.push('eslint.config.js', 'eslint.config.mjs', 'eslint.config.cjs');
59
+ }
60
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.e2e.json'), tsconfig);
61
+ (0, devkit_1.updateJson)(tree, tsconfigPath, (json) => {
62
+ // add the project tsconfig to the workspace root tsconfig.json references
63
+ json.references ??= [];
64
+ json.references.push({ path: './tsconfig.e2e.json' });
65
+ return json;
66
+ });
67
+ }
68
+ }
69
+ else {
40
70
  const tsconfig = {
41
71
  extends: (0, js_1.getRelativePathToRootTsConfig)(tree, projectConfig.root),
42
72
  compilerOptions: {
@@ -141,6 +171,11 @@ async function normalizeOptions(tree, options) {
141
171
  (process.env.NX_ADD_PLUGINS !== 'false' &&
142
172
  nxJson.useInferencePlugins !== false);
143
173
  const linter = await (0, generator_prompts_1.normalizeLinterOption)(tree, options.linter);
174
+ if (!options.webServerCommand || !options.webServerAddress) {
175
+ const { webServerCommand, webServerAddress } = await promptForMissingServeData(options.project);
176
+ options.webServerCommand = webServerCommand;
177
+ options.webServerAddress = webServerAddress;
178
+ }
144
179
  return {
145
180
  ...options,
146
181
  addPlugin,
@@ -148,6 +183,29 @@ async function normalizeOptions(tree, options) {
148
183
  directory: options.directory ?? 'e2e',
149
184
  };
150
185
  }
186
+ async function promptForMissingServeData(projectName) {
187
+ const { command, port } = await (0, prompt_1.promptWhenInteractive)([
188
+ {
189
+ type: 'input',
190
+ name: 'command',
191
+ message: 'What command should be run to serve the application locally?',
192
+ initial: `npx nx serve ${projectName}`,
193
+ },
194
+ {
195
+ type: 'numeral',
196
+ name: 'port',
197
+ message: 'What port will the application be served on?',
198
+ initial: 3000,
199
+ },
200
+ ], {
201
+ command: `npx nx serve ${projectName}`,
202
+ port: 3000,
203
+ });
204
+ return {
205
+ webServerCommand: command,
206
+ webServerAddress: `http://localhost:${port}`,
207
+ };
208
+ }
151
209
  function getBrowsersInstallTask() {
152
210
  return () => {
153
211
  devkit_1.output.log({
@@ -1,7 +1,6 @@
1
1
  import { defineConfig, devices } from '@playwright/test';
2
2
  import { nxE2EPreset } from '@nx/playwright/preset';
3
- <% if(!webServerCommand || !webServerAddress) { %>// eslint-disable-next-line @typescript-eslint/no-unused-vars <% } %>
4
- import { workspaceRoot } from '@nx/devkit';
3
+ <% if (webServerCommand && webServerAddress) { %>import { workspaceRoot } from '@nx/devkit';<% } %>
5
4
 
6
5
  // For CI, you may want to set BASE_URL to the deployed application.
7
6
  const baseURL = process.env['BASE_URL'] || '<% if(webServerAddress) {%><%= webServerAddress %><% } else {%>http://localhost:3000<% } %>';
@@ -54,7 +54,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
54
54
  return {};
55
55
  }
56
56
  const normalizedOptions = normalizeOptions(options);
57
- const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
57
+ const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, normalizedOptions, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
58
58
  targetsCache[hash] ??= await buildPlaywrightTargets(configFilePath, projectRoot, normalizedOptions, context);
59
59
  const { targets, metadata } = targetsCache[hash];
60
60
  return {
@@ -227,8 +227,8 @@ function createMatcher(pattern) {
227
227
  function normalizeOptions(options) {
228
228
  return {
229
229
  ...options,
230
- targetName: options.targetName ?? 'e2e',
231
- ciTargetName: options.ciTargetName ?? 'e2e-ci',
230
+ targetName: options?.targetName ?? 'e2e',
231
+ ciTargetName: options?.ciTargetName ?? 'e2e-ci',
232
232
  };
233
233
  }
234
234
  function getTestOutput(playwrightConfig) {