@nx/playwright 23.1.0 → 23.1.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/dist/src/generators/configuration/configuration.js +1 -1
- package/dist/src/generators/configuration/schema.d.ts +4 -0
- package/dist/src/generators/configuration/schema.json +8 -2
- package/dist/src/plugins/plugin.js +4 -8
- package/dist/src/utils/add-linter.d.ts +5 -1
- package/dist/src/utils/add-linter.js +15 -6
- package/dist/src/utils/preset.d.ts +9 -1
- package/dist/src/utils/preset.js +7 -3
- package/package.json +5 -5
|
@@ -149,7 +149,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
|
|
|
149
149
|
skipPackageJson: options.skipPackageJson,
|
|
150
150
|
js: options.js,
|
|
151
151
|
directory: options.directory,
|
|
152
|
-
|
|
152
|
+
enableTypedLinting: (0, internal_3.isTypedLintingEnabled)(options),
|
|
153
153
|
rootProject: options.rootProject ?? projectConfig.root === '.',
|
|
154
154
|
addPlugin: options.addPlugin,
|
|
155
155
|
}));
|
|
@@ -11,6 +11,10 @@ export interface ConfigurationGeneratorSchema {
|
|
|
11
11
|
skipPackageJson?: boolean;
|
|
12
12
|
skipInstall?: boolean;
|
|
13
13
|
linter?: Linter | LinterType;
|
|
14
|
+
enableTypedLinting?: boolean; // default is false
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
17
|
+
*/
|
|
14
18
|
setParserOptionsProject?: boolean; // default is false
|
|
15
19
|
/**
|
|
16
20
|
* command to give playwright to run the web server
|
|
@@ -39,11 +39,17 @@
|
|
|
39
39
|
"type": "string",
|
|
40
40
|
"description": "The address of the web server."
|
|
41
41
|
},
|
|
42
|
-
"
|
|
42
|
+
"enableTypedLinting": {
|
|
43
43
|
"type": "boolean",
|
|
44
|
-
"description": "Whether
|
|
44
|
+
"description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
|
|
45
45
|
"default": false
|
|
46
46
|
},
|
|
47
|
+
"setParserOptionsProject": {
|
|
48
|
+
"type": "boolean",
|
|
49
|
+
"description": "Deprecated alias for `enableTypedLinting`.",
|
|
50
|
+
"default": false,
|
|
51
|
+
"x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
|
|
52
|
+
},
|
|
47
53
|
"skipFormat": {
|
|
48
54
|
"description": "Skip formatting files.",
|
|
49
55
|
"type": "boolean",
|
|
@@ -8,18 +8,14 @@ const internal_2 = require("@nx/js/internal");
|
|
|
8
8
|
const minimatch_1 = require("minimatch");
|
|
9
9
|
const node_fs_1 = require("node:fs");
|
|
10
10
|
const node_path_1 = require("node:path");
|
|
11
|
-
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
12
|
-
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
13
|
-
const plugin_cache_utils_1 = require("nx/src/utils/plugin-cache-utils");
|
|
14
|
-
const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
15
11
|
const reporters_1 = require("../utils/reporters");
|
|
16
12
|
const playwrightConfigGlob = '**/playwright.config.{js,ts,cjs,cts,mjs,mts}';
|
|
17
13
|
exports.createNodes = [
|
|
18
14
|
playwrightConfigGlob,
|
|
19
15
|
async (configFilePaths, options, context) => {
|
|
20
|
-
const optionsHash = (0,
|
|
21
|
-
const cachePath = (0, node_path_1.join)(
|
|
22
|
-
const pluginCache = new
|
|
16
|
+
const optionsHash = (0, internal_1.hashObject)(options);
|
|
17
|
+
const cachePath = (0, node_path_1.join)(internal_1.workspaceDataDirectory, `playwright-${optionsHash}.hash`);
|
|
18
|
+
const pluginCache = new internal_1.PluginCache(cachePath);
|
|
23
19
|
const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
|
|
24
20
|
const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
25
21
|
const lockFileName = (0, js_1.getLockFileName)(packageManager);
|
|
@@ -249,7 +245,7 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
|
|
|
249
245
|
return { targets, metadata };
|
|
250
246
|
}
|
|
251
247
|
async function getAllTestFiles(opts) {
|
|
252
|
-
const files = await (0,
|
|
248
|
+
const files = await (0, internal_1.getFilesInDirectoryUsingContext)(opts.context.workspaceRoot, opts.path);
|
|
253
249
|
const matcher = createMatcher(opts.config.testMatch);
|
|
254
250
|
const ignoredMatcher = opts.config.testIgnore
|
|
255
251
|
? createMatcher(opts.config.testIgnore)
|
|
@@ -3,7 +3,11 @@ import { Linter, LinterType } from '@nx/eslint';
|
|
|
3
3
|
export interface PlaywrightLinterOptions {
|
|
4
4
|
project: string;
|
|
5
5
|
linter: Linter | LinterType;
|
|
6
|
-
|
|
6
|
+
enableTypedLinting?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
9
|
+
*/
|
|
10
|
+
setParserOptionsProject?: boolean;
|
|
7
11
|
skipPackageJson: boolean;
|
|
8
12
|
rootProject: boolean;
|
|
9
13
|
js?: boolean;
|
|
@@ -12,13 +12,14 @@ async function addLinterToPlaywrightProject(tree, options) {
|
|
|
12
12
|
const tasks = [];
|
|
13
13
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
14
14
|
const eslintFile = (0, internal_1.findEslintFile)(tree, projectConfig.root);
|
|
15
|
+
const enableTypedLinting = (0, internal_1.isTypedLintingEnabled)(options);
|
|
15
16
|
if (!eslintFile) {
|
|
16
17
|
tasks.push(await (0, eslint_1.lintProjectGenerator)(tree, {
|
|
17
18
|
project: options.project,
|
|
18
19
|
linter: options.linter,
|
|
19
20
|
skipFormat: true,
|
|
20
21
|
tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
|
|
21
|
-
|
|
22
|
+
enableTypedLinting,
|
|
22
23
|
skipPackageJson: options.skipPackageJson,
|
|
23
24
|
rootProject: options.rootProject,
|
|
24
25
|
addPlugin: options.addPlugin,
|
|
@@ -43,6 +44,13 @@ async function addLinterToPlaywrightProject(tree, options) {
|
|
|
43
44
|
files: ['*.ts', '*.js'],
|
|
44
45
|
rules: {},
|
|
45
46
|
});
|
|
47
|
+
// `lintProjectGenerator` only runs when the project has no ESLint config
|
|
48
|
+
// (it already emits the projectService block in that case). For an
|
|
49
|
+
// existing flat config it didn't run, so emit the block here when typed
|
|
50
|
+
// linting is requested.
|
|
51
|
+
if (eslintFile && enableTypedLinting) {
|
|
52
|
+
(0, internal_1.addTypedLintingToFlatConfig)(tree, projectConfig.root);
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
else {
|
|
48
56
|
const addExtendsTask = (0, internal_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:playwright/recommended');
|
|
@@ -53,11 +61,12 @@ async function addLinterToPlaywrightProject(tree, options) {
|
|
|
53
61
|
}
|
|
54
62
|
(0, internal_1.addOverrideToLintConfig)(tree, projectConfig.root, {
|
|
55
63
|
files: [`${options.directory}/**/*.{ts,js,tsx,jsx}`],
|
|
56
|
-
parserOptions
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
64
|
+
// Only emit `parserOptions.project` here on the legacy `.eslintrc`
|
|
65
|
+
// stack. Flat configs use `parserOptions.projectService` emitted by
|
|
66
|
+
// `lintProjectGenerator`.
|
|
67
|
+
parserOptions: enableTypedLinting
|
|
68
|
+
? { project: `${projectConfig.root}/tsconfig.*?.json` }
|
|
69
|
+
: undefined,
|
|
61
70
|
rules: {},
|
|
62
71
|
});
|
|
63
72
|
}
|
|
@@ -41,4 +41,12 @@ export interface NxPlaywrightOptions {
|
|
|
41
41
|
* @param pathToConfig will be used to construct the output paths for reporters and test results
|
|
42
42
|
* @param options optional configuration options
|
|
43
43
|
*/
|
|
44
|
-
export declare function nxE2EPreset(pathToConfig: string, options?: NxPlaywrightOptions):
|
|
44
|
+
export declare function nxE2EPreset(pathToConfig: string, options?: NxPlaywrightOptions): {
|
|
45
|
+
testDir: string;
|
|
46
|
+
outputDir: string;
|
|
47
|
+
fullyParallel: true;
|
|
48
|
+
forbidOnly: boolean;
|
|
49
|
+
retries: number;
|
|
50
|
+
workers: number;
|
|
51
|
+
reporter: any[];
|
|
52
|
+
};
|
package/dist/src/utils/preset.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.nxE2EPreset = nxE2EPreset;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const internal_2 = require("@nx/js/internal");
|
|
7
|
-
const test_1 = require("@playwright/test");
|
|
8
7
|
const node_fs_1 = require("node:fs");
|
|
9
8
|
const node_path_1 = require("node:path");
|
|
10
9
|
const semver_1 = require("semver");
|
|
@@ -71,7 +70,12 @@ function nxE2EPreset(pathToConfig, options) {
|
|
|
71
70
|
},
|
|
72
71
|
]);
|
|
73
72
|
}
|
|
74
|
-
|
|
73
|
+
// Plain object on purpose: consumers spread this into their own
|
|
74
|
+
// `defineConfig(...)` call. Calling `defineConfig` here would require
|
|
75
|
+
// `@playwright/test` at runtime, which crashes when the preset package and
|
|
76
|
+
// the consuming workspace resolve different copies of it (playwright
|
|
77
|
+
// refuses to be loaded twice in one process).
|
|
78
|
+
return {
|
|
75
79
|
testDir: options?.testDir ?? './src',
|
|
76
80
|
outputDir: testResultOuputDir,
|
|
77
81
|
/* Run tests in files in parallel */
|
|
@@ -84,5 +88,5 @@ function nxE2EPreset(pathToConfig, options) {
|
|
|
84
88
|
workers: process.env.CI ? 1 : undefined,
|
|
85
89
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
86
90
|
reporter: [...reporters],
|
|
87
|
-
}
|
|
91
|
+
};
|
|
88
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/playwright",
|
|
3
|
-
"version": "23.1.
|
|
3
|
+
"version": "23.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"tslib": "^2.3.0",
|
|
79
79
|
"minimatch": "10.2.5",
|
|
80
80
|
"semver": "^7.6.3",
|
|
81
|
-
"@nx/
|
|
82
|
-
"@nx/
|
|
83
|
-
"@nx/
|
|
81
|
+
"@nx/devkit": "23.1.2",
|
|
82
|
+
"@nx/eslint": "23.1.2",
|
|
83
|
+
"@nx/js": "23.1.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"nx": "23.1.
|
|
86
|
+
"nx": "23.1.2"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"@playwright/test": "^1.36.0"
|