vitest-plugin-vis 2.4.0 → 2.4.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.
@@ -11,17 +11,15 @@ export declare const visContext: {
11
11
  resultPath: string;
12
12
  diffPath: string;
13
13
  timeout?: number | undefined | undefined;
14
- failureThresholdType?: "pixel" | "percent" | undefined | undefined;
15
- failureThreshold?: number | undefined | undefined;
16
14
  comparisonMethod: any;
17
15
  diffOptions?: Partial<import("ssim.js").Options> | undefined;
16
+ failureThresholdType?: "pixel" | "percent" | undefined | undefined;
17
+ failureThreshold?: number | undefined | undefined;
18
18
  } | {
19
19
  baselinePath: string;
20
20
  resultPath: string;
21
21
  diffPath: string;
22
22
  timeout?: number | undefined | undefined;
23
- failureThresholdType?: "pixel" | "percent" | undefined | undefined;
24
- failureThreshold?: number | undefined | undefined;
25
23
  comparisonMethod?: any;
26
24
  diffOptions?: {
27
25
  threshold?: number | undefined;
@@ -32,6 +30,8 @@ export declare const visContext: {
32
30
  diffColorAlt?: [number, number, number] | undefined;
33
31
  diffMask?: boolean | undefined;
34
32
  } | undefined;
33
+ failureThresholdType?: "pixel" | "percent" | undefined | undefined;
34
+ failureThreshold?: number | undefined | undefined;
35
35
  }>;
36
36
  getTaskCount(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext, taskId: string): Promise<number>;
37
37
  hasImageSnapshot(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext, taskId: string, snapshotFileId: string | undefined, isAutoSnapshot: boolean): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"vis_context.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;sBACq6D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CADj5D,CAAA"}
