playwright-test-explorer 0.0.1
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/README.md +363 -0
- package/dist/api-DuYXKbq5.js +965 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +89 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +3 -0
- package/package.json +59 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as CancellationToken, n as listTestFile, r as treeStructure, t as listTestCase } from "./api-DuYXKbq5.js";
|
|
3
|
+
import { program } from "commander";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
import path from "path";
|
|
7
|
+
|
|
8
|
+
//#region src/cli.ts
|
|
9
|
+
program.name("pw-test-explorer").description("CLI tool for exploring Playwright tests").version("0.1.0");
|
|
10
|
+
program.command("list-files").description("List all test files in the Playwright project").option("-w, --workspace <path>", "workspace folder path", process.cwd()).option("-c, --config <file>", "config file path (relative to workspace)", "playwright.config.ts").option("-o, --output <file>", "output file path to save JSON results").action(async (options) => {
|
|
11
|
+
const spinner = ora("Loading test files...").start();
|
|
12
|
+
try {
|
|
13
|
+
const workspaceFolder = path.resolve(options.workspace);
|
|
14
|
+
const outputFile = options.output ? path.resolve(options.output) : void 0;
|
|
15
|
+
await listTestFile(workspaceFolder, options.config, outputFile);
|
|
16
|
+
spinner.succeed(chalk.green("Test files loaded successfully"));
|
|
17
|
+
} catch (error) {
|
|
18
|
+
spinner.fail(chalk.red("Failed to list test files"));
|
|
19
|
+
console.error(chalk.red("Error:"), error instanceof Error ? error.message : String(error));
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
program.command("list-tests").description("List all test cases in specified files").option("-w, --workspace <path>", "workspace folder path", process.cwd()).option("-c, --config <file>", "config file path (relative to workspace)", "playwright.config.ts").option("-f, --files <files...>", "test file paths (relative to workspace)", []).option("-o, --output <file>", "output file path to save JSON results").action(async (options) => {
|
|
24
|
+
if (!options.files || options.files.length === 0) {
|
|
25
|
+
console.error(chalk.red("Error: Please specify at least one test file using -f or --files"));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
const spinner = ora("Loading test cases...").start();
|
|
29
|
+
try {
|
|
30
|
+
const workspaceFolder = path.resolve(options.workspace);
|
|
31
|
+
const outputFile = options.output ? path.resolve(options.output) : void 0;
|
|
32
|
+
await listTestCase(workspaceFolder, options.config, options.files, outputFile);
|
|
33
|
+
spinner.succeed(chalk.green("Test cases loaded successfully"));
|
|
34
|
+
} catch (error) {
|
|
35
|
+
spinner.fail(chalk.red("Failed to list test cases"));
|
|
36
|
+
console.error(chalk.red("Error:"), error instanceof Error ? error.message : String(error));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
program.command("tree").description("Display test structure as a tree").option("-w, --workspace <path>", "workspace folder path", process.cwd()).option("-c, --config <file>", "config file path (relative to workspace)", "playwright.config.ts").option("-o, --output <file>", "output file path to save JSON results").action(async (options) => {
|
|
41
|
+
const spinner = ora("Building test tree...").start();
|
|
42
|
+
try {
|
|
43
|
+
const workspaceFolder = path.resolve(options.workspace);
|
|
44
|
+
const token = new CancellationToken();
|
|
45
|
+
process.on("SIGINT", () => {
|
|
46
|
+
spinner.warn(chalk.yellow("Operation cancelled"));
|
|
47
|
+
token.cancel();
|
|
48
|
+
process.exit(0);
|
|
49
|
+
});
|
|
50
|
+
const outputFile = options.output ? path.resolve(options.output) : void 0;
|
|
51
|
+
await treeStructure(workspaceFolder, options.config, token, outputFile);
|
|
52
|
+
spinner.succeed(chalk.green("Test tree built successfully"));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
spinner.fail(chalk.red("Failed to build test tree"));
|
|
55
|
+
console.error(chalk.red("Error:"), error instanceof Error ? error.message : String(error));
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
program.addHelpText("after", `
|
|
60
|
+
|
|
61
|
+
${chalk.bold("Examples:")}
|
|
62
|
+
${chalk.cyan("# List all test files in current directory")}
|
|
63
|
+
$ pw-test-explorer list-files
|
|
64
|
+
|
|
65
|
+
${chalk.cyan("# List test files with custom config")}
|
|
66
|
+
$ pw-test-explorer list-files -w /path/to/project -c e2e/playwright.config.ts
|
|
67
|
+
|
|
68
|
+
${chalk.cyan("# Save test files to JSON file")}
|
|
69
|
+
$ pw-test-explorer list-files -o output.json
|
|
70
|
+
|
|
71
|
+
${chalk.cyan("# List test cases in specific files")}
|
|
72
|
+
$ pw-test-explorer list-tests -f tests/example.spec.ts tests/another.spec.ts
|
|
73
|
+
|
|
74
|
+
${chalk.cyan("# Save test cases to JSON file")}
|
|
75
|
+
$ pw-test-explorer list-tests -f tests/example.spec.ts -o tests.json
|
|
76
|
+
|
|
77
|
+
${chalk.cyan("# Display test structure as tree")}
|
|
78
|
+
$ pw-test-explorer tree
|
|
79
|
+
|
|
80
|
+
${chalk.cyan("# Save tree structure to JSON file")}
|
|
81
|
+
$ pw-test-explorer tree -o tree.json
|
|
82
|
+
|
|
83
|
+
${chalk.cyan("# Display tree for specific workspace")}
|
|
84
|
+
$ pw-test-explorer tree -w /path/to/project
|
|
85
|
+
`);
|
|
86
|
+
program.parse();
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/upstream/events.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
declare namespace Disposable {
|
|
18
|
+
function disposeAll(disposables: Disposable[]): void;
|
|
19
|
+
}
|
|
20
|
+
type Disposable = {
|
|
21
|
+
dispose(): void;
|
|
22
|
+
};
|
|
23
|
+
interface Event<T> {
|
|
24
|
+
(listener: (e: T) => any, disposables?: Disposable[]): Disposable;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/playwrightTestServer.d.ts
|
|
28
|
+
|
|
29
|
+
declare class CancellationToken {
|
|
30
|
+
private _isCancelled;
|
|
31
|
+
private _onCancelEmitter;
|
|
32
|
+
get isCancellationRequested(): boolean;
|
|
33
|
+
get onCancellationRequested(): Event<void>;
|
|
34
|
+
cancel(): void;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/api.d.ts
|
|
38
|
+
declare function listTestFile(workspaceFolder?: string, configFile?: string, outputFile?: string): Promise<void>;
|
|
39
|
+
declare function listTestCase(workspaceFolder: string | undefined, configFile: string | undefined, relativePaths: string[], outputFile?: string): Promise<void>;
|
|
40
|
+
declare function treeStructure(workspaceFolder?: string, configFile?: string, cancellationToken?: CancellationToken, outputFile?: string): Promise<void>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { listTestCase, listTestFile, treeStructure };
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "playwright-test-explorer",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A CLI tool and library for exploring Playwright tests",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/author/library#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/author/library/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/author/library.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "Author Name <author.name@mail.com>",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"module": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"bin": {
|
|
23
|
+
"pw-test-explorer": "./dist/cli.js"
|
|
24
|
+
},
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./dist/index.js",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsdown",
|
|
31
|
+
"dev": "tsdown --watch",
|
|
32
|
+
"test": "vitest --run",
|
|
33
|
+
"test:watch": "vitest",
|
|
34
|
+
"test:coverage": "vitest --coverage",
|
|
35
|
+
"test:legacy": "node test-cli.js",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"test:example": "node dist/cli.js tree -w example",
|
|
38
|
+
"test:list-files": "node dist/cli.js list-files -w example",
|
|
39
|
+
"test:list-tests": "node dist/cli.js list-tests -w example -f tests/example.spec.ts",
|
|
40
|
+
"test:save-tree": "node dist/cli.js tree -w example -o example-tree.json",
|
|
41
|
+
"test:save-files": "node dist/cli.js list-files -w example -o example-files.json"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"chalk": "^5.6.2",
|
|
45
|
+
"commander": "^14.0.2",
|
|
46
|
+
"ora": "^9.0.0",
|
|
47
|
+
"ws": "^8.18.3"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@playwright/test": "^1.56.1",
|
|
51
|
+
"@types/node": "^24.9.2",
|
|
52
|
+
"@types/ws": "^8.18.1",
|
|
53
|
+
"@vitest/coverage-v8": "4.0.5",
|
|
54
|
+
"bumpp": "^10.3.1",
|
|
55
|
+
"tsdown": "^0.15.12",
|
|
56
|
+
"typescript": "^5.9.3",
|
|
57
|
+
"vitest": "^4.0.5"
|
|
58
|
+
}
|
|
59
|
+
}
|