@nx/playwright 23.0.0-beta.15 → 23.0.0-beta.17
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.d.ts.map +1 -1
- package/src/generators/configuration/configuration.js +20 -7
- package/src/generators/configuration/files/{playwright.config.ts.template → playwright.config.mts.template} +10 -3
- package/src/utils/add-linter.js +11 -13
- package/src/utils/preset.d.ts +4 -1
- package/src/utils/preset.d.ts.map +1 -1
- package/src/utils/preset.js +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/playwright",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.17",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"homepage": "https://nx.dev",
|
|
6
6
|
"private": false,
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"directory": "packages/playwright"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "23.0.0-beta.
|
|
38
|
-
"@nx/eslint": "23.0.0-beta.
|
|
39
|
-
"@nx/js": "23.0.0-beta.
|
|
37
|
+
"@nx/devkit": "23.0.0-beta.17",
|
|
38
|
+
"@nx/eslint": "23.0.0-beta.17",
|
|
39
|
+
"@nx/js": "23.0.0-beta.17",
|
|
40
40
|
"tslib": "^2.3.0",
|
|
41
41
|
"minimatch": "10.2.5",
|
|
42
42
|
"semver": "^7.6.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"nx": "23.0.0-beta.
|
|
45
|
+
"nx": "23.0.0-beta.17"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@playwright/test": "^1.36.0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/playwright/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,iBAAiB,EAWjB,IAAI,EAML,MAAM,YAAY,CAAC;AAiBpB,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,UAAU,CAAC;AAGlB,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,8BAGtC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,4BAA4B,
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/playwright/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,iBAAiB,EAWjB,IAAI,EAML,MAAM,YAAY,CAAC;AAiBpB,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,UAAU,CAAC;AAGlB,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,8BAGtC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,4BAA4B,8BA6NzC;AA2KD,eAAe,sBAAsB,CAAC"}
|
|
@@ -14,7 +14,7 @@ const add_linter_1 = require("../../utils/add-linter");
|
|
|
14
14
|
const assert_supported_playwright_version_1 = require("../../utils/assert-supported-playwright-version");
|
|
15
15
|
const versions_1 = require("../../utils/versions");
|
|
16
16
|
const init_1 = require("../init/init");
|
|
17
|
-
const
|
|
17
|
+
const internal_3 = require("@nx/eslint/internal");
|
|
18
18
|
function configurationGenerator(tree, options) {
|
|
19
19
|
return configurationGeneratorInternal(tree, { addPlugin: false, ...options });
|
|
20
20
|
}
|
|
@@ -29,14 +29,25 @@ async function configurationGeneratorInternal(tree, rawOptions) {
|
|
|
29
29
|
}));
|
|
30
30
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
31
31
|
const offsetFromProjectRoot = (0, devkit_1.offsetFromRoot)(projectConfig.root);
|
|
32
|
+
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
|
|
33
|
+
// Always emit `playwright.config.mts`. Node forces `.mts` to ESM
|
|
34
|
+
// regardless of workspace `type`, so Playwright's runtime routes it
|
|
35
|
+
// through the ESM loader (`requireOrImport` -> dynamic `import()`),
|
|
36
|
+
// bypassing the pirates CJS-compile path that breaks ESM-shape `.ts`
|
|
37
|
+
// configs. Nx's native TS strip loads `.mts` directly via `loadTsFile`.
|
|
38
|
+
// Playwright's configLoader auto-discovers `.mts` (extension list at
|
|
39
|
+
// configLoader.js:313 is `.ts/.js/.mts/.mjs/.cts/.cjs`).
|
|
32
40
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), projectConfig.root, {
|
|
33
41
|
offsetFromRoot: offsetFromProjectRoot,
|
|
34
42
|
projectRoot: projectConfig.root,
|
|
35
43
|
webServerCommand: options.webServerCommand ?? null,
|
|
36
44
|
webServerAddress: options.webServerAddress ?? null,
|
|
45
|
+
isTsSolutionSetup,
|
|
37
46
|
...options,
|
|
38
47
|
});
|
|
39
|
-
const
|
|
48
|
+
const playwrightConfigFile = options.js
|
|
49
|
+
? 'playwright.config.mjs'
|
|
50
|
+
: 'playwright.config.mts';
|
|
40
51
|
const tsconfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json');
|
|
41
52
|
if (tree.exists(tsconfigPath)) {
|
|
42
53
|
if (isTsSolutionSetup) {
|
|
@@ -50,7 +61,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
|
|
|
50
61
|
include: [
|
|
51
62
|
(0, devkit_1.joinPathFragments)(options.directory, '**/*.ts'),
|
|
52
63
|
(0, devkit_1.joinPathFragments)(options.directory, '**/*.js'),
|
|
53
|
-
|
|
64
|
+
playwrightConfigFile,
|
|
54
65
|
],
|
|
55
66
|
exclude: ['out-tsc', 'test-output'],
|
|
56
67
|
};
|
|
@@ -78,7 +89,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
|
|
|
78
89
|
include: [
|
|
79
90
|
'**/*.ts',
|
|
80
91
|
'**/*.js',
|
|
81
|
-
|
|
92
|
+
playwrightConfigFile,
|
|
82
93
|
'src/**/*.spec.ts',
|
|
83
94
|
'src/**/*.spec.js',
|
|
84
95
|
'src/**/*.test.ts',
|
|
@@ -144,7 +155,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
|
|
|
144
155
|
}));
|
|
145
156
|
if (options.js) {
|
|
146
157
|
const { ModuleKind } = (0, internal_2.ensureTypescript)();
|
|
147
|
-
(0, devkit_1.toJS)(tree, { extension: '.
|
|
158
|
+
(0, devkit_1.toJS)(tree, { extension: '.mjs', module: ModuleKind.ESNext });
|
|
148
159
|
}
|
|
149
160
|
recommendVsCodeExtensions(tree);
|
|
150
161
|
if (!options.skipPackageJson) {
|
|
@@ -279,7 +290,9 @@ Rename or remove the existing e2e target.`);
|
|
|
279
290
|
executor: '@nx/playwright:playwright',
|
|
280
291
|
outputs: [`{workspaceRoot}/dist/.playwright/${projectConfig.root}`],
|
|
281
292
|
options: {
|
|
282
|
-
|
|
293
|
+
// Generator emits `playwright.config.mts` (`.mjs` for `--js`) so the
|
|
294
|
+
// legacy executor's `--config` flag must point at the same extension.
|
|
295
|
+
config: `${projectConfig.root}/playwright.config.${options.js ? 'mjs' : 'mts'}`,
|
|
283
296
|
},
|
|
284
297
|
};
|
|
285
298
|
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
@@ -287,7 +300,7 @@ Rename or remove the existing e2e target.`);
|
|
|
287
300
|
function ignoreTestOutput(tree, options) {
|
|
288
301
|
// Make sure playwright outputs are not linted.
|
|
289
302
|
if (options.linter === 'eslint') {
|
|
290
|
-
(0,
|
|
303
|
+
(0, internal_3.addIgnoresToLintConfig)(tree, '', ['**/test-output']);
|
|
291
304
|
}
|
|
292
305
|
// Handle gitignore
|
|
293
306
|
if (!tree.exists('.gitignore')) {
|
|
@@ -9,13 +9,20 @@ const baseURL = process.env['BASE_URL'] || '<% if(webServerAddress) {%><%= webSe
|
|
|
9
9
|
* Read environment variables from file.
|
|
10
10
|
* https://github.com/motdotla/dotenv
|
|
11
11
|
*/
|
|
12
|
-
//
|
|
12
|
+
// import 'dotenv/config';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* See https://playwright.dev/docs/test-configuration.
|
|
16
|
+
*
|
|
17
|
+
* Generated as a .mts file so Node forces ESM regardless of workspace
|
|
18
|
+
* `type`. Playwright routes `.mts` through its ESM loader (dynamic import,
|
|
19
|
+
* bypassing the pirates CJS-compile path), and Nx's native TS strip loads
|
|
20
|
+
* `.mts` directly. Playwright's configLoader auto-discovers
|
|
21
|
+
* `playwright.config.mts` via its extension list
|
|
22
|
+
* (.ts/.js/.mts/.mjs/.cts/.cjs).
|
|
16
23
|
*/
|
|
17
24
|
export default defineConfig({
|
|
18
|
-
...nxE2EPreset(
|
|
25
|
+
...nxE2EPreset(import.meta.dirname, { testDir: './<%= directory %>' }),
|
|
19
26
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
20
27
|
use: {
|
|
21
28
|
baseURL,
|
|
@@ -50,7 +57,7 @@ export default defineConfig({
|
|
|
50
57
|
name: "webkit",
|
|
51
58
|
use: { ...devices["Desktop Safari"] },
|
|
52
59
|
},
|
|
53
|
-
|
|
60
|
+
|
|
54
61
|
// Uncomment for mobile browsers support
|
|
55
62
|
/* {
|
|
56
63
|
name: 'Mobile Chrome',
|
package/src/utils/add-linter.js
CHANGED
|
@@ -3,17 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addLinterToPlaywrightProject = addLinterToPlaywrightProject;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const eslint_1 = require("@nx/eslint");
|
|
6
|
-
const
|
|
6
|
+
const internal_1 = require("@nx/eslint/internal");
|
|
7
7
|
const versions_1 = require("./versions");
|
|
8
|
-
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
9
|
-
const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
|
|
10
8
|
async function addLinterToPlaywrightProject(tree, options) {
|
|
11
9
|
if (options.linter === 'none') {
|
|
12
10
|
return () => { };
|
|
13
11
|
}
|
|
14
12
|
const tasks = [];
|
|
15
13
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
16
|
-
const eslintFile = (0,
|
|
14
|
+
const eslintFile = (0, internal_1.findEslintFile)(tree, projectConfig.root);
|
|
17
15
|
if (!eslintFile) {
|
|
18
16
|
tasks.push(await (0, eslint_1.lintProjectGenerator)(tree, {
|
|
19
17
|
project: options.project,
|
|
@@ -32,28 +30,28 @@ async function addLinterToPlaywrightProject(tree, options) {
|
|
|
32
30
|
tasks.push(!options.skipPackageJson
|
|
33
31
|
? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'eslint-plugin-playwright': versions_1.eslintPluginPlaywrightVersion }, undefined, true)
|
|
34
32
|
: () => { });
|
|
35
|
-
if ((0,
|
|
36
|
-
(0,
|
|
37
|
-
if ((0,
|
|
38
|
-
(0,
|
|
33
|
+
if ((0, internal_1.isEslintConfigSupported)(tree, projectConfig.root) ||
|
|
34
|
+
(0, internal_1.isEslintConfigSupported)(tree)) {
|
|
35
|
+
if ((0, internal_1.useFlatConfig)(tree)) {
|
|
36
|
+
(0, internal_1.addPredefinedConfigToFlatLintConfig)(tree, projectConfig.root, 'flat/recommended', {
|
|
39
37
|
moduleName: 'playwright',
|
|
40
38
|
moduleImportPath: 'eslint-plugin-playwright',
|
|
41
39
|
spread: false,
|
|
42
40
|
insertAtTheEnd: false,
|
|
43
41
|
});
|
|
44
|
-
(0,
|
|
42
|
+
(0, internal_1.addOverrideToLintConfig)(tree, projectConfig.root, {
|
|
45
43
|
files: ['*.ts', '*.js'],
|
|
46
44
|
rules: {},
|
|
47
45
|
});
|
|
48
46
|
}
|
|
49
47
|
else {
|
|
50
|
-
const addExtendsTask = (0,
|
|
48
|
+
const addExtendsTask = (0, internal_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:playwright/recommended');
|
|
51
49
|
tasks.push(addExtendsTask);
|
|
52
50
|
if (options.rootProject) {
|
|
53
|
-
(0,
|
|
54
|
-
(0,
|
|
51
|
+
(0, internal_1.addPluginsToLintConfig)(tree, projectConfig.root, '@nx');
|
|
52
|
+
(0, internal_1.addOverrideToLintConfig)(tree, projectConfig.root, internal_1.javaScriptOverride);
|
|
55
53
|
}
|
|
56
|
-
(0,
|
|
54
|
+
(0, internal_1.addOverrideToLintConfig)(tree, projectConfig.root, {
|
|
57
55
|
files: [`${options.directory}/**/*.{ts,js,tsx,jsx}`],
|
|
58
56
|
parserOptions: !options.setParserOptionsProject
|
|
59
57
|
? undefined
|
package/src/utils/preset.d.ts
CHANGED
|
@@ -30,8 +30,11 @@ export interface NxPlaywrightOptions {
|
|
|
30
30
|
*
|
|
31
31
|
* you can easily extend this within your playwright config via spreading the preset
|
|
32
32
|
* @example
|
|
33
|
+
* // Nx generates `playwright.config.mts` (ESM). Pass `import.meta.dirname`.
|
|
34
|
+
* // For hand-written CJS configs (`.cts` or `.ts` outside a `type: "module"`
|
|
35
|
+
* // workspace), pass `__filename` instead.
|
|
33
36
|
* export default defineConfig({
|
|
34
|
-
* ...nxE2EPreset(
|
|
37
|
+
* ...nxE2EPreset(import.meta.dirname, options)
|
|
35
38
|
* // add your own config here
|
|
36
39
|
* })
|
|
37
40
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../../../../packages/playwright/src/utils/preset.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC;;;QAGI;IACJ,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;IACnD;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED
|
|
1
|
+
{"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../../../../packages/playwright/src/utils/preset.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC;;;QAGI;IACJ,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;IACnD;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,2DA2D9B"}
|
package/src/utils/preset.js
CHANGED
|
@@ -23,8 +23,11 @@ const versions_1 = require("./versions");
|
|
|
23
23
|
*
|
|
24
24
|
* you can easily extend this within your playwright config via spreading the preset
|
|
25
25
|
* @example
|
|
26
|
+
* // Nx generates `playwright.config.mts` (ESM). Pass `import.meta.dirname`.
|
|
27
|
+
* // For hand-written CJS configs (`.cts` or `.ts` outside a `type: "module"`
|
|
28
|
+
* // workspace), pass `__filename` instead.
|
|
26
29
|
* export default defineConfig({
|
|
27
|
-
* ...nxE2EPreset(
|
|
30
|
+
* ...nxE2EPreset(import.meta.dirname, options)
|
|
28
31
|
* // add your own config here
|
|
29
32
|
* })
|
|
30
33
|
*
|