@nx/playwright 16.8.0-beta.4 → 16.8.0-beta.6

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": "16.8.0-beta.4",
3
+ "version": "16.8.0-beta.6",
4
4
  "type": "commonjs",
5
5
  "homepage": "https://nx.dev",
6
6
  "private": false,
@@ -32,8 +32,8 @@
32
32
  "directory": "packages/playwright"
33
33
  },
34
34
  "dependencies": {
35
- "@nx/devkit": "16.8.0-beta.4",
36
- "@nx/linter": "16.8.0-beta.4",
35
+ "@nx/devkit": "16.8.0-beta.6",
36
+ "@nx/linter": "16.8.0-beta.6",
37
37
  "tslib": "^2.3.0"
38
38
  },
39
39
  "peerDependencies": {
@@ -56,5 +56,5 @@
56
56
  "./executors/*/schema.json": "./src/executors/*/schema.json",
57
57
  "./preset": "./src/utils/preset.js"
58
58
  },
59
- "gitHead": "c9aad2dc8c2b34531cf61549bff872e68c481e4e"
59
+ "gitHead": "0cc6ba996f2ef09f00b932c8eacf42de642457f3"
60
60
  }
@@ -1,39 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.playwrightExecutor = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const child_process_1 = require("child_process");
6
5
  const devkit_1 = require("@nx/devkit");
