vitest-plugin-vis 2.4.1 → 2.4.3
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/esm/server/browser_provider/playwright.js +1 -1
- package/esm/server/vis_context.d.ts +1 -1
- package/esm/server/vis_context.d.ts.map +1 -1
- package/esm/server/vis_context.logic.d.ts +1 -1
- package/esm/server/vis_context.logic.d.ts.map +1 -1
- package/esm/server/vis_context.logic.js +8 -6
- package/package.json +1 -1
- package/src/server/browser_provider/playwright.ts +1 -1
- package/src/server/vis_context.logic.ts +8 -7
|
@@ -4,8 +4,8 @@ export function playwright(context) {
|
|
|
4
4
|
// The `Locator` type from `vitest` has less props than the `Locator` in `playwright`
|
|
5
5
|
const subject = context.iframe.locator(selector);
|
|
6
6
|
return subject.screenshot({
|
|
7
|
-
timeout: options?.timeout,
|
|
8
7
|
path: filePath,
|
|
8
|
+
...options,
|
|
9
9
|
});
|
|
10
10
|
},
|
|
11
11
|
};
|
|
@@ -3,7 +3,7 @@ export declare const visContext: {
|
|
|
3
3
|
__test__getOptions(projectName: string): import("../config.ts").VisOptions<any> | undefined;
|
|
4
4
|
__test__reset(): void;
|
|
5
5
|
__test__getState(context: import("./vis_context.types.ts").PartialBrowserCommandContext): Promise<import("./vis_context.types.ts").VisProjectState>;
|
|
6
|
-
setupSuite(
|
|
6
|
+
setupSuite(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext): Promise<import("type-plus").Pick._<import("./vis_context.types.ts").VisProjectState, "subjectDataTestId">>;
|
|
7
7
|
getSnapshotInfo(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext, name: string, isAutoSnapshot: boolean, options?: {
|
|
8
8
|
snapshotFileId?: string | undefined;
|
|
9
9
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vis_context.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;
|
|
1
|
+
{"version":3,"file":"vis_context.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;sBAC86D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAD15D,CAAA"}
|
|
@@ -10,7 +10,7 @@ export declare function createVisContext(): {
|
|
|
10
10
|
* Test files include vitest test files and storybook story files.
|
|
11
11
|
* It needs to make sure there is no race condition between the test files.
|
|
12
12
|
*/
|
|
13
|
-
setupSuite(
|
|
13
|
+
setupSuite(browserContext: PartialBrowserCommandContext): Promise<import("type-plus").Pick._<VisProjectState, "subjectDataTestId">>;
|
|
14
14
|
getSnapshotInfo(browserContext: PartialBrowserCommandContext, name: string, isAutoSnapshot: boolean, options?: {
|
|
15
15
|
snapshotFileId?: string | undefined;
|
|
16
16
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vis_context.logic.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.logic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAMpD,OAAO,KAAK,EAAE,4BAA4B,EAAE,eAAe,EAAY,MAAM,wBAAwB,CAAA;AAErG,wBAAgB,gBAAgB;eAKnB,CAAC,SAAS,OAAO,GAAG,MAAM,eAAe,MAAM,GAAG,SAAS,YAAW,UAAU,CAAC,CAAC,CAAC;oCAG9D,MAAM;;8BAOZ,4BAA4B;IAGtD;;;;OAIG
|
|
1
|
+
{"version":3,"file":"vis_context.logic.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.logic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAMpD,OAAO,KAAK,EAAE,4BAA4B,EAAE,eAAe,EAAY,MAAM,wBAAwB,CAAA;AAErG,wBAAgB,gBAAgB;eAKnB,CAAC,SAAS,OAAO,GAAG,MAAM,eAAe,MAAM,GAAG,SAAS,YAAW,UAAU,CAAC,CAAC,CAAC;oCAG9D,MAAM;;8BAOZ,4BAA4B;IAGtD;;;;OAIG;+BAC8B,4BAA4B;oCAiB5C,4BAA4B,QACtC,MAAM,kBACI,OAAO,YACb;QAAE,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;iCA+Bf,4BAA4B,UAAU,MAAM;qCAI9D,4BAA4B,UACpC,MAAM,kBACE,MAAM,GAAG,SAAS,kBAClB,OAAO;wCAaP,4BAA4B,QACtC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,kBACjC,MAAM,GAAG,SAAS,kBAClB,OAAO;iCAWW,4BAA4B,UAAU,MAAM;;;;;;;;;;;EAmBhF;AAyBD,wBAAgB,WAAW,CAC1B,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,0BAA0B,CAAC;;;;;;;;EAYrD;AAED,wBAAgB,UAAU,CACzB,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,0BAA0B,CAAC,UAGrD"}
|
|
@@ -27,13 +27,14 @@ export function createVisContext() {
|
|
|
27
27
|
* Test files include vitest test files and storybook story files.
|
|
28
28
|
* It needs to make sure there is no race condition between the test files.
|
|
29
29
|
*/
|
|
30
|
-
async setupSuite(
|
|
31
|
-
const projectId = getProjectId(
|
|
30
|
+
async setupSuite(browserContext) {
|
|
31
|
+
const projectId = getProjectId(browserContext);
|
|
32
|
+
const visOptions = getVisOptions(visOptionsRecord, browserContext);
|
|
32
33
|
if (!state[projectId]) {
|
|
33
|
-
state[projectId] = setupState(
|
|
34
|
+
state[projectId] = setupState(browserContext, visOptions);
|
|
34
35
|
}
|
|
35
36
|
const projectState = await state[projectId];
|
|
36
|
-
const { suiteId, suite } = createSuite(projectState,
|
|
37
|
+
const { suiteId, suite } = createSuite(projectState, browserContext.testPath, visOptions);
|
|
37
38
|
projectState.suites[suiteId] = suite;
|
|
38
39
|
await Promise.allSettled([ctx.rimraf(suite.diffDir), ctx.rimraf(suite.resultDir)]);
|
|
39
40
|
return pick(projectState, 'subjectDataTestId');
|
|
@@ -73,7 +74,8 @@ export function createVisContext() {
|
|
|
73
74
|
async getSuiteInfo(browserContext, taskId) {
|
|
74
75
|
const projectId = getProjectId(browserContext);
|
|
75
76
|
const projectState = await state[projectId];
|
|
76
|
-
const
|
|
77
|
+
const visOptions = getVisOptions(visOptionsRecord, browserContext);
|
|
78
|
+
const suiteId = getSuiteId(projectState, browserContext.testPath, visOptions);
|
|
77
79
|
const suite = projectState.suites[suiteId];
|
|
78
80
|
const task = (suite.tasks[taskId] = suite.tasks[taskId] ?? { count: 1 });
|
|
79
81
|
return {
|
|
@@ -123,7 +125,7 @@ export function getSuiteId(state, testPath, options) {
|
|
|
123
125
|
return getSnapshotSubpath(relative(state.projectRoot, testPath), options);
|
|
124
126
|
}
|
|
125
127
|
function getVisOptions(visOptionsRecord, context) {
|
|
126
|
-
return visOptionsRecord[getProjectName(context) ?? '__default'];
|
|
128
|
+
return visOptionsRecord[getProjectName(context) ?? '__default'] ?? {};
|
|
127
129
|
}
|
|
128
130
|
function getProjectRoot(context) {
|
|
129
131
|
return context.project.config.root;
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@ export function playwright(context: BrowserCommandContext): BrowserApi {
|
|
|
7
7
|
// The `Locator` type from `vitest` has less props than the `Locator` in `playwright`
|
|
8
8
|
const subject = context.iframe.locator(selector)
|
|
9
9
|
return subject.screenshot({
|
|
10
|
-
timeout: options?.timeout,
|
|
11
10
|
path: filePath,
|
|
11
|
+
...options,
|
|
12
12
|
})
|
|
13
13
|
},
|
|
14
14
|
}
|
|
@@ -31,16 +31,17 @@ export function createVisContext() {
|
|
|
31
31
|
* Test files include vitest test files and storybook story files.
|
|
32
32
|
* It needs to make sure there is no race condition between the test files.
|
|
33
33
|
*/
|
|
34
|
-
async setupSuite(
|
|
35
|
-
const projectId = getProjectId(
|
|
34
|
+
async setupSuite(browserContext: PartialBrowserCommandContext) {
|
|
35
|
+
const projectId = getProjectId(browserContext)
|
|
36
36
|
|
|
37
|
+
const visOptions = getVisOptions(visOptionsRecord, browserContext)
|
|
37
38
|
if (!state[projectId]) {
|
|
38
|
-
state[projectId] = setupState(
|
|
39
|
+
state[projectId] = setupState(browserContext, visOptions)
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
const projectState = await state[projectId]
|
|
42
43
|
|
|
43
|
-
const { suiteId, suite } = createSuite(projectState,
|
|
44
|
+
const { suiteId, suite } = createSuite(projectState, browserContext.testPath, visOptions)
|
|
44
45
|
projectState.suites[suiteId] = suite
|
|
45
46
|
|
|
46
47
|
await Promise.allSettled([ctx.rimraf(suite.diffDir), ctx.rimraf(suite.resultDir)])
|
|
@@ -118,8 +119,8 @@ export function createVisContext() {
|
|
|
118
119
|
async getSuiteInfo(browserContext: PartialBrowserCommandContext, taskId: string) {
|
|
119
120
|
const projectId = getProjectId(browserContext)
|
|
120
121
|
const projectState = await state[projectId]!
|
|
121
|
-
|
|
122
|
-
const suiteId = getSuiteId(projectState, browserContext.testPath,
|
|
122
|
+
const visOptions = getVisOptions(visOptionsRecord, browserContext)
|
|
123
|
+
const suiteId = getSuiteId(projectState, browserContext.testPath, visOptions)
|
|
123
124
|
const suite = projectState.suites[suiteId]!
|
|
124
125
|
const task = (suite.tasks[taskId] = suite.tasks[taskId] ?? { count: 1 })
|
|
125
126
|
return {
|
|
@@ -185,7 +186,7 @@ export function getSuiteId(
|
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
function getVisOptions(visOptionsRecord: Record<string, VisOptions<any>>, context: PartialBrowserCommandContext) {
|
|
188
|
-
return visOptionsRecord[getProjectName(context) ?? '__default']
|
|
189
|
+
return visOptionsRecord[getProjectName(context) ?? '__default'] ?? {}
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
function getProjectRoot(context: PartialBrowserCommandContext) {
|