1
+ {"version":3,"file":"vis_context.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;sBACs3D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CADl2D,CAAA"}
@@ -18,17 +18,15 @@ export declare function createVisContext(): {
18
18
  resultPath: string;
19
19
  diffPath: string;
20
20
  timeout?: number | undefined | undefined;
21
- failureThresholdType?: "pixel" | "percent" | undefined | undefined;
22
- failureThreshold?: number | undefined | undefined;
23
21
  comparisonMethod: any;
24
22
  diffOptions?: Partial<import("ssim.js").Options> | undefined;
23
+ failureThresholdType?: "pixel" | "percent" | undefined | undefined;
24
+ failureThreshold?: number | undefined | undefined;
25
25
  } | {
26
26
  baselinePath: string;
27
27
  resultPath: string;
28
28
  diffPath: string;
29
29
  timeout?: number | undefined | undefined;
30
- failureThresholdType?: "pixel" | "percent" | undefined | undefined;
31
- failureThreshold?: number | undefined | undefined;
32
30
  comparisonMethod?: any;
33
31
  diffOptions?: {
34
32
  threshold?: number | undefined;
@@ -39,6 +37,8 @@ export declare function createVisContext(): {
39
37
  diffColorAlt?: [number, number, number] | undefined;
40
38
  diffMask?: boolean | undefined;
41
39
  } | undefined;
40
+ failureThresholdType?: "pixel" | "percent" | undefined | undefined;
41
+ failureThreshold?: number | undefined | undefined;
42
42
  }>;
43
43
  getTaskCount(browserContext: PartialBrowserCommandContext, taskId: string): Promise<number>;
44
44
  hasImageSnapshot(browserContext: PartialBrowserCommandContext, taskId: string, snapshotFileId: string | undefined, isAutoSnapshot: boolean): Promise<boolean>;
@@ -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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B,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"}
@@ -20,8 +20,7 @@ export function createVisContext() {
20
20
  state = {};
21
21
  },
22
22
  __test__getState(context) {
23
- const projectRoot = getProjectRoot(context);
24
- return state[projectRoot];
23
+ return state[getProjectId(context)];
25
24
  },
26
25
  /**
27
26
  * Setup suite is called on each test file's beforeAll hook.
@@ -29,11 +28,11 @@ export function createVisContext() {
29
28
  * It needs to make sure there is no race condition between the test files.
30
29
  */
31
30
  async setupSuite(context) {
32
- const projectRoot = getProjectRoot(context);
33
- if (!state[projectRoot]) {
34
- state[projectRoot] = setupState(context, getVisOptions(visOptionsRecord, context) ?? {});
31
+ const projectId = getProjectId(context);
32
+ if (!state[projectId]) {
33
+ state[projectId] = setupState(context, getVisOptions(visOptionsRecord, context) ?? {});
35
34
  }
36
- const projectState = await state[projectRoot];
35
+ const projectState = await state[projectId];
37
36
  const { suiteId, suite } = createSuite(projectState, context.testPath, visOptionsRecord);
38
37
  projectState.suites[suiteId] = suite;
39
38
  await Promise.allSettled([ctx.rimraf(suite.diffDir), ctx.rimraf(suite.resultDir)]);
@@ -72,13 +71,13 @@ export function createVisContext() {
72
71
  })}.png`;
73
72
  },
74
73
  async getSuiteInfo(browserContext, taskId) {
75
- const projectRoot = getProjectRoot(browserContext);
76
- const projectState = await state[projectRoot];
74
+ const projectId = getProjectId(browserContext);
75
+ const projectState = await state[projectId];
77
76
  const suiteId = getSuiteId(projectState, browserContext.testPath, visOptionsRecord);
78
77
  const suite = projectState.suites[suiteId];
79
78
  const task = (suite.tasks[taskId] = suite.tasks[taskId] ?? { count: 1 });
80
79
  return {
81
- projectRoot,
80
+ projectRoot: projectState.projectRoot,
82
81
  suiteId,
83
82
  taskId,
84
83
  baselineDir: suite.baselineDir,
@@ -129,3 +128,6 @@ function getVisOptions(visOptionsRecord, context) {
129
128
  function getProjectRoot(context) {
130
129
  return context.project.config.root;
131
130
  }
131
+ function getProjectId(context) {
132
+ return `${context.project.config.root}/${context.project.config.name}`;
133
+ }
@@ -23,6 +23,7 @@ export type VisProjectState = {
23
23
  export type PartialBrowserCommandContext = {
24
24
  project: {
25
25
  config: {
26
+ name: string;
26
27
  root: string;
27
28
  snapshotOptions: {
28
29
  updateSnapshot: 'all' | 'new' | 'none';
@@ -1 +1 @@
1
- {"version":3,"file":"vis_context.types.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACtB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;CAC/C,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,iBAAiB,EAAE,MAAM,CAAA;IACzB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,MAAM,EAAE,MAAM,CACb,MAAM,EACN;QACC,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;QACf,KAAK,EAAE,MAAM,CACZ,MAAM,EACN;YACC,KAAK,EAAE,MAAM,CAAA;SACb,CACD,CAAA;KACD,CACD,CAAA;CACD,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IAC1C,OAAO,EAAE;QACR,MAAM,EAAE;YACP,IAAI,EAAE,MAAM,CAAA;YACZ,eAAe,EAAE;gBAChB,cAAc,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAA;aACtC,CAAA;YACD,WAAW,EAAE,MAAM,CAAA;YACnB,WAAW,EAAE,MAAM,CAAA;SACnB,CAAA;QACD,IAAI,EAAE;YACL,MAAM,EAAE;gBACP,IAAI,CAAC,EAAE;oBACN,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;iBACzB,CAAA;aACD,CAAA;SACD,CAAA;KACD,CAAA;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAChC,OAAO,CAAC,EAAE;YACT,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;YAC9B,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;YACxC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SACxC,CAAA;KACD,CAAA;IACD,QAAQ,EAAE,MAAM,CAAA;CAChB,CAAA"}
1
+ {"version":3,"file":"vis_context.types.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACtB,CAAC,WAAW,E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kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;YACxC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SACxC,CAAA;KACD,CAAA;IACD,QAAQ,EAAE,MAAM,CAAA;CAChB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Visual test configuration on the client side.
3
3
  */
4
- export declare const vis: import("./create_vis.ts").VisClientConfigurator<import("../index.ts").SnapshotMeta<import("../index.ts").ComparisonMethod>>;
4
+ export declare const vis: import("./create_vis.ts").VisClientConfigurator<import("../client.ts").SnapshotMeta<import("../client.ts").ComparisonMethod>>;
5
5
  //# sourceMappingURL=vis.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vis.d.ts","sourceRoot":"","sources":["../../src/setup/vis.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,GAAG,6HAAsB,CAAA"}
1
+ {"version":3,"file":"vis.d.ts","sourceRoot":"","sources":["../../src/setup/vis.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,GAAG,+HAAsB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-plugin-vis",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Vitest visual testing plugin",
5
5
  "keywords": [
6
6
  "image-snapshot",
@@ -58,6 +58,9 @@
58
58
  },
59
59
  "./package.json": "./package.json"
60
60
  },
61
+ "imports": {
62
+ "#vitest-plugin-vis/config": "./src/config.ts"
63
+ },
61
64
  "types": "./esm/index.d.ts",
62
65
  "files": [
63
66
  "esm",
@@ -80,10 +83,10 @@
80
83
  "@types/is-ci": "^3.0.4",
81
84
  "@types/pngjs": "^6.0.5",
82
85
  "@types/react": "^19.0.2",
83
- "@vitest/browser": "^3.0.6",
84
- "@vitest/coverage-istanbul": "^3.0.6",
85
- "@vitest/coverage-v8": "^3.0.6",
86
- "@vitest/expect": "^3.0.6",
86
+ "@vitest/browser": "^3.0.8",
87
+ "@vitest/coverage-istanbul": "^3.0.8",
88
+ "@vitest/coverage-v8": "^3.0.8",
89
+ "@vitest/expect": "^3.0.8",
87
90
  "cross-env": "^7.0.3",
88
91
  "never-fail": "^1.1.4",
89
92
  "npm-run-all2": "^7.0.2",
@@ -92,9 +95,8 @@
92
95
  "react-dom": "^19.0.0",
93
96
  "typescript": "^5.7.2",
94
97
  "vite": "^6.0.9",
95
- "vitest": "^3.0.6",
96
- "vitest-browser-react": "^0.1.0",
97
- "webdriverio": "latest"
98
+ "vitest": "^3.0.8",
99
+ "vitest-browser-react": "^0.1.0"
98
100
  },
99
101
  "peerDependencies": {
100
102
  "@vitest/browser": "^2 || ^3",
@@ -24,8 +24,7 @@ export function createVisContext() {
24
24
  state = {}
25
25
  },
26
26
  __test__getState(context: PartialBrowserCommandContext) {
27
- const projectRoot = getProjectRoot(context)
28
- return state[projectRoot]!
27
+ return state[getProjectId(context)]!
29
28
  },
30
29
  /**
31
30
  * Setup suite is called on each test file's beforeAll hook.
@@ -33,13 +32,13 @@ export function createVisContext() {
33
32
  * It needs to make sure there is no race condition between the test files.
34
33
  */
35
34
  async setupSuite(context: PartialBrowserCommandContext) {
36
- const projectRoot = getProjectRoot(context)
35
+ const projectId = getProjectId(context)
37
36
 
38
- if (!state[projectRoot]) {
39
- state[projectRoot] = setupState(context, getVisOptions(visOptionsRecord, context) ?? {})
37
+ if (!state[projectId]) {
38
+ state[projectId] = setupState(context, getVisOptions(visOptionsRecord, context) ?? {})
40
39
  }
41
40
 
42
- const projectState = await state[projectRoot]
41
+ const projectState = await state[projectId]
43
42
 
44
43
  const { suiteId, suite } = createSuite(projectState, context.testPath, visOptionsRecord)
45
44
  projectState.suites[suiteId] = suite
@@ -117,14 +116,14 @@ export function createVisContext() {
117
116
  })}.png`
118
117
  },