7
- function playwrightExecutor(options, context) {
8
- var _a, _b, _c, _d;
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- const projectRoot = (_d = (_c = (_b = (_a = context.projectGraph) === null || _a === void 0 ? void 0 : _a.nodes) === null || _b === void 0 ? void 0 : _b[context === null || context === void 0 ? void 0 : context.projectName]) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.root;
11
- if (!projectRoot) {
12
- throw new Error(`Unable to find the Project Root for ${context.projectName}. Is it set in the project.json?`);
13
- }
14
- if (!options.skipInstall) {
15
- devkit_1.output.log({
16
- title: 'Ensuring Playwright is installed.',
17
- bodyLines: ['use --skipInstall to skip installation.'],
18
- });
19
- const pmc = (0, devkit_1.getPackageManagerCommand)();
20
- (0, child_process_1.execSync)(`${pmc.exec} playwright install`, {
21
- cwd: devkit_1.workspaceRoot,
22
- stdio: 'inherit',
23
- });
24
- }
25
- const args = createArgs(options);
26
- const p = runPlaywright(args, context.root);
27
- p.stdout.on('data', (message) => {
28
- process.stdout.write(message);
6
+ async function playwrightExecutor(options, context) {
7
+ const projectRoot = context.projectGraph?.nodes?.[context?.projectName]?.data?.root;
8
+ if (!projectRoot) {
9
+ throw new Error(`Unable to find the Project Root for ${context.projectName}. Is it set in the project.json?`);
10
+ }
11
+ if (!options.skipInstall) {
12
+ devkit_1.output.log({
13
+ title: 'Ensuring Playwright is installed.',
14
+ bodyLines: ['use --skipInstall to skip installation.'],
29
15
  });
30
- p.stderr.on('data', (message) => {
31
- process.stderr.write(message);
16
+ const pmc = (0, devkit_1.getPackageManagerCommand)();
17
+ (0, child_process_1.execSync)(`${pmc.exec} playwright install`, {
18
+ cwd: devkit_1.workspaceRoot,
19
+ stdio: 'inherit',
32
20
  });
33
- return new Promise((resolve) => {
34
- p.on('close', (code) => {
35
- resolve({ success: code === 0 });
36
- });
21
+ }
22
+ const args = createArgs(options);
23
+ const p = runPlaywright(args, context.root);
24
+ p.stdout.on('data', (message) => {
25
+ process.stdout.write(message);
26
+ });
27
+ p.stderr.on('data', (message) => {
28
+ process.stderr.write(message);
29
+ });
30
+ return new Promise((resolve) => {
31
+ p.on('close', (code) => {
32
+ resolve({ success: code === 0 });
37
33
  });
38
34
  });
39
35
  }
@@ -1,67 +1,66 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configurationSchematic = exports.configurationGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const path = require("path");
7
6
  const init_1 = require("../init/init");
8
7
  const add_linter_1 = require("../../utils/add-linter");
9
- function configurationGenerator(tree, options) {
10
- var _a, _b;
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const tasks = [];
13
- tasks.push(yield (0, init_1.default)(tree, {
14
- skipFormat: true,
15
- skipPackageJson: options.skipPackageJson,
16
- }));
17
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
18
- (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), projectConfig.root, Object.assign({ offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root), projectRoot: projectConfig.root, webServerCommand: (_a = options.webServerCommand) !== null && _a !== void 0 ? _a : null, webServerAddress: (_b = options.webServerAddress) !== null && _b !== void 0 ? _b : null }, options));
19
- addE2eTarget(tree, options);
20
- setupE2ETargetDefaults(tree);
21
- tasks.push(yield (0, add_linter_1.addLinterToPlaywrightProject)(tree, {
22
- project: options.project,
23
- linter: options.linter,
24
- skipPackageJson: options.skipPackageJson,
25
- js: options.js,
26
- directory: options.directory,
27
- setParserOptionsProject: options.setParserOptionsProject,
28
- rootProject: projectConfig.root === '.',
29
- }));
30
- if (options.js) {
31
- (0, devkit_1.toJS)(tree);
32
- }
33
- if (!options.skipFormat) {
34
- yield (0, devkit_1.formatFiles)(tree);
35
- }
36
- return (0, devkit_1.runTasksInSerial)(...tasks);
8
+ async function configurationGenerator(tree, options) {
9
+ const tasks = [];
10
+ tasks.push(await (0, init_1.default)(tree, {
11
+ skipFormat: true,
12
+ skipPackageJson: options.skipPackageJson,
13
+ }));
14
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
15
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), projectConfig.root, {
16
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root),
17
+ projectRoot: projectConfig.root,
18
+ webServerCommand: options.webServerCommand ?? null,
19
+ webServerAddress: options.webServerAddress ?? null,
20
+ ...options,
37
21
  });
22
+ addE2eTarget(tree, options);
23
+ setupE2ETargetDefaults(tree);
24
+ tasks.push(await (0, add_linter_1.addLinterToPlaywrightProject)(tree, {
25
+ project: options.project,
26
+ linter: options.linter,
27
+ skipPackageJson: options.skipPackageJson,
28
+ js: options.js,
29
+ directory: options.directory,
30
+ setParserOptionsProject: options.setParserOptionsProject,
31
+ rootProject: projectConfig.root === '.',
32
+ }));
33
+ if (options.js) {
34
+ (0, devkit_1.toJS)(tree);
35
+ }
36
+ if (!options.skipFormat) {
37
+ await (0, devkit_1.formatFiles)(tree);
38
+ }
39
+ return (0, devkit_1.runTasksInSerial)(...tasks);
38
40
  }
39
41
  exports.configurationGenerator = configurationGenerator;
40
42
  function setupE2ETargetDefaults(tree) {
41
- var _a, _b, _c, _d;
42
- var _e, _f;
43
43
  const nxJson = (0, devkit_1.readNxJson)(tree);
44
44
  if (!nxJson.namedInputs) {
45
45
  return;
46
46
  }
47
47
  // E2e targets depend on all their project's sources + production sources of dependencies
48
- (_a = nxJson.targetDefaults) !== null && _a !== void 0 ? _a : (nxJson.targetDefaults = {});
49
- const productionFileSet = !!((_b = nxJson.namedInputs) === null || _b === void 0 ? void 0 : _b.production);
50
- (_c = (_e = nxJson.targetDefaults).e2e) !== null && _c !== void 0 ? _c : (_e.e2e = {});
51
- (_d = (_f = nxJson.targetDefaults.e2e).inputs) !== null && _d !== void 0 ? _d : (_f.inputs = [
48
+ nxJson.targetDefaults ??= {};
49
+ const productionFileSet = !!nxJson.namedInputs?.production;
50
+ nxJson.targetDefaults.e2e ??= {};
51
+ nxJson.targetDefaults.e2e.inputs ??= [
52
52
  'default',
53
53
  productionFileSet ? '^production' : '^default',
54
- ]);
54
+ ];
55
55
  (0, devkit_1.updateNxJson)(tree, nxJson);
56
56
  }
57
57
  function addE2eTarget(tree, options) {
58
- var _a, _b;
59
58
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
60
- if ((_a = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.targets) === null || _a === void 0 ? void 0 : _a.e2e) {
59
+ if (projectConfig?.targets?.e2e) {
61
60
  throw new Error(`Project ${options.project} already has an e2e target.
62
61
  Rename or remove the existing e2e target.`);
63
62
  }
64
- (_b = projectConfig.targets) !== null && _b !== void 0 ? _b : (projectConfig.targets = {});
63
+ projectConfig.targets ??= {};
65
64
  projectConfig.targets.e2e = {
66
65
  executor: '@nx/playwright:playwright',
67
66
  outputs: [`{workspaceRoot}/dist/.playwright/${projectConfig.root}`],
@@ -1,49 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initSchematic = exports.initGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const versions_1 = require("../../utils/versions");
7
6
  const child_process_1 = require("child_process");
8
- function initGenerator(tree, options) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- const tasks = [];
11
- if (!options.skipPackageJson) {
12
- tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
13
- '@nx/playwright': versions_1.nxVersion,
14
- '@playwright/test': versions_1.playwrightVersion,
15
- }));
16
- }
17
- if (!options.skipFormat) {
18
- yield (0, devkit_1.formatFiles)(tree);
19
- }
20
- if (tree.exists('.vscode/extensions.json')) {
21
- (0, devkit_1.updateJson)(tree, '.vscode/extensions.json', (json) => {
22
- var _a;
23
- (_a = json.recommendations) !== null && _a !== void 0 ? _a : (json.recommendations = []);
24
- const recs = new Set(json.recommendations);
25
- recs.add('ms-playwright.playwright');
26
- json.recommendations = Array.from(recs);
27
- return json;
7
+ async function initGenerator(tree, options) {
8
+ const tasks = [];
9
+ if (!options.skipPackageJson) {
10
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
11
+ '@nx/playwright': versions_1.nxVersion,
12
+ '@playwright/test': versions_1.playwrightVersion,
13
+ }));
14
+ }
15
+ if (!options.skipFormat) {
16
+ await (0, devkit_1.formatFiles)(tree);
17
+ }
18
+ if (tree.exists('.vscode/extensions.json')) {
19
+ (0, devkit_1.updateJson)(tree, '.vscode/extensions.json', (json) => {
20
+ json.recommendations ??= [];
21
+ const recs = new Set(json.recommendations);
22
+ recs.add('ms-playwright.playwright');
23
+ json.recommendations = Array.from(recs);
24
+ return json;
25
+ });
26
+ }
27
+ else {
28
+ tree.write('.vscode/extensions.json', JSON.stringify({
29
+ recommendations: ['ms-playwright.playwright'],
30
+ }, null, 2));
31
+ }
32
+ if (!options.skipInstall) {
33
+ tasks.push(() => {
34
+ devkit_1.output.log({
35
+ title: 'Ensuring Playwright is installed.',
36
+ bodyLines: ['use --skipInstall to skip installation.'],
28
37
  });
29
- }
30
- else {
31
- tree.write('.vscode/extensions.json', JSON.stringify({
32
- recommendations: ['ms-playwright.playwright'],
33
- }, null, 2));
34
- }
35
- if (!options.skipInstall) {
36
- tasks.push(() => {
37
- devkit_1.output.log({
38
- title: 'Ensuring Playwright is installed.',
39
- bodyLines: ['use --skipInstall to skip installation.'],
40
- });
41
- const pmc = (0, devkit_1.getPackageManagerCommand)();
42
- (0, child_process_1.execSync)(`${pmc.exec} playwright install`, { cwd: devkit_1.workspaceRoot });
43
- });
44
- }
45
- return (0, devkit_1.runTasksInSerial)(...tasks);
46
- });
38
+ const pmc = (0, devkit_1.getPackageManagerCommand)();
39
+ (0, child_process_1.execSync)(`${pmc.exec} playwright install`, { cwd: devkit_1.workspaceRoot });
40
+ });
41
+ }
42
+ return (0, devkit_1.runTasksInSerial)(...tasks);
47
43
  }
48
44
  exports.initGenerator = initGenerator;
49
45
  exports.default = initGenerator;
@@ -1,57 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLinterToPlaywrightProject = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const linter_1 = require("@nx/linter");
7
6
  const global_eslint_config_1 = require("@nx/linter/src/generators/init/global-eslint-config");
8
7
  const versions_1 = require("./versions");
9
8
  const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
10
- function addLinterToPlaywrightProject(tree, options) {
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- if (options.linter === linter_1.Linter.None) {
13
- return () => { };
14
- }
15
- const tasks = [];
16
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
17
- const eslintFile = (0, eslint_file_1.findEslintFile)(tree, projectConfig.root);
18
- if (!eslintFile) {
19
- tasks.push(yield (0, linter_1.lintProjectGenerator)(tree, {
20
- project: options.project,
21
- linter: options.linter,
22
- skipFormat: true,
23
- tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
24
- eslintFilePatterns: [
25
- `${projectConfig.root}/**/*.${options.js ? 'js' : '{js,ts}'}`,
26
- ],
27
- setParserOptionsProject: options.setParserOptionsProject,
28
- skipPackageJson: options.skipPackageJson,
29
- rootProject: options.rootProject,
30
- }));
31
- }
32
- if (!options.linter || options.linter !== linter_1.Linter.EsLint) {
33
- return (0, devkit_1.runTasksInSerial)(...tasks);
34
- }
35
- tasks.push(!options.skipPackageJson
36
- ? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'eslint-plugin-playwright': versions_1.eslintPluginPlaywrightVersion })
37
- : () => { });
38
- if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
39
- (0, eslint_file_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:playwright/recommended');
40
- if (options.rootProject) {
41
- (0, eslint_file_1.addPluginsToLintConfig)(tree, projectConfig.root, '@nx');
42
- (0, eslint_file_1.addOverrideToLintConfig)(tree, projectConfig.root, global_eslint_config_1.javaScriptOverride);
43
- }
44
- (0, eslint_file_1.addOverrideToLintConfig)(tree, projectConfig.root, {
45
- files: [`${options.directory}/**/*.{ts,js,tsx,jsx}`],
46
- parserOptions: !options.setParserOptionsProject
47
- ? undefined
48
- : {
49
- project: `${projectConfig.root}/tsconfig.*?.json`,
50
- },
51
- rules: {},
52
- });
53
- }
9
+ async function addLinterToPlaywrightProject(tree, options) {
10
+ if (options.linter === linter_1.Linter.None) {
11
+ return () => { };
12
+ }
13
+ const tasks = [];
14
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
15
+ const eslintFile = (0, eslint_file_1.findEslintFile)(tree, projectConfig.root);
16
+ if (!eslintFile) {
17
+ tasks.push(await (0, linter_1.lintProjectGenerator)(tree, {
18
+ project: options.project,
19
+ linter: options.linter,
20
+ skipFormat: true,
21
+ tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
22
+ eslintFilePatterns: [
23
+ `${projectConfig.root}/**/*.${options.js ? 'js' : '{js,ts}'}`,
24
+ ],
25
+ setParserOptionsProject: options.setParserOptionsProject,
26
+ skipPackageJson: options.skipPackageJson,
27
+ rootProject: options.rootProject,
28
+ }));
29
+ }
30
+ if (!options.linter || options.linter !== linter_1.Linter.EsLint) {
54
31
  return (0, devkit_1.runTasksInSerial)(...tasks);
55
- });
32
+ }
33
+ tasks.push(!options.skipPackageJson
34
+ ? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'eslint-plugin-playwright': versions_1.eslintPluginPlaywrightVersion })
35
+ : () => { });
36
+ if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
37
+ (0, eslint_file_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:playwright/recommended');
38
+ if (options.rootProject) {
39
+ (0, eslint_file_1.addPluginsToLintConfig)(tree, projectConfig.root, '@nx');
40
+ (0, eslint_file_1.addOverrideToLintConfig)(tree, projectConfig.root, global_eslint_config_1.javaScriptOverride);
41
+ }
42
+ (0, eslint_file_1.addOverrideToLintConfig)(tree, projectConfig.root, {
43
+ files: [`${options.directory}/**/*.{ts,js,tsx,jsx}`],
44
+ parserOptions: !options.setParserOptionsProject
45
+ ? undefined
46
+ : {
47
+ project: `${projectConfig.root}/tsconfig.*?.json`,
48
+ },
49
+ rules: {},
50
+ });
51
+ }
52
+ return (0, devkit_1.runTasksInSerial)(...tasks);
56
53
  }
