From f2828cd8b0083af647d50514324f84b2c414687c Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Mon, 25 Mar 2024 12:29:44 +0800 Subject: [PATCH] chore: add options for matching and ignoring test files in e2e and p-test commands (#3811) --- packages/core/cli/src/commands/e2e.js | 6 ++++++ packages/core/cli/src/commands/p-test.js | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/cli/src/commands/e2e.js b/packages/core/cli/src/commands/e2e.js index 361687b9b..8d70f553a 100644 --- a/packages/core/cli/src/commands/e2e.js +++ b/packages/core/cli/src/commands/e2e.js @@ -243,6 +243,12 @@ module.exports = (cli) => { .option('--stop-on-error') .option('--build') .option('--concurrency [concurrency]', '', os.cpus().length) + .option( + '--match [match]', + 'Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.', + 'packages/**/__e2e__/**/*.test.ts', + ) + .option('--ignore [ignore]', 'Skip tests that match the pattern. Strings are treated as glob patterns.', undefined) .action(async (options) => { process.env.__E2E__ = true; if (options.build) { diff --git a/packages/core/cli/src/commands/p-test.js b/packages/core/cli/src/commands/p-test.js index 05bcaa06e..fb5b8a828 100644 --- a/packages/core/cli/src/commands/p-test.js +++ b/packages/core/cli/src/commands/p-test.js @@ -60,7 +60,8 @@ exports.pTest = async (options) => { fs.mkdirSync(dir, { recursive: true }); } - const files = glob.sync('packages/**/__e2e__/**/*.test.ts', { + const files = glob.sync(options.match, { + ignore: options.ignore, root: process.cwd(), });