vitest-plugin-vis 3.5.1 → 4.1.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.
Files changed (366) hide show
  1. package/dist/asserts--HSSlgPD.mjs +8 -0
  2. package/dist/asserts--HSSlgPD.mjs.map +1 -0
  3. package/dist/augment-C1tjdh5B.d.mts +33 -0
  4. package/dist/augment-C1tjdh5B.d.mts.map +1 -0
  5. package/dist/auto_snapshot_matcher-C0y6mAeS.mjs +381 -0
  6. package/dist/auto_snapshot_matcher-C0y6mAeS.mjs.map +1 -0
  7. package/dist/auto_snapshot_options-BMRtKmod.d.mts +45 -0
  8. package/dist/auto_snapshot_options-BMRtKmod.d.mts.map +1 -0
  9. package/dist/auto_snapshot_options-DUOTpF2N.mjs +88 -0
  10. package/dist/auto_snapshot_options-DUOTpF2N.mjs.map +1 -0
  11. package/dist/base64-CHSENEAO.mjs +8 -0
  12. package/dist/base64-CHSENEAO.mjs.map +1 -0
  13. package/dist/client-api.d.mts +44 -0
  14. package/dist/client-api.d.mts.map +1 -0
  15. package/dist/client-api.mjs +14 -0
  16. package/dist/client-api.mjs.map +1 -0
  17. package/dist/commands.types-BVhcnnHw.d.mts +51 -0
  18. package/dist/commands.types-BVhcnnHw.d.mts.map +1 -0
  19. package/dist/config.d.mts +28 -0
  20. package/dist/config.d.mts.map +1 -0
  21. package/dist/config.mjs +412 -0
  22. package/dist/config.mjs.map +1 -0
  23. package/dist/constants-CTBaz8Ml.mjs +10 -0
  24. package/dist/constants-CTBaz8Ml.mjs.map +1 -0
  25. package/dist/index.d.mts +5 -0
  26. package/dist/index.mjs +6 -0
  27. package/dist/presets/auto.d.mts +1 -0
  28. package/dist/presets/auto.mjs +19 -0
  29. package/dist/presets/auto.mjs.map +1 -0
  30. package/dist/presets/enable.d.mts +1 -0
  31. package/dist/presets/enable.mjs +15 -0
  32. package/dist/presets/enable.mjs.map +1 -0
  33. package/dist/presets/manual.d.mts +1 -0
  34. package/dist/presets/manual.mjs +15 -0
  35. package/dist/presets/manual.mjs.map +1 -0
  36. package/dist/server-utils.d.mts +19 -0
  37. package/dist/server-utils.d.mts.map +1 -0
  38. package/dist/server-utils.mjs +4 -0
  39. package/dist/setup-DCytWz48.mjs +124 -0
  40. package/dist/setup-DCytWz48.mjs.map +1 -0
  41. package/dist/setup.d.mts +106 -0
  42. package/dist/setup.d.mts.map +1 -0
  43. package/dist/setup.mjs +8 -0
  44. package/dist/snapshot_path-7GliOSH_.mjs +58 -0
  45. package/dist/snapshot_path-7GliOSH_.mjs.map +1 -0
  46. package/dist/src-CSQnlFa9.mjs +1 -0
  47. package/dist/testing.d.mts +12 -0
  48. package/dist/testing.d.mts.map +1 -0
  49. package/dist/testing.mjs +65550 -0
  50. package/dist/testing.mjs.map +1 -0
  51. package/dist/to_match_image_snapshot.types--tTmHoRA.d.mts +9 -0
  52. package/dist/to_match_image_snapshot.types--tTmHoRA.d.mts.map +1 -0
  53. package/dist/trim_common_folder-DBThLerp.d.mts +9 -0
  54. package/dist/trim_common_folder-DBThLerp.d.mts.map +1 -0
  55. package/dist/types-CEmjj-A9.d.mts +144 -0
  56. package/dist/types-CEmjj-A9.d.mts.map +1 -0
  57. package/dist/types-DJYCbyT8.d.mts +63 -0
  58. package/dist/types-DJYCbyT8.d.mts.map +1 -0
  59. package/package.json +55 -39
  60. package/readme.md +58 -6
  61. package/src/client/actions/has_image_snapshot_action.ts +1 -1
  62. package/src/client/actions/load_image_snapshot_results_action.ts +1 -1
  63. package/src/client/actions/match_image_snapshot_action.ts +7 -5
  64. package/src/client/actions/match_page_image_snapshot_action.ts +6 -4
  65. package/src/client/expect/_ctx.ts +10 -0
  66. package/src/client/expect/to_match_image_snapshot.ts +3 -4
  67. package/src/client/external/browser/has_render_content.ts +3 -0
  68. package/src/client/{image_resizer.ts → external/browser/image_resizer.ts} +1 -1
  69. package/src/client/{vitest_browser_context_proxy.ts → external/vitest/vitest_browser_context_proxy.ts} +3 -3
  70. package/src/client/{vitest_suite_proxy.ts → external/vitest/vitest_suite_proxy.ts} +1 -1
  71. package/src/client/{align_images.ts → image/align_images.ts} +3 -3
  72. package/src/client/page/_ctx.ts +12 -0
  73. package/src/client/page/extend.ts +1 -1
  74. package/src/client/page/has_image_snapshot.mdx +1 -1
  75. package/src/client/page/has_image_snapshot.ts +4 -4
  76. package/src/client/page/to_match_image_snapshot.mdx +1 -1
  77. package/src/client/page/to_match_image_snapshot.ts +3 -4
  78. package/src/client/{compare_image_snapshot.logic.ts → snapshot/compare_image_snapshot.logic.ts} +1 -1
  79. package/src/client/{compare_image_snapshot.ts → snapshot/compare_image_snapshot.ts} +8 -9
  80. package/src/client/snapshot/should_take_snapshot.ts +6 -0
  81. package/src/client/suite/_ctx.ts +8 -0
  82. package/src/client/suite/auto_snapshot_matcher.ts +68 -0
  83. package/src/client/{ctx.ts → task/_ctx.ts} +1 -3
  84. package/src/client/{auto_snapshot_options.ts → task/auto_snapshot_options.ts} +20 -5
  85. package/src/client/{snapshot_meta.ts → task/snapshot_meta.ts} +6 -1
  86. package/src/client-api.ts +3 -2
  87. package/src/config/vis.ts +4 -4
  88. package/src/index.ts +1 -1
  89. package/src/server/browser_provider/browser_api.ts +2 -2
  90. package/src/server/browser_provider/playwright.ts +6 -4
  91. package/src/server/browser_provider/webdriverio.ts +3 -3
  92. package/src/server/commands/_assertions.ts +3 -3
  93. package/src/server/commands/augment.ts +9 -7
  94. package/src/server/commands/has_image_snapshot.ts +3 -6
  95. package/src/server/commands/image_snapshot_next_index.ts +3 -9
  96. package/src/server/commands/load_image_snapshot_results.ts +3 -23
  97. package/src/server/commands/prepare_image_snapshot_comparison.ts +4 -50
  98. package/src/server/commands/prepare_page_image_snapshot_comparison.ts +3 -45
  99. package/src/server/commands/setup_vis_suite.ts +3 -27
  100. package/src/server/project.ts +8 -7
  101. package/src/server/snapshot.ts +4 -4
  102. package/src/server/snapshot_path.ts +6 -5
  103. package/src/server/suite.ts +7 -12
  104. package/src/server/testing/stubBrowserCommandContext.ts +16 -0
  105. package/src/{testing → server/testing}/stubSuite.ts +7 -9
  106. package/src/server/testing/stubUserConfig.ts +6 -0
  107. package/src/server/vis_options.ts +4 -5
  108. package/src/server/vis_server_context.logic.ts +8 -8
  109. package/src/server/vis_server_context.types.ts +31 -26
  110. package/src/{client/setup → setup}/create_vis.ts +23 -78
  111. package/src/setup/readme.md +5 -0
  112. package/src/{client/setup → setup}/vis.ts +1 -1
  113. package/src/setup.ts +2 -2
  114. package/src/shared/commands.types.ts +71 -0
  115. package/src/shared/types.ts +55 -1
  116. package/src/testing.ts +0 -1
  117. package/esm/client/actions/has_image_snapshot_action.d.ts +0 -4
  118. package/esm/client/actions/has_image_snapshot_action.d.ts.map +0 -1
  119. package/esm/client/actions/has_image_snapshot_action.js +0 -6
  120. package/esm/client/actions/load_image_snapshot_results_action.d.ts +0 -3
  121. package/esm/client/actions/load_image_snapshot_results_action.d.ts.map +0 -1
  122. package/esm/client/actions/load_image_snapshot_results_action.js +0 -3
  123. package/esm/client/actions/match_image_snapshot_action.d.ts +0 -6
  124. package/esm/client/actions/match_image_snapshot_action.d.ts.map +0 -1
  125. package/esm/client/actions/match_image_snapshot_action.js +0 -20
  126. package/esm/client/actions/match_page_image_snapshot_action.d.ts +0 -6
  127. package/esm/client/actions/match_page_image_snapshot_action.d.ts.map +0 -1
  128. package/esm/client/actions/match_page_image_snapshot_action.js +0 -9
  129. package/esm/client/align_images.d.ts +0 -2
  130. package/esm/client/align_images.d.ts.map +0 -1
  131. package/esm/client/align_images.js +0 -10
  132. package/esm/client/auto_snapshot_options.d.ts +0 -29
  133. package/esm/client/auto_snapshot_options.d.ts.map +0 -1
  134. package/esm/client/auto_snapshot_options.js +0 -49
  135. package/esm/client/compare_image_snapshot.d.ts +0 -6
  136. package/esm/client/compare_image_snapshot.d.ts.map +0 -1
  137. package/esm/client/compare_image_snapshot.js +0 -52
  138. package/esm/client/compare_image_snapshot.logic.d.ts +0 -3
  139. package/esm/client/compare_image_snapshot.logic.d.ts.map +0 -1
  140. package/esm/client/compare_image_snapshot.logic.js +0 -12
  141. package/esm/client/ctx.d.ts +0 -7
  142. package/esm/client/ctx.d.ts.map +0 -1
  143. package/esm/client/ctx.js +0 -11
  144. package/esm/client/expect/augment.d.ts +0 -8
  145. package/esm/client/expect/augment.d.ts.map +0 -1
  146. package/esm/client/expect/augment.js +0 -1
  147. package/esm/client/expect/expectation_result.d.ts +0 -3
  148. package/esm/client/expect/expectation_result.d.ts.map +0 -1
  149. package/esm/client/expect/expectation_result.js +0 -5
  150. package/esm/client/expect/extend.d.ts +0 -2
  151. package/esm/client/expect/extend.d.ts.map +0 -1
  152. package/esm/client/expect/extend.js +0 -4
  153. package/esm/client/expect/to_match_image_snapshot.d.ts +0 -9
  154. package/esm/client/expect/to_match_image_snapshot.d.ts.map +0 -1
  155. package/esm/client/expect/to_match_image_snapshot.js +0 -21
  156. package/esm/client/expect/to_match_image_snapshot.types.d.ts +0 -5
  157. package/esm/client/expect/to_match_image_snapshot.types.d.ts.map +0 -1
  158. package/esm/client/expect/to_match_image_snapshot.types.js +0 -1
  159. package/esm/client/image_data.d.ts +0 -3
  160. package/esm/client/image_data.d.ts.map +0 -1
  161. package/esm/client/image_data.js +0 -33
  162. package/esm/client/image_resizer.d.ts +0 -9
  163. package/esm/client/image_resizer.d.ts.map +0 -1
  164. package/esm/client/image_resizer.js +0 -49
  165. package/esm/client/image_snapshot_options.d.ts +0 -2
  166. package/esm/client/image_snapshot_options.d.ts.map +0 -1
  167. package/esm/client/image_snapshot_options.js +0 -6
  168. package/esm/client/page/augment.d.ts +0 -7
  169. package/esm/client/page/augment.d.ts.map +0 -1
  170. package/esm/client/page/augment.js +0 -1
  171. package/esm/client/page/extend.d.ts +0 -2
  172. package/esm/client/page/extend.d.ts.map +0 -1
  173. package/esm/client/page/extend.js +0 -5
  174. package/esm/client/page/has_image_snapshot.d.ts +0 -10
  175. package/esm/client/page/has_image_snapshot.d.ts.map +0 -1
  176. package/esm/client/page/has_image_snapshot.js +0 -15
  177. package/esm/client/page/to_match_image_snapshot.d.ts +0 -6
  178. package/esm/client/page/to_match_image_snapshot.d.ts.map +0 -1
  179. package/esm/client/page/to_match_image_snapshot.js +0 -15
  180. package/esm/client/selector.d.ts +0 -7
  181. package/esm/client/selector.d.ts.map +0 -1
  182. package/esm/client/selector.js +0 -97
  183. package/esm/client/setup/create_vis.d.ts +0 -96
  184. package/esm/client/setup/create_vis.d.ts.map +0 -1
  185. package/esm/client/setup/create_vis.js +0 -109
  186. package/esm/client/setup/vis.ctx.d.ts +0 -12
  187. package/esm/client/setup/vis.ctx.d.ts.map +0 -1
  188. package/esm/client/setup/vis.ctx.js +0 -32
  189. package/esm/client/setup/vis.d.ts +0 -5
  190. package/esm/client/setup/vis.d.ts.map +0 -1
  191. package/esm/client/setup/vis.js +0 -6
  192. package/esm/client/should_take_snapshot.d.ts +0 -3
  193. package/esm/client/should_take_snapshot.d.ts.map +0 -1
  194. package/esm/client/should_take_snapshot.js +0 -3
  195. package/esm/client/snapshot_meta.d.ts +0 -6
  196. package/esm/client/snapshot_meta.d.ts.map +0 -1
  197. package/esm/client/snapshot_meta.js +0 -1
  198. package/esm/client/task_id.d.ts +0 -7
  199. package/esm/client/task_id.d.ts.map +0 -1
  200. package/esm/client/task_id.js +0 -10
  201. package/esm/client/vitest_browser_context_proxy.d.ts +0 -32
  202. package/esm/client/vitest_browser_context_proxy.d.ts.map +0 -1
  203. package/esm/client/vitest_browser_context_proxy.js +0 -11
  204. package/esm/client/vitest_suite_proxy.d.ts +0 -7
  205. package/esm/client/vitest_suite_proxy.d.ts.map +0 -1
  206. package/esm/client/vitest_suite_proxy.js +0 -8
  207. package/esm/client-api.d.ts +0 -12
  208. package/esm/client-api.d.ts.map +0 -1
  209. package/esm/client-api.js +0 -9
  210. package/esm/commands.d.ts +0 -5
  211. package/esm/commands.d.ts.map +0 -1
  212. package/esm/commands.js +0 -4
  213. package/esm/config/types.d.ts +0 -60
  214. package/esm/config/types.d.ts.map +0 -1
  215. package/esm/config/types.js +0 -1
  216. package/esm/config/vis.d.ts +0 -28
  217. package/esm/config/vis.d.ts.map +0 -1
  218. package/esm/config/vis.js +0 -27
  219. package/esm/config.d.ts +0 -4
  220. package/esm/config.d.ts.map +0 -1
  221. package/esm/config.js +0 -2
  222. package/esm/index.d.ts +0 -5
  223. package/esm/index.d.ts.map +0 -1
  224. package/esm/index.js +0 -4
  225. package/esm/presets/auto.d.ts +0 -2
  226. package/esm/presets/auto.d.ts.map +0 -1
  227. package/esm/presets/auto.js +0 -8
  228. package/esm/presets/enable.d.ts +0 -2
  229. package/esm/presets/enable.d.ts.map +0 -1
  230. package/esm/presets/enable.js +0 -4
  231. package/esm/presets/manual.d.ts +0 -2
  232. package/esm/presets/manual.d.ts.map +0 -1
  233. package/esm/presets/manual.js +0 -4
  234. package/esm/server/browser_provider/browser_api.d.ts +0 -3
  235. package/esm/server/browser_provider/browser_api.d.ts.map +0 -1
  236. package/esm/server/browser_provider/browser_api.js +0 -11
  237. package/esm/server/browser_provider/playwright.d.ts +0 -4
  238. package/esm/server/browser_provider/playwright.d.ts.map +0 -1
  239. package/esm/server/browser_provider/playwright.js +0 -18
  240. package/esm/server/browser_provider/types.d.ts +0 -10
  241. package/esm/server/browser_provider/types.d.ts.map +0 -1
  242. package/esm/server/browser_provider/types.js +0 -1
  243. package/esm/server/browser_provider/webdriverio.d.ts +0 -4
  244. package/esm/server/browser_provider/webdriverio.d.ts.map +0 -1
  245. package/esm/server/browser_provider/webdriverio.js +0 -12
  246. package/esm/server/commands/_assertions.d.ts +0 -5
  247. package/esm/server/commands/_assertions.d.ts.map +0 -1
  248. package/esm/server/commands/_assertions.js +0 -11
  249. package/esm/server/commands/augment.d.ts +0 -11
  250. package/esm/server/commands/augment.d.ts.map +0 -1
  251. package/esm/server/commands/augment.js +0 -1
  252. package/esm/server/commands/commands.d.ts +0 -9
  253. package/esm/server/commands/commands.d.ts.map +0 -1
  254. package/esm/server/commands/commands.js +0 -14
  255. package/esm/server/commands/has_image_snapshot.d.ts +0 -6
  256. package/esm/server/commands/has_image_snapshot.d.ts.map +0 -1
  257. package/esm/server/commands/has_image_snapshot.js +0 -6
  258. package/esm/server/commands/image_snapshot_next_index.d.ts +0 -9
  259. package/esm/server/commands/image_snapshot_next_index.d.ts.map +0 -1
  260. package/esm/server/commands/image_snapshot_next_index.js +0 -6
  261. package/esm/server/commands/load_image_snapshot_results.d.ts +0 -21
  262. package/esm/server/commands/load_image_snapshot_results.d.ts.map +0 -1
  263. package/esm/server/commands/load_image_snapshot_results.js +0 -6
  264. package/esm/server/commands/prepare_image_snapshot_comparison.d.ts +0 -38
  265. package/esm/server/commands/prepare_image_snapshot_comparison.d.ts.map +0 -1
  266. package/esm/server/commands/prepare_image_snapshot_comparison.js +0 -34
  267. package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts +0 -35
  268. package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts.map +0 -1
  269. package/esm/server/commands/prepare_page_image_snapshot_comparison.js +0 -27
  270. package/esm/server/commands/setup_vis_suite.d.ts +0 -15
  271. package/esm/server/commands/setup_vis_suite.d.ts.map +0 -1
  272. package/esm/server/commands/setup_vis_suite.js +0 -6
  273. package/esm/server/commands/types.d.ts +0 -3
  274. package/esm/server/commands/types.d.ts.map +0 -1
  275. package/esm/server/commands/types.js +0 -1
  276. package/esm/server/externals/file.d.ts +0 -10
  277. package/esm/server/externals/file.d.ts.map +0 -1
  278. package/esm/server/externals/file.js +0 -20
  279. package/esm/server/project.d.ts +0 -21
  280. package/esm/server/project.d.ts.map +0 -1
  281. package/esm/server/project.js +0 -13
  282. package/esm/server/snapshot.d.ts +0 -6
  283. package/esm/server/snapshot.d.ts.map +0 -1
  284. package/esm/server/snapshot.js +0 -29
  285. package/esm/server/snapshot_path.d.ts +0 -14
  286. package/esm/server/snapshot_path.d.ts.map +0 -1
  287. package/esm/server/snapshot_path.js +0 -34
  288. package/esm/server/snapshot_writer.d.ts +0 -13
  289. package/esm/server/snapshot_writer.d.ts.map +0 -1
  290. package/esm/server/snapshot_writer.js +0 -15
  291. package/esm/server/suite.d.ts +0 -54
  292. package/esm/server/suite.d.ts.map +0 -1
  293. package/esm/server/suite.js +0 -73
  294. package/esm/server/vis_options.d.ts +0 -19
  295. package/esm/server/vis_options.d.ts.map +0 -1
  296. package/esm/server/vis_options.js +0 -14
  297. package/esm/server/vis_server_context.d.ts +0 -50
  298. package/esm/server/vis_server_context.d.ts.map +0 -1
  299. package/esm/server/vis_server_context.deps.d.ts +0 -29
  300. package/esm/server/vis_server_context.deps.d.ts.map +0 -1
  301. package/esm/server/vis_server_context.deps.js +0 -10
  302. package/esm/server/vis_server_context.js +0 -2
  303. package/esm/server/vis_server_context.logic.d.ts +0 -53
  304. package/esm/server/vis_server_context.logic.d.ts.map +0 -1
  305. package/esm/server/vis_server_context.logic.js +0 -79
  306. package/esm/server/vis_server_context.types.d.ts +0 -54
  307. package/esm/server/vis_server_context.types.d.ts.map +0 -1
  308. package/esm/server/vis_server_context.types.js +0 -1
  309. package/esm/server-utils.d.ts +0 -4
  310. package/esm/server-utils.d.ts.map +0 -1
  311. package/esm/server-utils.js +0 -3
  312. package/esm/setup.d.ts +0 -5
  313. package/esm/setup.d.ts.map +0 -1
  314. package/esm/setup.js +0 -5
  315. package/esm/shared/asserts.d.ts +0 -2
  316. package/esm/shared/asserts.d.ts.map +0 -1
  317. package/esm/shared/asserts.js +0 -5
  318. package/esm/shared/base64.d.ts +0 -2
  319. package/esm/shared/base64.d.ts.map +0 -1
  320. package/esm/shared/base64.js +0 -3
  321. package/esm/shared/compare_image.d.ts +0 -6
  322. package/esm/shared/compare_image.d.ts.map +0 -1
  323. package/esm/shared/compare_image.js +0 -42
  324. package/esm/shared/constants.d.ts +0 -6
  325. package/esm/shared/constants.d.ts.map +0 -1
  326. package/esm/shared/constants.js +0 -5
  327. package/esm/shared/convert_threshold_unit.d.ts +0 -6
  328. package/esm/shared/convert_threshold_unit.d.ts.map +0 -1
  329. package/esm/shared/convert_threshold_unit.js +0 -10
  330. package/esm/shared/get_max_size.d.ts +0 -11
  331. package/esm/shared/get_max_size.d.ts.map +0 -1
  332. package/esm/shared/get_max_size.js +0 -5
  333. package/esm/shared/is_same_size.d.ts +0 -8
  334. package/esm/shared/is_same_size.d.ts.map +0 -1
  335. package/esm/shared/is_same_size.js +0 -3
  336. package/esm/shared/trim_common_folder.d.ts +0 -6
  337. package/esm/shared/trim_common_folder.d.ts.map +0 -1
  338. package/esm/shared/trim_common_folder.js +0 -11
  339. package/esm/shared/types.d.ts +0 -90
  340. package/esm/shared/types.d.ts.map +0 -1
  341. package/esm/shared/types.js +0 -1
  342. package/esm/testing/constants.d.ts +0 -9
  343. package/esm/testing/constants.d.ts.map +0 -1
  344. package/esm/testing/constants.js +0 -1933
  345. package/esm/testing/stubBrowserCommandContext.d.ts +0 -8
  346. package/esm/testing/stubBrowserCommandContext.d.ts.map +0 -1
  347. package/esm/testing/stubBrowserCommandContext.js +0 -12
  348. package/esm/testing/stubSuite.d.ts +0 -10
  349. package/esm/testing/stubSuite.d.ts.map +0 -1
  350. package/esm/testing/stubSuite.js +0 -27
  351. package/esm/testing/stubUserConfig.d.ts +0 -7
  352. package/esm/testing/stubUserConfig.d.ts.map +0 -1
  353. package/esm/testing/stubUserConfig.js +0 -4
  354. package/esm/testing.d.ts +0 -3
  355. package/esm/testing.d.ts.map +0 -1
  356. package/esm/testing.js +0 -2
  357. package/src/client/image_snapshot_options.ts +0 -6
  358. package/src/client/setup/vis.ctx.ts +0 -33
  359. package/src/client/should_take_snapshot.ts +0 -5
  360. package/src/server/commands/types.ts +0 -9
  361. package/src/testing/stubBrowserCommandContext.ts +0 -16
  362. package/src/testing/stubUserConfig.ts +0 -6
  363. /package/src/client/{image_data.ts → external/browser/image_data.ts} +0 -0
  364. /package/src/client/{selector.ts → external/browser/selector.ts} +0 -0
  365. /package/src/client/{auto_snapshot_options.mdx → task/auto_snapshot_options.mdx} +0 -0
  366. /package/src/client/{task_id.ts → task/task_id.ts} +0 -0