119
118
  async getSuiteInfo(browserContext: PartialBrowserCommandContext, taskId: string) {
120
- const projectRoot = getProjectRoot(browserContext)
121
- const projectState = await state[projectRoot]!
119
+ const projectId = getProjectId(browserContext)
120
+ const projectState = await state[projectId]!
122
121
 
123
122
  const suiteId = getSuiteId(projectState, browserContext.testPath, visOptionsRecord)
124
123
  const suite = projectState.suites[suiteId]!
125
124
  const task = (suite.tasks[taskId] = suite.tasks[taskId] ?? { count: 1 })
126
125
  return {
127
- projectRoot,
126
+ projectRoot: projectState.projectRoot,
128
127
  suiteId,
129
128
  taskId,
130
129
  baselineDir: suite.baselineDir,
@@ -192,3 +191,7 @@ function getVisOptions(visOptionsRecord: Record<string, VisOptions<any>>, contex
192
191
  function getProjectRoot(context: PartialBrowserCommandContext) {
193
192
  return context.project.config.root
194
193
  }
194
+
195
+ function getProjectId(context: PartialBrowserCommandContext) {
196
+ return `${context.project.config.root}/${context.project.config.name}`
197
+ }
@@ -31,6 +31,7 @@ export type VisProjectState = {
31
31
  export type PartialBrowserCommandContext = {
32
32
  project: {
33
33
  config: {
34
+ name: string
34
35
  root: string
35
36
  snapshotOptions: {
36
37
  updateSnapshot: 'all' | 'new' | 'none'