@nx/playwright 18.3.0-beta.0 → 18.3.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/playwright",
3
- "version": "18.3.0-beta.0",
3
+ "version": "18.3.0-beta.2",
4
4
  "type": "commonjs",
5
5
  "homepage": "https://nx.dev",
6
6
  "private": false,
@@ -33,9 +33,9 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@phenomnomnominal/tsquery": "~5.0.1",
36
- "@nx/devkit": "18.3.0-beta.0",
37
- "@nx/eslint": "18.3.0-beta.0",
38
- "@nx/js": "18.3.0-beta.0",
36
+ "@nx/devkit": "18.3.0-beta.2",
37
+ "@nx/eslint": "18.3.0-beta.2",
38
+ "@nx/js": "18.3.0-beta.2",
39
39
  "tslib": "^2.3.0",
40
40
  "minimatch": "9.0.3"
41
41
  },
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initGeneratorInternal = exports.initGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
5
+ const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
6
6
  const plugin_1 = require("../../plugins/plugin");
7
7
  const versions_1 = require("../../utils/versions");
8
8
  function initGenerator(tree, options) {
@@ -22,10 +22,7 @@ async function initGeneratorInternal(tree, options) {
22
22
  }, undefined, options.keepExistingVersions));
23
23
  }
24
24
  if (options.addPlugin) {
25
- addPlugin(tree);
26
- }
27
- if (options.updatePackageScripts) {
28
- await (0, update_package_scripts_1.updatePackageScripts)(tree, plugin_1.createNodes);
25
+ await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/playwright/plugin', plugin_1.createNodes, { targetName: ['e2e', 'playwright:e2e', 'playwright-e2e'] }, options.updatePackageScripts);
29
26
  }
30
27
  if (!options.skipFormat) {
31
28
  await (0, devkit_1.formatFiles)(tree);
@@ -33,19 +30,4 @@ async function initGeneratorInternal(tree, options) {
33
30
  return (0, devkit_1.runTasksInSerial)(...tasks);
34
31
  }
35
32
  exports.initGeneratorInternal = initGeneratorInternal;
36
- function addPlugin(tree) {
37
- const nxJson = (0, devkit_1.readNxJson)(tree);
38
- nxJson.plugins ??= [];
39
- if (!nxJson.plugins.some((p) => typeof p === 'string'
40
- ? p === '@nx/playwright/plugin'
41
- : p.plugin === '@nx/playwright/plugin')) {
42
- nxJson.plugins.push({
43
- plugin: '@nx/playwright/plugin',
44
- options: {
45
- targetName: 'e2e',
46
- },
47
- });
48
- (0, devkit_1.updateNxJson)(tree, nxJson);
49
- }
50
- }
51
33
  exports.default = initGenerator;
@@ -39,14 +39,15 @@ exports.createNodes = [
39
39
  const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
40
40
  (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
41
41
  ]);
42
- const targets = targetsCache[hash] ??
42
+ const { targets, metadata } = targetsCache[hash] ??
43
43
  (await buildPlaywrightTargets(configFilePath, projectRoot, normalizedOptions, context));
44
- calculatedTargets[hash] = targets;
44
+ calculatedTargets[hash] = { targets, metadata };
45
45
  return {
46
46
  projects: {
47
47
  [projectRoot]: {
48
48
  root: projectRoot,
49
49
  targets,
50
+ metadata,
50
51
  },
51
52
  },
52
53
  };
@@ -60,11 +61,16 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
60
61
  const playwrightConfig = await (0, config_utils_1.loadConfigFile)((0, path_1.join)(context.workspaceRoot, configFilePath));
61
62
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
62
63
  const targets = {};
64
+ let metadata;
63
65
  const baseTargetConfig = {
64
66
  command: 'playwright test',
65
67
  options: {
66
68
  cwd: '{projectRoot}',
67
69
  },
70
+ metadata: {
71
+ technologies: ['playwright'],
72
+ description: 'Runs Playwright Tests',
73
+ },
68
74
  };
69
75
  targets[options.targetName] = {
70
76
  ...baseTargetConfig,
@@ -83,6 +89,9 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
83
89
  : ['default', '^default'],
84
90
  outputs: getOutputs(projectRoot, playwrightConfig),
85
91
  };
92
+ const groupName = 'E2E (CI)';
93
+ metadata = { targetGroups: { [groupName]: [] } };
94
+ const ciTargetGroup = metadata.targetGroups[groupName];
86
95
  const testDir = playwrightConfig.testDir
87
96
  ? (0, devkit_1.joinPathFragments)(projectRoot, playwrightConfig.testDir)
88
97
  : projectRoot;
@@ -90,11 +99,16 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
90
99
  playwrightConfig.testMatch ??= '**/*.@(spec|test).?(c|m)[jt]s?(x)';
91
100
  const dependsOn = [];
92
101
  forEachTestFile((testFile) => {
93
- const relativeToProjectRoot = (0, devkit_1.normalizePath)((0, path_1.relative)(projectRoot, testFile));
94
- const targetName = `${options.ciTargetName}--${relativeToProjectRoot}`;
102
+ const relativeSpecFilePath = (0, devkit_1.normalizePath)((0, path_1.relative)(projectRoot, testFile));
103
+ const targetName = `${options.ciTargetName}--${relativeSpecFilePath}`;
104
+ ciTargetGroup.push(targetName);
95
105
  targets[targetName] = {
96
106
  ...ciBaseTargetConfig,
97
- command: `${baseTargetConfig.command} ${relativeToProjectRoot}`,
107
+ command: `${baseTargetConfig.command} ${relativeSpecFilePath}`,
108
+ metadata: {
109
+ technologies: ['playwright'],
110
+ description: `Runs Playwright Tests in ${relativeSpecFilePath} in CI`,
111
+ },
98
112
  };
99
113
  dependsOn.push({
100
114
  target: targetName,
@@ -113,11 +127,16 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
113
127
  inputs: ciBaseTargetConfig.inputs,
114
128
  outputs: ciBaseTargetConfig.outputs,
115
129
  dependsOn,
130
+ metadata: {
131
+ technologies: ['playwright'],
132
+ description: 'Runs Playwright Tests in CI',
133
+ },
116
134
  };
135
+ ciTargetGroup.push(options.ciTargetName);
117
136
  }
118
- return targets;
137
+ return { targets, metadata };
119
138
  }
120
- async function forEachTestFile(cb, opts) {
139
+ function forEachTestFile(cb, opts) {
121
140
  const files = (0, workspace_context_1.getFilesInDirectoryUsingContext)(opts.context.workspaceRoot, opts.path);
122
141
  const matcher = createMatcher(opts.config.testMatch);
123
142
  const ignoredMatcher = opts.config.testIgnore