@@ -0,0 +1,9 @@
1
+ import { _ as ToMatchImageSnapshotOptions, n as ComparisonMethod } from "./types-CEmjj-A9.mjs";
2
+
3
+ //#region src/client/expect/to_match_image_snapshot.types.d.ts
4
+ interface ImageSnapshotMatcher {
5
+ toMatchImageSnapshot<M extends ComparisonMethod>(options?: ToMatchImageSnapshotOptions<M> | undefined): Promise<void>;
6
+ }
7
+ //#endregion
8
+ export { ImageSnapshotMatcher as t };
9
+ //# sourceMappingURL=to_match_image_snapshot.types--tTmHoRA.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to_match_image_snapshot.types--tTmHoRA.d.mts","names":[],"sources":["../src/client/expect/to_match_image_snapshot.types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,oBAAA;iCACe,4BAA4B,4BAA4B,iBAAiB;AADzG"}
@@ -0,0 +1,9 @@
1
+ //#region src/shared/trim_common_folder.d.ts
2
+ /**
3
+ * Trim off common folder such as `src` or `tests` from the test file path.
4
+ * This is used to generate the default snapshot sub-path.
5
+ */
6
+ declare function trimCommonFolder(suiteName: string): string;
7
+ //#endregion
8
+ export { trimCommonFolder as t };
9
+ //# sourceMappingURL=trim_common_folder-DBThLerp.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trim_common_folder-DBThLerp.d.mts","names":[],"sources":["../src/shared/trim_common_folder.ts"],"sourcesContent":[],"mappings":";;AAIA;;;iBAAgB,gBAAA"}
@@ -0,0 +1,144 @@
1
+ import pixelMatch from "pixelmatch";
2
+ import { Options as SsimDiffOptions } from "ssim.js";
3
+
4
+ //#region src/client/task/snapshot_meta.d.ts
5
+ type SnapshotMeta<M extends ComparisonMethod> = ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions & {
6
+ /**
7
+ * Whether to enable the snapshot.
8
+ *
9
+ * Default: `true`
10
+ */
11
+ enable?: boolean | undefined;
12
+ [key: string]: unknown;
13
+ };
14
+ //#endregion
15
+ //#region src/shared/constants.d.ts
16
+ declare const NAME = "vis";
17
+ declare const SNAPSHOT_ROOT_DIR = "__vis__";
18
+ declare const BASELINE_DIR = "__baselines__";
19
+ declare const RESULT_DIR = "__results__";
20
+ declare const DIFF_DIR = "__diffs__";
21
+ //#endregion
22
+ //#region src/shared/types.d.ts
23
+ type Awaitable<T> = T | PromiseLike<T>;
24
+ interface ImageSnapshotTimeoutOptions {
25
+ /**
26
+ * Timeout for taking the snapshot.
27
+ *
28
+ * Default: 30000 ms (30 seconds)
29
+ */
30
+ timeout?: number | undefined;
31
+ }
32
+ interface ImageSnapshotKeyOptions {
33
+ /**
34
+ * Customize the `snapshotKey` of the snapshot.
35
+ */
36
+ snapshotKey?: string | undefined;
37
+ }
38
+ type ComparisonMethod = 'pixel' | 'ssim';
39
+ type FailureThresholdOptions = {
40
+ /**
41
+ * Failure threshold should measure in `pixel` or `percent`.
42
+ *
43
+ * Default is `pixel`.
44
+ */
45
+ failureThresholdType?: 'pixel' | 'percent' | undefined;
46
+ /**
47
+ * Failure tolerance threshold.
48
+ *
49
+ * If `failureThresholdType` is `pixel`, the value is the number of pixels that are allowed to be different.
50
+ * If `failureThresholdType` is `percent`, the value is the percentage of pixels that are allowed to be different.
51
+ *
52
+ * Default is `0`.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * // Allow 10 pixels to be different
57
+ * failureThresholdType: 'pixel'
58
+ * failureThreshold: 10
59
+ *
60
+ * // Allow 10% of pixels to be different
61
+ * failureThresholdType: 'percent'
62
+ * failureThreshold: 10
63
+ * ```
64
+ */
65
+ failureThreshold?: number | undefined;
66
+ };
67
+ type SsimComparisonOptions<M = 'ssim'> = {
68
+ comparisonMethod: M;
69
+ /**
70
+ * Custom options passed to 'ssim'
71
+ */
72
+ diffOptions?: Partial<SsimDiffOptions> | undefined;
73
+ };
74
+ type PixelComparisonOptions<M = 'pixel'> = {
75
+ comparisonMethod?: M | undefined;
76
+ /**
77
+ * Custom options passed to 'pixelmatch'
78
+ */
79
+ diffOptions?: PixelDiffOptions | undefined;
80
+ };
81
+ type PixelDiffOptions = Parameters<typeof pixelMatch>[5];
82
+ type ImageSnapshotCompareOptions<M extends ComparisonMethod = 'pixel'> = (M extends 'ssim' ? SsimComparisonOptions<M> : PixelComparisonOptions<M>) & FailureThresholdOptions;
83
+ type ImageSnapshotSubjectOptions = {
84
+ /**
85
+ * Specify the query of the subject element.
86
+ *
87
+ * If the test does not have an element with the specified query,
88
+ * the `body` element will be used.
89
+ */
90
+ subject?: string | undefined;
91
+ };
92
+ type ToMatchImageSnapshotOptions<M extends ComparisonMethod = 'pixel'> = ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & ImageSnapshotCompareOptions<M> & {
93
+ /**
94
+ * Expect the matcher to fail.
95
+ * If it passes, it will throw an error with details.
96
+ */
97
+ expectToFail?: boolean | undefined;
98
+ };
99
+ interface PageImageSnapshotOptions {
100
+ fullPage?: boolean | undefined;
101
+ }
102
+ type ToMatchPageImageSnapshotOptions<M extends ComparisonMethod = 'pixel'> = ToMatchImageSnapshotOptions<M> & PageImageSnapshotOptions;
103
+ type SnapshotTestMeta = {
104
+ meta: {
105
+ [NAME]?: SnapshotMeta<ComparisonMethod>;
106
+ };
107
+ };
108
+ type ImageSnapshotComparisonInfo = {
109
+ /**
110
+ * Path to the project root.
111
+ */
112
+ projectRoot: string;
113
+ /**
114
+ * Path to the baseline image relative to the project root.
115
+ */
116
+ baselinePath: string;
117
+ /**
118
+ * Path to the result image relative to the project root.
119
+ */
120
+ resultPath: string;
121
+ /**
122
+ * Path to the diff image relative to the project root.
123
+ */
124
+ diffPath: string;
125
+ /**
126
+ * Base64 encoded baseline image.
127
+ */
128
+ baseline: string;
129
+ /**
130
+ * Base64 encoded result image.
131
+ */
132
+ result: string;
133
+ /**
134
+ * Base64 encoded diff image.
135
+ */
136
+ diff?: string | undefined;
137
+ } & ImageSnapshotTimeoutOptions & FailureThresholdOptions & (SsimComparisonOptions | PixelComparisonOptions);
138
+ type MatchImageSnapshotOptions = ImageSnapshotTimeoutOptions & ImageSnapshotCompareOptions<any> & ImageSnapshotKeyOptions;
139
+ type SetupVisOptions<GM extends Record<string, any> | unknown = unknown> = {
140
+ auto?: boolean | (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void) | Record<string, boolean | (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>;
141
+ };
142
+ //#endregion
143
+ export { SNAPSHOT_ROOT_DIR as C, RESULT_DIR as S, ToMatchImageSnapshotOptions as _, ImageSnapshotComparisonInfo as a, DIFF_DIR as b, ImageSnapshotTimeoutOptions as c, PixelComparisonOptions as d, PixelDiffOptions as f, SsimDiffOptions as g, SsimComparisonOptions as h, ImageSnapshotCompareOptions as i, MatchImageSnapshotOptions as l, SnapshotTestMeta as m, ComparisonMethod as n, ImageSnapshotKeyOptions as o, SetupVisOptions as p, FailureThresholdOptions as r, ImageSnapshotSubjectOptions as s, Awaitable as t, PageImageSnapshotOptions as u, ToMatchPageImageSnapshotOptions as v, SnapshotMeta as w, NAME as x, BASELINE_DIR as y };
144
+ //# sourceMappingURL=types-CEmjj-A9.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-CEmjj-A9.d.mts","names":[],"sources":["../src/client/task/snapshot_meta.ts","../src/shared/constants.ts","../src/shared/types.ts"],"sourcesContent":[],"mappings":";;;;KAEY,uBAAuB,oBAAoB,4BAA4B,KAClF;;;AADD;;;EAAuD,MAAA,CAAA,EAAA,OAAA,GAAA,SAAA;EACtD,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;CAA2B;;;cCHf,IAAA;cACA,iBAAA;cACA,YAAA;cACA,UAAA;ADDD,cCEC,QAAA,GDFW,WAAA;;;AAAZ,KEGA,SFHY,CAAA,CAAA,CAAA,GEGG,CFHH,GEGO,WFHP,CEGmB,CFHnB,CAAA;AAAW,UEKlB,2BAAA,CFLkB;EAAgD;;;;;;;ACFtE,UCgBI,uBAAA,CDhBA;EACJ;AACb;AACA;EACa,WAAQ,CAAA,EAAA,MAAA,GAAA,SAAA;;KCmBT,gBAAA;KAEA,uBAAA;EApBA;;;;;EAEK,oBAAA,CAAA,EAAA,OAA2B,GAAA,SAAA,GAAA,SAAA;EAS3B;AAOjB;AAEA;AA6BA;;;;;AAUA;AAQA;AAEA;;;;;;;;;EAKY,gBAAA,CAAA,EAAA,MAAA,GAAA,SAA2B;AASvC,CAAA;AAAkD,KAlCtC,qBAkCsC,CAAA,IAAA,MAAA,CAAA,GAAA;EAA8B,gBAAA,EAjC7D,CAiC6D;EAC/E;;;EAC2B,WAAA,CAAA,EA/Bb,OA+Ba,CA/BL,eA+BK,CAAA,GAAA,SAAA;AAQ5B,CAAA;AAIsD,KAtC1C,sBAsC0C,CAAA,IAAA,OAAA,CAAA,GAAA;EAA0D,gBAAA,CAAA,EArC5F,CAqC4F,GAAA,SAAA;EAA5B;;;EAGxE,WAAA,CAAA,EApCG,gBAoCa,GAAA,SAAA;CAEJ;AAAb,KAnCC,gBAAA,GAAmB,UAmCpB,CAAA,OAnCsC,UAmCtC,CAAA,CAAA,CAAA,CAAA;AAAR,KAjCS,2BAiCT,CAAA,UAjC+C,gBAiC/C,GAAA,OAAA,CAAA,GAAA,CAjC8E,CAiC9E,SAAA,MAAA,GAhCA,qBAgCA,CAhCsB,CAgCtB,CAAA,GA/BA,sBA+BA,CA/BuB,CA+BvB,CAAA,CAAA,GA9BF,uBA8BE;AAAI,KA5BK,2BAAA,GA4BL;EAIK;;;;;;EAiCA,OAAA,CAAA,EAAA,MAAA,GAAA,SAAyB;CAAG;AACvC,KAzDW,2BAyDX,CAAA,UAzDiD,gBAyDjD,GAAA,OAAA,CAAA,GAzD+E,2BAyD/E,GAxDA,uBAwDA,GAvDA,2BAuDA,CAvD4B,CAuD5B,CAAA,GAAA;EACA;;AAED;;EAGgB,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA;CAA4B;AAClB,UAtDT,wBAAA,CAsDS;EAAb,QAAA,CAAA,EAAA,OAAA,GAAA,SAAA;;AAAsB,KAlDvB,+BAkDuB,CAAA,UAlDmB,gBAkDnB,GAAA,OAAA,CAAA,GAlDiD,2BAkDjD,CAlD6E,CAkD7E,CAAA,GAjDlC,wBAiDkC;AAC1B,KAhDG,gBAAA,GAgDH;EAAmB,IAAA,EAAA;IAIV,CAlDf,IAAA,EAkDe,EAlDP,YAkDO,CAlDM,gBAkDN,CAAA;EAA4B,CAAA;CAClB;AAAb,KA/CH,2BAAA,GA+CG;EAAkB;;;EACH,WAAA,EAAA,MAAA;EAL1B;;;;;;;;;;;;;;;;;;;;;;;;IAdA,8BACH,2BACC,wBAAwB;KAEd,yBAAA,GAA4B,8BACvC,mCACA;KAEW,2BAA2B;+BAGvB,4BAA4B,kDAC/B,aAAa,KAAK,IAAI,OAC1B,mBAAmB,kCACxB,qCAGc,4BAA4B,kDAC/B,aAAa,KAAK,IAAI,OAC1B,mBAAmB"}
@@ -0,0 +1,63 @@
1
+ import { c as ImageSnapshotTimeoutOptions, f as PixelDiffOptions, g as SsimDiffOptions, n as ComparisonMethod, o as ImageSnapshotKeyOptions, r as FailureThresholdOptions, s as ImageSnapshotSubjectOptions } from "./types-CEmjj-A9.mjs";
2
+
3
+ //#region src/config/types.d.ts
4
+ type VisOptions<M extends ComparisonMethod = 'pixel'> = (M extends 'ssim' ? {
5
+ comparisonMethod: M;
6
+ /**
7
+ * Custom options passed to 'ssim'
8
+ */
9
+ diffOptions?: Partial<SsimDiffOptions> | undefined;
10
+ } : {
11
+ comparisonMethod?: M | undefined;
12
+ /**
13
+ * Custom options passed to 'pixelmatch'
14
+ */
15
+ diffOptions?: PixelDiffOptions | undefined;
16
+ }) & FailureThresholdOptions & ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & ImageSnapshotSubjectOptions & {
17
+ /**
18
+ * Loads the `test.setupFiles` of the specified preset.
19
+ *
20
+ * Note:
21
+ * - 'enable` is deprecated. Use `manual` for the same effect.
22
+ * - 'none` is deprecated. Use `custom` for the same effect.
23
+ *
24
+ * @default 'auto'
25
+ *
26
+ */
27
+ preset?: 'enable' | 'manual' | 'auto' | 'custom' | 'none' | undefined;
28
+ /**
29
+ * The snapshot folder relative to the root of the project.
30
+ *
31
+ * Default: `{projectRoot}/__vis__/{platform}`
32
+ */
33
+ snapshotRootDir?: string | ((context: {
34
+ ci: boolean;
35
+ browserName?: string | undefined;
36
+ providerName: string;
37
+ platform: string;
38
+ screenshotFailures?: boolean | undefined;
39
+ screenshotDirectory?: string | undefined;
40
+ }) => string) | undefined;
41
+ /**
42
+ * Customize the snapshot subpath.
43
+ *
44
+ * Typically, you place your test files either in a dedicated `tests` folder or in the `src` folder along with your source code.
45
+ * By default, the snapshot subpath is the test file path with that folder removed to reduces nesting of the snapshot folders.
46
+ *
47
+ * If you place your test files in multiple folders,
48
+ * such as in both `tests` and `src` folders,
49
+ * and they might have files with the same name and create conflicting snapshots,
50
+ * you can set this to customize the snapshot subpath.
51
+ *
52
+ * @param options - Options for customizing the snapshot subpath.
53
+ * @property subPath - The path of the test file to be used as the snapshot subpath.
54
+ * To retain the full path, simply return it.
55
+ * @returns The customized snapshot subpath.
56
+ */
57
+ snapshotSubpath?: ((options: {
58
+ subpath: string;
59
+ }) => string) | undefined;
60
+ };
61
+ //#endregion
62
+ export { VisOptions as t };
63
+ //# sourceMappingURL=types-DJYCbyT8.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DJYCbyT8.d.mts","names":[],"sources":["../src/config/types.ts"],"sourcesContent":[],"mappings":";;;KAcY,qBAAqB,+BAA+B;EAApD,gBAAU,EAED,CAFC;EAAW;;;EAMR,WAAA,CAAA,EAAR,OAAQ,CAAA,eAAA,CAAA,GAAA,SAAA;CAAR,GAAA;EAGK,gBAAA,CAAA,EAAA,CAAA,GAAA,SAAA;EAIL;;;EAIhB,WAAA,CAAA,EAJgB,gBAIhB,GAAA,SAAA;CACA,CAAA,GAHA,uBAGA,GAFA,2BAEA,GADA,uBACA,GAAA,2BAAA,GAAA;EAA2B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-plugin-vis",
3
- "version": "3.5.1",
3
+ "version": "4.1.0",
4
4
  "description": "Vitest visual testing plugin",
5
5
  "keywords": [
6
6
  "image-snapshot",
@@ -20,50 +20,51 @@
20
20
  },
21
21
  "type": "module",
22
22
  "imports": {
23
- "#vitest-plugin-vis/config": "./src/config.ts"
23
+ "#vitest-plugin-vis/config": "./src/config.ts",
24
+ "#vitest-plugin-vis/setup": "./src/setup.ts"
24
25
  },
25
26
  "exports": {
26
27
  ".": {
27
- "types": "./esm/index.d.ts",
28
- "default": "./esm/index.js"
28
+ "types": "./dist/index.d.mts",
29
+ "default": "./dist/index.mjs"
29
30
  },
30
31
  "./config": {
31
- "types": "./esm/config.d.ts",
32
- "default": "./esm/config.js"
32
+ "types": "./dist/config.d.mts",
33
+ "default": "./dist/config.mjs"
33
34
  },
34
35
  "./client-api": {
35
- "types": "./esm/client-api.d.ts",
36
- "default": "./esm/client-api.js"
36
+ "types": "./dist/client-api.d.mts",
37
+ "default": "./dist/client-api.mjs"
37
38
  },
38
39
  "./presets/auto": {
39
- "types": "./esm/presets/auto.d.ts",
40
- "default": "./esm/presets/auto.js"
40
+ "types": "./dist/presets/auto.d.mts",
41
+ "default": "./dist/presets/auto.mjs"
41
42
  },
42
43
  "./presets/enable": {
43
- "types": "./esm/presets/enable.d.ts",
44
- "default": "./esm/presets/enable.js"
44
+ "types": "./dist/presets/enable.d.mts",
45
+ "default": "./dist/presets/enable.mjs"
45
46
  },
46
47
  "./presets/manual": {
47
- "types": "./esm/presets/manual.d.ts",
48
- "default": "./esm/presets/manual.js"
48
+ "types": "./dist/presets/manual.d.mts",
49
+ "default": "./dist/presets/manual.mjs"
49
50
  },
50
51
  "./server-utils": {
51
- "types": "./esm/server-utils.d.ts",
52
- "default": "./esm/server-utils.js"
52
+ "types": "./dist/server-utils.d.mts",
53
+ "default": "./dist/server-utils.mjs"
53
54
  },
54
55
  "./setup": {
55
- "types": "./esm/setup.d.ts",
56
- "default": "./esm/setup.js"
56
+ "types": "./dist/setup.d.mts",
57
+ "default": "./dist/setup.mjs"
57
58
  },
58
59
  "./testing": {
59
- "types": "./esm/testing.d.ts",
60
- "default": "./esm/testing.js"
60
+ "types": "./dist/testing.d.mts",
61
+ "default": "./dist/testing.mjs"
61
62
  },
62
63
  "./package.json": "./package.json"
63
64
  },
64
- "types": "./esm/index.d.ts",
65
+ "types": "./dist/index.d.mts",
65
66
  "files": [
66
- "esm",
67
+ "dist",
67
68
  "src",
68
69
  "!**/*.{spec,test,unit,accept,integrate,system,perf,stress}.*"
69
70
  ],
@@ -80,44 +81,58 @@
80
81
  "type-plus": "8.0.0-beta.7"
81
82
  },
