testchimp-runner-core 0.0.87 → 0.0.89

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,101 @@
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 ParsedTestStatement {
12
+ code: string;
13
+ isVariableDeclaration: boolean;
14
+ intentComment?: string;
15
+ screenStateAnnotation?: string;
16
+ }
17
+ export interface ParsedTest {
18
+ name: string;
19
+ code: string;
20
+ suitePath?: string[];
21
+ fullName: string;
22
+ statements: ParsedTestStatement[];
23
+ }
24
+ export interface ParsedSuite {
25
+ name: string;
26
+ suitePath: string[];
27
+ beforeAll: ParsedHook[];
28
+ afterAll: ParsedHook[];
29
+ beforeEach: ParsedHook[];
30
+ afterEach: ParsedHook[];
31
+ tests: ParsedTest[];
32
+ nestedSuites: ParsedSuite[];
33
+ }
34
+ export interface ParsedTestFile {
35
+ fileHooks: {
36
+ beforeAll: ParsedHook[];
37
+ afterAll: ParsedHook[];
38
+ beforeEach: ParsedHook[];
39
+ afterEach: ParsedHook[];
40
+ };
41
+ tests: ParsedTest[];
42
+ suites: ParsedSuite[];
43
+ }
44
+ export declare class TestFileParser {
45
+ /**
46
+ * Generate full test name with suite prefix
47
+ * @param suitePath - Array of suite names from root to current suite
48
+ * @param testName - Original test name
49
+ * @returns Full test name with suite prefix (e.g., "LoginSuite__testLogin")
50
+ */
51
+ static generateTestFullName(suitePath: string[], testName: string): string;
52
+ /**
53
+ * Find all parent describe blocks for a given AST path
54
+ * @param path - Babel AST path
55
+ * @returns Array of suite names from root to current (empty if not in any describe block)
56
+ */
57
+ static findSuitePath(path: any): string[];
58
+ /**
59
+ * Parse a test file to extract hooks and tests, supporting test.describe() blocks
60
+ * @param script - The test file content
61
+ * @param testNames - Optional array of test names to filter (supports both original names and full names with suite prefix)
62
+ * @returns Parsed structure with hooks and tests
63
+ */
64
+ static parseTestFile(script: string, testNames?: string[]): ParsedTestFile;
65
+ /**
66
+ * Flatten suite structure into execution-ready format
67
+ * Separates per-test hooks (beforeEach/afterEach) from per-suite hooks (beforeAll/afterAll)
68
+ * @param parsed - Parsed test file structure
69
+ * @returns Flattened structure ready for execution
70
+ */
71
+ static flattenForExecution(parsed: ParsedTestFile): {
72
+ fileLevelHooks: {
73
+ beforeAll: ParsedHook[];
74
+ afterAll: ParsedHook[];
75
+ beforeEach: ParsedHook[];
76
+ afterEach: ParsedHook[];
77
+ };
78
+ tests: Array<{
79
+ test: ParsedTest;
80
+ suitePath: string[];
81
+ suiteBeforeEachHooks: ParsedHook[];
82
+ suiteAfterEachHooks: ParsedHook[];
83
+ }>;
84
+ suites: Array<{
85
+ suitePath: string[];
86
+ beforeAll: ParsedHook[];
87
+ afterAll: ParsedHook[];
88
+ testIndices: number[];
89
+ }>;
90
+ };
91
+ /**
92
+ * Construct a test script with imports and a single test using AST
93
+ * This is more robust than string interpolation
94
+ * @param originalScript - The full original script (to extract imports)
95
+ * @param testName - The test name
96
+ * @param testBodyCode - The test body code (already extracted)
97
+ * @returns A complete script with imports and the test
98
+ */
99
+ static constructTestScriptWithImports(originalScript: string, testName: string, testBodyCode: string): string;
100
+ }
101
+ //# 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,mBAAmB;IAClC,IA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