@nsxbet/playwright-orchestrator 0.6.3 → 0.7.0
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/fixture.d.ts +43 -3
- package/dist/fixture.d.ts.map +1 -1
- package/dist/fixture.js +75 -3
- package/dist/fixture.js.map +1 -1
- package/package.json +1 -1
package/dist/fixture.d.ts
CHANGED
|
@@ -6,10 +6,21 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Usage in your test setup file (e.g., tests/setup.ts):
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import { test } from '@playwright/test';
|
|
10
|
-
* import {
|
|
9
|
+
* import { test as base } from '@playwright/test';
|
|
10
|
+
* import { withOrchestratorFilter } from '@nsxbet/playwright-orchestrator/fixture';
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* // Create extended test with orchestrator filtering
|
|
13
|
+
* export const test = withOrchestratorFilter(base);
|
|
14
|
+
* export { expect } from '@playwright/test';
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Then in your test files:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { test, expect } from './setup';
|
|
20
|
+
*
|
|
21
|
+
* test('my test', async ({ page }) => {
|
|
22
|
+
* // ...
|
|
23
|
+
* });
|
|
13
24
|
* ```
|
|
14
25
|
*
|
|
15
26
|
* Environment variables:
|
|
@@ -20,6 +31,35 @@
|
|
|
20
31
|
*/
|
|
21
32
|
import type { TestType } from '@playwright/test';
|
|
22
33
|
/**
|
|
34
|
+
* Creates an extended test with orchestrator filtering as an auto-fixture.
|
|
35
|
+
* This ensures tests not in the current shard are skipped.
|
|
36
|
+
*
|
|
37
|
+
* IMPORTANT: Use this function to create your test object, then export it.
|
|
38
|
+
* All test files should import the extended test, not the base test.
|
|
39
|
+
*
|
|
40
|
+
* @param test - The base test object from @playwright/test
|
|
41
|
+
* @returns Extended test with orchestrator filtering
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // In setup.ts
|
|
46
|
+
* import { test as base } from '@playwright/test';
|
|
47
|
+
* import { withOrchestratorFilter } from '@nsxbet/playwright-orchestrator/fixture';
|
|
48
|
+
*
|
|
49
|
+
* export const test = withOrchestratorFilter(base);
|
|
50
|
+
*
|
|
51
|
+
* // In your.spec.ts
|
|
52
|
+
* import { test } from './setup';
|
|
53
|
+
* test('example', async ({ page }) => { ... });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function withOrchestratorFilter<T extends object, W extends object>(test: TestType<T, W>): TestType<T & {
|
|
57
|
+
_orchestratorFilter: undefined;
|
|
58
|
+
}, W>;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Use `withOrchestratorFilter` instead. This function uses beforeEach
|
|
61
|
+
* which only works for the first test file processed, not subsequent files.
|
|
62
|
+
*
|
|
23
63
|
* Sets up the orchestrator filter as a beforeEach hook.
|
|
24
64
|
* This will skip tests that are not in the current shard.
|
|
25
65
|
*
|
package/dist/fixture.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixture.d.ts","sourceRoot":"","sources":["../src/fixture.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fixture.d.ts","sourceRoot":"","sources":["../src/fixture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAuDjD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EACvE,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,QAAQ,CAAC,CAAC,GAAG;IAAE,mBAAmB,EAAE,SAAS,CAAA;CAAE,EAAE,CAAC,CAAC,CAwDrD;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EACxE,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,IAAI,CAoCN;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C,GAAG,OAAO,CAUV"}
|
package/dist/fixture.js
CHANGED
|
@@ -6,10 +6,21 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Usage in your test setup file (e.g., tests/setup.ts):
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import { test } from '@playwright/test';
|
|
10
|
-
* import {
|
|
9
|
+
* import { test as base } from '@playwright/test';
|
|
10
|
+
* import { withOrchestratorFilter } from '@nsxbet/playwright-orchestrator/fixture';
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* // Create extended test with orchestrator filtering
|
|
13
|
+
* export const test = withOrchestratorFilter(base);
|
|
14
|
+
* export { expect } from '@playwright/test';
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Then in your test files:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { test, expect } from './setup';
|
|
20
|
+
*
|
|
21
|
+
* test('my test', async ({ page }) => {
|
|
22
|
+
* // ...
|
|
23
|
+
* });
|
|
13
24
|
* ```
|
|
14
25
|
*
|
|
15
26
|
* Environment variables:
|
|
@@ -59,6 +70,67 @@ function loadShardFile() {
|
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
72
|
/**
|
|
73
|
+
* Creates an extended test with orchestrator filtering as an auto-fixture.
|
|
74
|
+
* This ensures tests not in the current shard are skipped.
|
|
75
|
+
*
|
|
76
|
+
* IMPORTANT: Use this function to create your test object, then export it.
|
|
77
|
+
* All test files should import the extended test, not the base test.
|
|
78
|
+
*
|
|
79
|
+
* @param test - The base test object from @playwright/test
|
|
80
|
+
* @returns Extended test with orchestrator filtering
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* // In setup.ts
|
|
85
|
+
* import { test as base } from '@playwright/test';
|
|
86
|
+
* import { withOrchestratorFilter } from '@nsxbet/playwright-orchestrator/fixture';
|
|
87
|
+
*
|
|
88
|
+
* export const test = withOrchestratorFilter(base);
|
|
89
|
+
*
|
|
90
|
+
* // In your.spec.ts
|
|
91
|
+
* import { test } from './setup';
|
|
92
|
+
* test('example', async ({ page }) => { ... });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export function withOrchestratorFilter(test) {
|
|
96
|
+
return test.extend({
|
|
97
|
+
// @ts-expect-error - Playwright's auto fixture typing is complex
|
|
98
|
+
_orchestratorFilter: [
|
|
99
|
+
async (
|
|
100
|
+
// biome-ignore lint/correctness/noEmptyPattern: Playwright requires empty destructuring
|
|
101
|
+
{}, use, testInfo) => {
|
|
102
|
+
const allowedTestIds = loadShardFile();
|
|
103
|
+
if (allowedTestIds) {
|
|
104
|
+
// CRITICAL: Use project.testDir for consistent path resolution with test-discovery
|
|
105
|
+
// No fallback to process.cwd() - this causes path mismatch bugs
|
|
106
|
+
const testDir = testInfo.project.testDir;
|
|
107
|
+
if (!testDir) {
|
|
108
|
+
throw new Error('[Orchestrator Fixture] Could not determine project testDir. ' +
|
|
109
|
+
'Ensure your playwright.config.ts has projects configured with testDir.');
|
|
110
|
+
}
|
|
111
|
+
const testId = buildTestIdFromRuntime(testInfo.file, testInfo.titlePath, {
|
|
112
|
+
projectName: testInfo.project.name,
|
|
113
|
+
baseDir: testDir,
|
|
114
|
+
});
|
|
115
|
+
const isAllowed = allowedTestIds.has(testId);
|
|
116
|
+
// Debug: Write to stderr for visibility in CI logs
|
|
117
|
+
if (process.env.ORCHESTRATOR_DEBUG === '1') {
|
|
118
|
+
process.stderr.write(`[Fixture] testDir=${testInfo.project.testDir} | testId=${testId} | allowed=${isAllowed}\n`);
|
|
119
|
+
}
|
|
120
|
+
if (!isAllowed) {
|
|
121
|
+
test.skip(true, 'Not in shard');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
await use();
|
|
125
|
+
},
|
|
126
|
+
{ auto: true },
|
|
127
|
+
],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated Use `withOrchestratorFilter` instead. This function uses beforeEach
|
|
132
|
+
* which only works for the first test file processed, not subsequent files.
|
|
133
|
+
*
|
|
62
134
|
* Sets up the orchestrator filter as a beforeEach hook.
|
|
63
135
|
* This will skip tests that are not in the current shard.
|
|
64
136
|
*
|
package/dist/fixture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixture.js","sourceRoot":"","sources":["../src/fixture.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fixture.js","sourceRoot":"","sources":["../src/fixture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,mDAAmD;AACnD,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,GAAG,EAAE,CAAC;IAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;AAC1E,CAAC;AAED,yDAAyD;AACzD,IAAI,oBAAoB,GAAuB,IAAI,CAAC;AACpD,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B,SAAS,aAAa;IACpB,IAAI,gBAAgB;QAAE,OAAO,oBAAoB,CAAC;IAElD,gBAAgB,GAAG,IAAI,CAAC;IACxB,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IAEtD,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