82
83
  "devDependencies": {
83
- "@repobuddy/storybook": "^2.0.0",
84
+ "@repobuddy/storybook": "^2.1.2",
84
85
  "@repobuddy/typescript": "^2.1.0",
85
- "@storybook-community/storybook-dark-mode": "^7.0.0",
86
- "@storybook/addon-docs": "^10.0.6",
87
- "@storybook/addon-vitest": "^9.1.13",
88
- "@storybook/react-vite": "^9.1.15",
86
+ "@storybook-community/storybook-dark-mode": "^7.0.3",
87
+ "@storybook/addon-docs": "^10.2.0-alpha.1",
88
+ "@storybook/addon-vitest": "^10.2.0-alpha.1",
89
+ "@storybook/react-vite": "^10.2.0-alpha.1",
89
90
  "@tailwindcss/vite": "^4.1.14",
90
91
  "@types/is-ci": "^3.0.4",
91
92
  "@types/pngjs": "^6.0.5",
92
93
  "@types/react": "^19.2.2",
93
- "@vitest/browser": "^3.2.4",
94
- "@vitest/coverage-istanbul": "^4.0.3",
95
- "@vitest/coverage-v8": "^3.2.4",
96
- "@vitest/expect": "^4.0.6",
94
+ "@vitest/browser": "^4.0.9",
95
+ "@vitest/browser-playwright": "^4.0.9",
96
+ "@vitest/browser-webdriverio": "^4.0.9",
97
+ "@vitest/coverage-istanbul": "^4.0.9",
98
+ "@vitest/coverage-v8": "^4.0.9",
99
+ "@vitest/expect": "^4.0.9",
100
+ "@vitest/ui": "4.0.9",
97
101
  "cross-env": "^10.0.0",
98
102
  "never-fail": "^1.1.4",
99
103
  "npm-run-all2": "^8.0.0",
100
104
  "react": "^19.0.0",
101
105
  "react-dom": "^19.0.0",
102
- "storybook": "^9.1.10",
103
- "storybook-addon-tag-badges": "^3.0.0",
106
+ "storybook": "^10.2.0-alpha.1",
107
+ "storybook-addon-tag-badges": "^3.0.2",
104
108
  "tailwindcss": "^4.1.14",
109
+ "tsdown": "^0.16.6",
105
110
  "typescript": "^5.9.3",
106
111
  "vite": "^7.1.12",
107
- "vitest": "^3.2.4",
108
- "vitest-browser-react": "^1.0.0"
112
+ "vitest": "^4.0.9",
113
+ "vitest-browser-react": "^2.0.2"
109
114
  },
