testchimp-runner-core 0.0.87 → 0.0.88

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.
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Utilities for parsing test files to extract hooks and tests
3
+ * Supports Playwright hooks: test.beforeAll, test.afterAll, test.beforeEach, test.afterEach
4
+ */
5
+ export interface ParsedHook {
6
+ code: string;
7
+ name: string;
8
+ suitePath?: string[];
9
+ scope: 'file' | 'suite';
10
+ }
11
+ export interface ParsedTest {
12
+ name: string;
13
+ code: string;
14
+ suitePath?: string[];
15
+ fullName: string;
16
+ }
17
+ export interface ParsedSuite {
18
+ name: string;
19
+ suitePath: string[];
20
+ beforeAll: ParsedHook[];
21
+ afterAll: ParsedHook[];
22
+ beforeEach: ParsedHook[];
23
+ afterEach: ParsedHook[];
24
+ tests: ParsedTest[];
25
+ nestedSuites: ParsedSuite[];
26
+ }
27
+ export interface ParsedTestFile {
28
+ fileHooks: {
29
+ beforeAll: ParsedHook[];
30
+ afterAll: ParsedHook[];
31
+ beforeEach: ParsedHook[];
32
+ afterEach: ParsedHook[];
33
+ };
34
+ tests: ParsedTest[];
35
+ suites: ParsedSuite[];
36
+ }
37
+ export declare class TestFileParser {
38
+ /**
39
+ * Generate full test name with suite prefix
40
+ * @param suitePath - Array of suite names from root to current suite
41
+ * @param testName - Original test name
42
+ * @returns Full test name with suite prefix (e.g., "LoginSuite__testLogin")
43
+ */
44
+ static generateTestFullName(suitePath: string[], testName: string): string;
45
+ /**
46
+ * Find all parent describe blocks for a given AST path
47
+ * @param path - Babel AST path
48
+ * @returns Array of suite names from root to current (empty if not in any describe block)
49
+ */
50
+ static findSuitePath(path: any): string[];
51
+ /**
52
+ * Parse a test file to extract hooks and tests, supporting test.describe() blocks
53
+ * @param script - The test file content
54
+ * @param testNames - Optional array of test names to filter (supports both original names and full names with suite prefix)
55
+ * @returns Parsed structure with hooks and tests
56
+ */
57
+ static parseTestFile(script: string, testNames?: string[]): ParsedTestFile;
58
+ /**
59
+ * Flatten suite structure into execution-ready format
60
+ * Separates per-test hooks (beforeEach/afterEach) from per-suite hooks (beforeAll/afterAll)
61
+ * @param parsed - Parsed test file structure
62
+ * @returns Flattened structure ready for execution
63
+ */
64
+ static flattenForExecution(parsed: ParsedTestFile): {
65
+ fileLevelHooks: {
66
+ beforeAll: ParsedHook[];
67
+ afterAll: ParsedHook[];
68
+ beforeEach: ParsedHook[];
69
+ afterEach: ParsedHook[];
70
+ };
71
+ tests: Array<{
72
+ test: ParsedTest;
73
+ suitePath: string[];
74
+ suiteBeforeEachHooks: ParsedHook[];
75
+ suiteAfterEachHooks: ParsedHook[];
76
+ }>;
77
+ suites: Array<{
78
+ suitePath: string[];
79
+ beforeAll: ParsedHook[];
80
+ afterAll: ParsedHook[];
81
+ testIndices: number[];
82
+ }>;
83
+ };
84
+ /**
85
+ * Construct a test script with imports and a single test using AST
86
+ * This is more robust than string interpolation
87
+ * @param originalScript - The full original script (to extract imports)
88
+ * @param testName - The test name
89
+ * @param testBodyCode - The test body code (already extracted)
90
+ * @returns A complete script with imports and the test
91
+ */
92
+ static constructTestScriptWithImports(originalScript: string, testName: string, testBodyCode: string): string;
93
+ }
94
+ //# sourceMappingURL=test-file-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-file-parser.d.ts","sourceRoot":"","sources":["../../src/utils/test-file-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CA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