57
54
  exports.addLinterToPlaywrightProject = addLinterToPlaywrightProject;
@@ -27,7 +27,6 @@ const test_1 = require("@playwright/test");
27
27
  * @param options optional configuration options
28
28
  */
29
29
  function nxE2EPreset(pathToConfig, options) {
30
- var _a;
31
30
  const normalizedPath = (0, node_fs_1.lstatSync)(pathToConfig).isDirectory()
32
31
  ? pathToConfig
33
32
  : (0, node_path_1.dirname)(pathToConfig);
@@ -38,43 +37,43 @@ function nxE2EPreset(pathToConfig, options) {
38
37
  const projects = [
39
38
  {
40
39
  name: 'chromium',
41
- use: Object.assign({}, test_1.devices['Desktop Chrome']),
40
+ use: { ...test_1.devices['Desktop Chrome'] },
42
41
  },
43
42
  {
44
43
  name: 'firefox',
45
- use: Object.assign({}, test_1.devices['Desktop Firefox']),
44
+ use: { ...test_1.devices['Desktop Firefox'] },
46
45
  },
47
46
  {
48
47
  name: 'webkit',
49
- use: Object.assign({}, test_1.devices['Desktop Safari']),
48
+ use: { ...test_1.devices['Desktop Safari'] },
50
49
  },
51
50
  ];
52
- if (options === null || options === void 0 ? void 0 : options.includeMobileBrowsers) {
51
+ if (options?.includeMobileBrowsers) {
53
52
  projects.push(...[
54
53
  {
55
54
  name: 'Mobile Chrome',
56
- use: Object.assign({}, test_1.devices['Pixel 5']),
55
+ use: { ...test_1.devices['Pixel 5'] },
57
56
  },
58
57
  {
59
58
  name: 'Mobile Safari',
60
- use: Object.assign({}, test_1.devices['iPhone 12']),
59
+ use: { ...test_1.devices['iPhone 12'] },
61
60
  },
62
61
  ]);
63
62
  }
64
- if (options === null || options === void 0 ? void 0 : options.includeBrandedBrowsers) {
63
+ if (options?.includeBrandedBrowsers) {
65
64
  projects.push(...[
66
65
  {
67
66
  name: 'Microsoft Edge',
68
- use: Object.assign(Object.assign({}, test_1.devices['Desktop Edge']), { channel: 'msedge' }),
67
+ use: { ...test_1.devices['Desktop Edge'], channel: 'msedge' },
69
68
  },
70
69
  {
71
70
  name: 'Google Chrome',
72
- use: Object.assign(Object.assign({}, test_1.devices['Desktop Chrome']), { channel: 'chrome' }),
71
+ use: { ...test_1.devices['Desktop Chrome'], channel: 'chrome' },
73
72
  },
74
73
  ]);
75
74
  }
76
75
  return (0, test_1.defineConfig)({
77
- testDir: (_a = options === null || options === void 0 ? void 0 : options.testDir) !== null && _a !== void 0 ? _a : './src',
76
+ testDir: options?.testDir ?? './src',
78
77
  outputDir: testResultOuputDir,
79
78
  /* Run tests in files in parallel */
80
79
  fullyParallel: true,