110
115
  "peerDependencies": {
111
- "@vitest/browser": "^2 || ^3",
112
- "vitest": "^2 || ^3"
116
+ "@vitest/browser": "^4",
117
+ "@vitest/browser-playwright": "^4",
118
+ "@vitest/browser-webdriverio": "^4",
119
+ "vitest": "^4"
120
+ },
121
+ "peerDependenciesMeta": {
122
+ "@vitest/browser-playwright": {
123
+ "optional": true
124
+ },
125
+ "@vitest/browser-webdriverio": {
126
+ "optional": true
127
+ }
113
128
  },
114
129
  "publishConfig": {
115
130
  "access": "public"
116
131
  },
117
132
  "scripts": {
118
- "build": "tsc -b tsconfig.esm.json",
133
+ "build": "tsdown",
119
134
  "build:watch": "tsc -b tsconfig.esm.json -w",
120
- "clean": "rimraf coverage esm --glob *.tsbuildinfo vitest.*.timestamp*",
135
+ "clean": "rimraf coverage dist esm --glob *.tsbuildinfo vitest.*.timestamp*",
121
136
  "clean:vis:local": "rimraf __vis__/local",
122
137
  "cov": "cross-env COVERAGE=true vitest run --coverage",
123
138
  "coverage": "cross-env COVERAGE=true vitest run --coverage",
@@ -127,6 +142,7 @@
127
142
  "sb": "storybook dev -p 6007",
128
143
  "t:node": "vitest --project=vpv:node",
129
144
  "t:pw": "vitest run --project=\"vpv:pw (*)\"",
145
+ "t:t": "tsc --noEmit",
130
146
  "t:wd": "vitest run --project=\"vpv:wd (*)\"",
131
147
  "test": "vitest run",
132
148
  "test:u": "vitest run -u",
package/readme.md CHANGED
@@ -26,6 +26,7 @@ The [`vitest-plugin-vis`][vitest-plugin-vis] plugin can be used without customiz
26
26
 
27
27
  ```ts
28
28
  // vitest.config.ts
29
+ import { playwright } from '@vitest/browser-playwright'
29
30
  import { defineConfig } from 'vitest/config'
30
31
  import { vis } from 'vitest-plugin-vis/config'
31
32
 
@@ -45,6 +46,14 @@ export default defineConfig({
45
46
  instances: [
46
47
  { browser: 'chromium' }
47
48
  ]
49
+ },
50
+ // vitest v4
51
+ browser: {
52
+ enabled: true,
53
+ provider: playwright(),
54
+ instances: [
55
+ { browser: 'chromium' }
56
+ ]
48
57
  }
49
58
  }
50
59
  })
@@ -166,7 +175,50 @@ By default, the plugin will trim the common folder such as `src` or `test` from
166
175
  If you place your test files in multiple folders,
167
176
  such as in both `tests` and `src` folders,
168
177
  and they might have files with the same name and create conflicting snapshots,
169
- you can customize it.
178
+ you can use `snapshotSubpath` to customize the snapshot sub-path to avoid conflicts.
179
+
180
+ ```ts
181
+ // vitest.config.ts
182
+ import { storybookVis } from 'storybook-addon-vis/vitest-plugin'
183
+ import { defineConfig } from 'vitest/config'
184
+
185
+ export default defineConfig({
186
+ plugins: [
187
+ storybookVis({
188
+ // keep the folder structure
189
+ snapshotSubpath: (subpath) => subpath
190
+ })
191
+ ],
192
+ // ...
193
+ })
194
+ ```
195
+
196
+ With the above configuration, the snapshot folder structure will look like this:
197
+
198
+ ```ini
199
+ v __vis__
200
+ > # ...
201
+ v local # snapshot generated on local machine
202
+ > __baselines__
203
+ v examples
204
+ v button.stories.tsx
205
+ snapshot-1.png
206
+ snapshot-2.png
207
+ v src
208
+ v button.stories.tsx
209
+ snapshot-1.png
210
+ snapshot-2.png
211
+ v tests
212
+ v button.stories.tsx
213
+ snapshot-1.png
214
+ snapshot-2.png
215
+ v examples
216
+ button.stories.tsx
217
+ v src
218
+ button.stories.tsx
219
+ v tests
220
+ button.stories.tsx
221
+ ```
170
222
 
171
223
  > `MyComponent/className/can-customize-className`: `snapshotId`
172
224
 
@@ -231,7 +283,7 @@ You can also customize the subject per test using the `setAutoSnapshotOptions` f
231
283
 
232
284
  ```ts
233
285
  // some.test.ts
234
- import { page } from '@vitest/browser/context'
286
+ import { page } from 'vitest/browser'
235
287
  import { expect, it } from 'vitest'
236
288
  import { render } from 'vitest-browser-react'
237
289
  import { setAutoSnapshotOptions } from 'vitest-plugin-vis'
@@ -386,7 +438,7 @@ You can take snapshots manually:
386
438
  ```ts
387
439
  // some.test.ts
388
440
  import { render } from 'vitest-browser-react'
389
- import { page } from '@vitest/browser/context'
441
+ import { page } from 'vitest/browser'
390
442
  import { it } from 'vitest'
391
443
 
392
444
  it('manual snapshot', async ({ expect }) => {
@@ -403,7 +455,7 @@ You can customize the snapshot comparison options per assertion:
403
455
  ```ts
404
456
  // some.test.ts
405
457
  import { render } from 'vitest-browser-react'
406
- import { page } from '@vitest/browser/context'
458
+ import { page } from 'vitest/browser'
407
459
  import { it } from 'vitest'
408
460
 
409
461
  it('manual snapshot with options', async ({ expect }) => {
@@ -426,7 +478,7 @@ it('manual snapshot with options', async ({ expect }) => {
426
478
  You can also take a full page snapshot:
427
479
 
428
480
  ```ts
429
- import { page } from '@vitest/browser/context'
481
+ import { page } from 'vitest/browser'
430
482
  import { it } from 'vitest'
431
483
 
432
484
  it('full page snapshot', async () => {
@@ -439,7 +491,7 @@ it('full page snapshot', async () => {
439
491
  While less common, you can also check if a snapshot exists:
440
492
 
441
493
  ```ts
442
- import { page } from '@vitest/browser/context'
494
+ import { page } from 'vitest/browser'
443
495
  import { it } from 'vitest'
444
496
 
445
497
  it('Has Snapshot', async ({ expect }) => {
@@ -1,4 +1,4 @@
1
- import type { HasImageSnapshotCommand, ImageSnapshotNextIndexCommand } from '../../commands.ts'
1
+ import type { HasImageSnapshotCommand, ImageSnapshotNextIndexCommand } from '../../shared/commands.types.ts'
2
2
  import type { ImageSnapshotKeyOptions } from '../../shared/types.ts'
3
3
 
4
4
  export function hasImageSnapshotAction(
@@ -1,4 +1,4 @@
1
- import type { LoadImageSnapshotResultsCommand } from '../../server/commands/load_image_snapshot_results.ts'
1
+ import type { LoadImageSnapshotResultsCommand } from '../../shared/commands.types.ts'
2
2
 
3
3
  export function loadImageSnapshotResultsAction(commands: LoadImageSnapshotResultsCommand, taskId: string) {
4
4
  return commands.loadImageSnapshotResults(taskId)
@@ -1,11 +1,13 @@
1
- import type { BrowserCommands } from '@vitest/browser/context'
2
- import type { ImageSnapshotNextIndexCommand } from '../../commands.ts'
3
- import type { PrepareImageSnapshotComparisonCommand } from '../../server/commands/prepare_image_snapshot_comparison.ts'
1
+ import type { BrowserCommands } from 'vitest/browser'
4
2
  import { assertSnapshotKeyWithoutDash } from '../../shared/asserts.ts'
5
3
  import { isBase64String } from '../../shared/base64.ts'
4
+ import type {
5
+ ImageSnapshotNextIndexCommand,
6
+ PrepareImageSnapshotComparisonCommand,
7
+ } from '../../shared/commands.types.ts'
6
8
  import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts'
7
- import { compareImageSnapshot } from '../compare_image_snapshot.ts'
8
- import { convertElementToCssSelector } from '../selector.ts'
9
+ import { convertElementToCssSelector } from '../external/browser/selector.ts'
10
+ import { compareImageSnapshot } from '../snapshot/compare_image_snapshot.ts'
9
11
 
10
12
  export async function matchImageSnapshotAction(
11
13
  commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand,
@@ -1,9 +1,11 @@
1
- import type { BrowserCommands } from '@vitest/browser/context'
2
- import type { ImageSnapshotNextIndexCommand } from '../../commands.ts'
3
- import type { PrepareImageSnapshotComparisonCommand } from '../../server/commands/prepare_image_snapshot_comparison.ts'
1
+ import type { BrowserCommands } from 'vitest/browser'
4
2
  import { assertSnapshotKeyWithoutDash } from '../../shared/asserts.ts'
3
+ import type {
4
+ ImageSnapshotNextIndexCommand,
5
+ PrepareImageSnapshotComparisonCommand,
6
+ } from '../../shared/commands.types.ts'
5
7
  import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts'
6
- import { compareImageSnapshot } from '../compare_image_snapshot.ts'
8
+ import { compareImageSnapshot } from '../snapshot/compare_image_snapshot.ts'
7
9
 
8
10
  export async function matchPageImageSnapshotAction(
9
11
  commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand,
@@ -0,0 +1,10 @@
1
+ import { commands } from 'vitest/browser'
2
+ import { getCurrentTest } from '../external/vitest/vitest_suite_proxy.ts'
3
+
4
+ export const ctx = {
5
+ commands,
6
+ getCurrentTest,
7
+ __test__reset() {
8
+ ctx.getCurrentTest = getCurrentTest
9
+ },
10
+ }
@@ -1,9 +1,8 @@
1
- import { commands } from '@vitest/browser/context'
2
1
  import type { AsyncExpectationResult } from '@vitest/expect'
3
2
  import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts'
4
3
  import { matchImageSnapshotAction } from '../actions/match_image_snapshot_action.ts'
5
- import { ctx } from '../ctx.ts'
6
- import { toTaskId } from '../task_id.ts'
4
+ import { toTaskId } from '../task/task_id.ts'
5
+ import { ctx } from './_ctx.ts'
7
6
  import { success } from './expectation_result.ts'
8
7
 
9
8
  export function toMatchImageSnapshot(
@@ -26,5 +25,5 @@ export function toMatchImageSnapshot(
26
25
  )
27
26
  }
28
27
 
29
- return matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success)
28
+ return matchImageSnapshotAction(ctx.commands, toTaskId(test), subject, options).then(() => success)
30
29
  }
@@ -0,0 +1,3 @@
1
+ export function hasRenderContent() {
2
+ return document.body.childElementCount > 0
3
+ }
@@ -1,4 +1,4 @@
1
- import { isSameSize } from '../shared/is_same_size.ts'
1
+ import { isSameSize } from '../../../shared/is_same_size.ts'
2
2
 
3
3
  export const createImageResizer =
4
4
  ({ width, height }: { width: number; height: number }) =>
@@ -1,10 +1,10 @@
1
- import type { BrowserCommands, Platform } from '@vitest/browser/context'
2
1
  import type { SerializedConfig } from 'vitest'
2
+ import type { BrowserCommands, Platform } from 'vitest/browser'
3
3
 
4
- let ctx: Awaited<typeof import('@vitest/browser/context')>
4
+ let ctx: Awaited<typeof import('vitest/browser')>
5
5
 
6
6
  if ((globalThis as any).__vitest_browser__) {
7
- import('@vitest/browser/context').then((m) => {
7
+ import('vitest/browser').then((m) => {
8
8
  ctx = m
9
9
  })
10
10
  }
@@ -1,4 +1,4 @@
1
- import type { SnapshotTestMeta } from '../shared/types.ts'
1
+ import type { SnapshotTestMeta } from '../../../shared/types.ts'
2
2
 
3
3
  let vitestSuite: Awaited<typeof import('vitest/suite')>
4
4
 
@@ -1,6 +1,6 @@
1
- import { getMaxSize } from '../shared/get_max_size.ts'
2
- import { isSameSize } from '../shared/is_same_size.ts'
3
- import { createImageResizer } from './image_resizer.ts'
1
+ import { getMaxSize } from '../../shared/get_max_size.ts'
2
+ import { isSameSize } from '../../shared/is_same_size.ts'
3
+ import { createImageResizer } from '../external/browser/image_resizer.ts'
4
4
 
5
5
  export function alignImagesToSameSize(image1: ImageData, image2: ImageData): [image1: ImageData, image2: ImageData] {
6
6
  if (isSameSize(image1, image2)) return [image1, image2] as const