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,12 @@
1
+ import { type BrowserPage, commands } from 'vitest/browser'
2
+ import { getCurrentTest } from '../external/vitest/vitest_suite_proxy.ts'
3
+
4
+ export type { BrowserPage }
5
+
6
+ export const ctx = {
7
+ commands,
8
+ getCurrentTest,
9
+ __test__reset() {
10
+ ctx.getCurrentTest = getCurrentTest
11
+ },
12
+ }
@@ -1,4 +1,4 @@
1
- import { page } from '@vitest/browser/context'
1
+ import { page } from 'vitest/browser'
2
2
  import './augment.ts'
3
3
  import { hasImageSnapshot } from './has_image_snapshot.ts'
4
4
  import { toMatchImageSnapshot } from './to_match_image_snapshot.ts'
@@ -11,7 +11,7 @@ This method allows you to conditionally execute code based on whether a snapshot
11
11
  ## Basic Usage
12
12
 
13
13
  ```ts
14
- import { page } from '@vitest/browser/context'
14
+ import { page } from 'vitest/browser'
15
15
 
16
16
  it('should check if snapshot exists', async ({ expect }) => {
17
17
  const hasSnapshot = await page.hasImageSnapshot()
@@ -1,8 +1,8 @@
1
- import { type BrowserPage, commands } from '@vitest/browser/context'
2
1
  import type { ImageSnapshotKeyOptions } from '../../shared/types.ts'
3
2
  import { hasImageSnapshotAction } from '../actions/has_image_snapshot_action.ts'
4
- import { ctx } from '../ctx.ts'
5
- import { toTaskId } from '../task_id.ts'
3
+ import { toTaskId } from '../task/task_id.ts'
4
+ import type { BrowserPage } from './_ctx.ts'
5
+ import { ctx } from './_ctx.ts'
6
6
 
7
7
  export interface HasImageSnapshotAction {
8
8
  /**
@@ -23,5 +23,5 @@ export function hasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOp
23
23
  "concurrent tests run at the same time in the same iframe and affect each other's environment. ",
24
24
  )
25
25
  }
26
- return hasImageSnapshotAction(commands, toTaskId(test), options)
26
+ return hasImageSnapshotAction(ctx.commands, toTaskId(test), options)
27
27
  }
@@ -11,7 +11,7 @@ Unlike `expect().toMatchImageSnapshot()` which targets specific elements, `page.
11
11
  ## Basic Usage
12
12
 
13
13
  ```ts
14
- import { page } from '@vitest/browser/context'
14
+ import { page } from 'vitest/browser'
15
15
 
16
16
  it('should take a page snapshot', async () => {
17
17
  // Your test setup here
@@ -1,8 +1,7 @@
1
- import { commands } from '@vitest/browser/context'
2
1
  import type { ComparisonMethod, ToMatchPageImageSnapshotOptions } from '../../shared/types.ts'
3
2
  import { matchPageImageSnapshotAction } from '../actions/match_page_image_snapshot_action.ts'
4
- import { ctx } from '../ctx.ts'
5
- import { toTaskId } from '../task_id.ts'
3
+ import { toTaskId } from '../task/task_id.ts'
4
+ import { ctx } from './_ctx.ts'
6
5
 
7
6
  export interface ToMatchImageSnapshotAction {
8
7
  toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(
@@ -25,5 +24,5 @@ export function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(
25
24
  )
26
25
  }
27
26
 
28
- return matchPageImageSnapshotAction(commands, toTaskId(test), options)
27
+ return matchPageImageSnapshotAction(ctx.commands, toTaskId(test), options)
29
28
  }
@@ -1,4 +1,4 @@
1
- import type { ToMatchImageSnapshotOptions } from '../shared/types.ts'
1
+ import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts'
2
2
 
3
3
  export function prettifyOptions(options: ToMatchImageSnapshotOptions<any> | undefined) {
4
4
  if (!options) return 'none'
@@ -1,17 +1,16 @@
1
- import type { BrowserCommands } from '@vitest/browser/context'
2
1
  import dedent from 'dedent'
3
2
  import { resolve } from 'pathe'
4
- import type { ImageSnapshotNextIndexCommand } from '../commands.ts'
3
+ import type { BrowserCommands } from 'vitest/browser'
5
4
  import type {
6
- ImageSnapshotComparisonInfo,
5
+ ImageSnapshotNextIndexCommand,
7
6
  PrepareImageSnapshotComparisonCommand,
8
- } from '../server/commands/prepare_image_snapshot_comparison.ts'
9
- import { compareImage } from '../shared/compare_image.ts'
10
- import type { ToMatchImageSnapshotOptions } from '../shared/types.ts'
11
- import { alignImagesToSameSize } from './align_images.ts'
7
+ } from '../../shared/commands.types.ts'
8
+ import { compareImage } from '../../shared/compare_image.ts'
9
+ import type { ImageSnapshotComparisonInfo, ToMatchImageSnapshotOptions } from '../../shared/types.ts'
10
+ import { toDataURL, toImageData } from '../external/browser/image_data.ts'
11
+ import { server } from '../external/vitest/vitest_browser_context_proxy.ts'
12
+ import { alignImagesToSameSize } from '../image/align_images.ts'
12
13
  import { prettifyOptions } from './compare_image_snapshot.logic.ts'
13
- import { toDataURL, toImageData } from './image_data.ts'
14
- import { server } from './vitest_browser_context_proxy.ts'
15
14
 
16
15
  export async function compareImageSnapshot(
17
16
  commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand,
@@ -0,0 +1,6 @@
1
+ import { hasRenderContent } from '../external/browser/has_render_content.ts'
2
+ import type { SnapshotMeta } from '../task/snapshot_meta.ts'
3
+
4
+ export function shouldTakeSnapshot(meta: SnapshotMeta<any> | undefined) {
5
+ return hasRenderContent() && meta?.enable
6
+ }
@@ -0,0 +1,8 @@
1
+ import { getCurrentTest } from '../external/vitest/vitest_suite_proxy.ts'
2
+
3
+ export const ctx = {
4
+ getCurrentTest,
5
+ __test__reset() {
6
+ ctx.getCurrentTest = getCurrentTest
7
+ },
8
+ }
@@ -0,0 +1,68 @@
1
+ import dedent from 'dedent'
2
+ import type { SetupVisSuiteCommand } from '../../shared/commands.types.ts'
3
+ import type { ComparisonMethod } from '../../shared/types.ts'
4
+ import { shouldTakeSnapshot } from '../snapshot/should_take_snapshot.ts'
5
+ import { extractAutoSnapshotOptions } from '../task/auto_snapshot_options.ts'
6
+ import type { SnapshotMeta } from '../task/snapshot_meta.ts'
7
+ import { toTaskId } from '../task/task_id.ts'
8
+ import { ctx } from './_ctx.ts'
9
+
10
+ export function autoSnapshotMatcher<GM extends Record<string, any> | unknown = unknown>(
11
+ commands: SetupVisSuiteCommand,
12
+ expect: any,
13
+ ) {
14
+ let subject: string | undefined
15
+
16
+ return {
17
+ async setup() {
18
+ subject = (await commands.setupVisSuite()).subject
19
+ },
20
+ createMatcher<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(
21
+ themes: Record<
22
+ string,
23
+ boolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)
24
+ >,
25
+ ) {
26
+ return async function matchImageSnapshot() {
27
+ const test = ctx.getCurrentTest()
28
+ if ((test?.result?.errors?.length ?? 0) > 0) return
29
+
30
+ const meta = extractAutoSnapshotOptions(test)
31
+ if (!shouldTakeSnapshot(meta)) return
32
+ const errors: Array<[string, Error]> = []
33
+ for (const themeId in themes) {
34
+ try {
35
+ await new Promise((a) => setTimeout(a, 10))
36
+ const theme = themes[themeId]
37
+ const r = typeof theme === 'function' ? await theme(meta! as any) : theme
38
+ if (r === false) continue
39
+ await expect(getSubject(meta?.subject ?? subject)).toMatchImageSnapshot({
40
+ ...meta,
41
+ snapshotKey: meta?.snapshotKey ?? themeId,
42
+ })
43
+ } catch (error) {
44
+ errors.push([themeId, error as Error])
45
+ }
46
+ }
47
+ if (errors.length > 0) {
48
+ if (errors.length === 1) throw errors[0]![1]
49
+ const taskId = toTaskId(test!)
50
+ throw new AggregateError(
51
+ errors,
52
+ dedent`Snapshot \`${taskId}\` mismatched
53
+
54
+ ${errors
55
+ .map(([themeId, error]) => {
56
+ return `Theme \`${themeId}\` failed: ${error.message}`
57
+ })
58
+ .join('\n\n')}`,
59
+ )
60
+ }
61
+ }
62
+ },
63
+ }
64
+ }
65
+
66
+ function getSubject(selectors: string | undefined) {
67
+ return selectors ? (document.querySelector(selectors) ?? document.body) : document.body
68
+ }
@@ -1,12 +1,10 @@
1
- import { getCurrentSuite, getCurrentTest } from './vitest_suite_proxy.ts'
1
+ import { getCurrentSuite, getCurrentTest } from '../external/vitest/vitest_suite_proxy.ts'
2
2
 
3
3
  export const ctx = {
4
- autoEnabled: undefined as boolean | undefined,
5
4
  getCurrentTest,
6
5
  getCurrentSuite,
7
6
  __test__reset() {
8
7
  ctx.getCurrentTest = getCurrentTest
9
8
  ctx.getCurrentSuite = getCurrentSuite
10
- ctx.autoEnabled = undefined
11
9
  },
12
10
  }
@@ -1,7 +1,7 @@
1
- import { assertSnapshotKeyWithoutDash } from '../shared/asserts.ts'
2
- import { NAME } from '../shared/constants.ts'
3
- import type { ComparisonMethod } from '../shared/types.ts'
4
- import { ctx } from './ctx.ts'
1
+ import { assertSnapshotKeyWithoutDash } from '../../shared/asserts.ts'
2
+ import { NAME } from '../../shared/constants.ts'
3
+ import type { ComparisonMethod } from '../../shared/types.ts'
4
+ import { ctx } from './_ctx.ts'
5
5
  import type { SnapshotMeta } from './snapshot_meta.ts'
6
6
 
7
7
  type Suite = { meta: Record<string, any>; suite?: Suite | undefined }
@@ -17,6 +17,21 @@ export type MetaTask =
17
17
  /**
18
18
  * Set the snapshot options for auto snapshot.
19
19
  *
20
+ * You can use it in beforeAll, beforeEach, or individual test cases.
21
+ *
22
+ * @param meta - The snapshot options to set.
23
+ * You can pass a boolean to enable/disable the snapshot, or an object with the snapshot options.
24
+ * When passing an object, the `enable` property will be set to `true` by default unless you explicitly set it to `false`.
25
+ * @param meta.enable - Whether to enable the snapshot.
26
+ * @param meta.snapshotKey - The key to use for the snapshot.
27
+ * @param meta.comparisonMethod - The comparison method to use for the snapshot.
28
+ * @param meta.diffOptions - The diff options to use for the snapshot.
29
+ * @param meta.failureThreshold - The failure threshold to use for the snapshot.
30
+ * @param meta.failureThresholdType - The failure threshold type to use for the snapshot.
31
+ * @param meta.timeout - The timeout to use for the snapshot.
32
+ *
33
+ * @example
34
+ *
20
35
  * ```ts
21
36
  * beforeAll(() => setAutoSnapshotOptions(...))
22
37
  * beforeEach(() => setAutoSnapshotOptions(...))
@@ -26,7 +41,7 @@ export type MetaTask =
26
41
  * })
27
42
  * ```
28
43
  */
29
- export function setAutoSnapshotOptions<M extends ComparisonMethod>(meta: SnapshotMeta<M> | boolean): void {
44
+ export function setAutoSnapshotOptions<M extends ComparisonMethod>(meta: boolean | SnapshotMeta<M>): void {
30
45
  if (typeof meta === 'object') {
31
46
  assertSnapshotKeyWithoutDash(meta.snapshotKey)
32
47
  }
@@ -1,7 +1,12 @@
1
- import type { ComparisonMethod, ImageSnapshotSubjectOptions, ToMatchImageSnapshotOptions } from '../shared/types.ts'
1
+ import type { ComparisonMethod, ImageSnapshotSubjectOptions, ToMatchImageSnapshotOptions } from '../../shared/types.ts'
2
2
 
3
3
  export type SnapshotMeta<M extends ComparisonMethod> = ToMatchImageSnapshotOptions<M> &
4
4
  ImageSnapshotSubjectOptions & {
5
+ /**
6
+ * Whether to enable the snapshot.
7
+ *
8
+ * Default: `true`
9
+ */
5
10
  enable?: boolean | undefined
6
11
  [key: string]: unknown
7
12
  }
package/src/client-api.ts CHANGED
@@ -4,9 +4,10 @@ export * from './client/actions/has_image_snapshot_action.ts'
4
4
  export * from './client/actions/load_image_snapshot_results_action.ts'
5
5
  export * from './client/actions/match_image_snapshot_action.ts'
6
6
  export * from './client/actions/match_page_image_snapshot_action.ts'
7
- export { setAutoSnapshotOptions, type MetaTask } from './client/auto_snapshot_options.ts'
8
7
  export * from './client/expect/expectation_result.ts'
9
8
  export type * from './client/expect/to_match_image_snapshot.types.ts'
10
- export * from './client/task_id.ts'
9
+ export * from './client/suite/auto_snapshot_matcher.ts'
10
+ export { setAutoSnapshotOptions, type MetaTask } from './client/task/auto_snapshot_options.ts'
11
+ export * from './client/task/task_id.ts'
11
12
  export * from './shared/constants.ts'
12
13
  export type * from './shared/types.ts'
package/src/config/vis.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PluginOption } from 'vite'
1
+ import type { Plugin } from 'vitest/config'
2
2
  import { commands } from '../server/commands/commands.ts'
3
3
  import { setVisOption } from '../server/vis_options.ts'
4
4
  import { NAME } from '../shared/constants.ts'
@@ -20,12 +20,12 @@ export function vis<M extends ComparisonMethod = 'pixel'>(options: VisOptions<M>
20
20
  return {
21
21
  test: {
22
22
  browser: {
23
- name: undefined as unknown as string,
24
- commands,
23
+ name: undefined,
24
+ commands: commands as any,
25
25
  },
26
26
  setupFiles: preset && preset !== 'none' && preset !== 'custom' ? [`vitest-plugin-vis/presets/${preset}`] : [],
27
27
  },
28
28
  }
29
29
  },
30
- } satisfies PluginOption
30
+ } satisfies Plugin
31
31
  }
package/src/index.ts CHANGED
@@ -2,5 +2,5 @@
2
2
  import './client/expect/augment.ts'
3
3
  import './client/page/augment.ts'
4
4
 
5
- export { setAutoSnapshotOptions, type MetaTask } from './client/auto_snapshot_options.ts'
5
+ export { setAutoSnapshotOptions, type MetaTask } from './client/task/auto_snapshot_options.ts'
6
6
  export type * from './shared/types.ts'
@@ -1,8 +1,8 @@
1
- import type { BrowserCommandContext } from 'vitest/node'
1
+ import type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'
2
2
  import { playwright } from './playwright.ts'
3
3
  import { webdriverio } from './webdriverio.ts'
4
4
 
5
- export function browserApi(context: BrowserCommandContext) {
5
+ export function browserApi(context: ExtendedBrowserCommandContext) {
6
6
  if (context.provider.name === 'playwright') {
7
7
  return playwright(context)
8
8
  }
@@ -1,18 +1,20 @@
1
1
  import { resolve } from 'pathe'
2
- import type { BrowserCommandContext } from 'vitest/node'
2
+ import type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'
3
3
  import type { BrowserApi } from './types.ts'
4
4
 
5
- export function playwright(context: BrowserCommandContext): BrowserApi {
5
+ export function playwright(context: ExtendedBrowserCommandContext): BrowserApi {
6
+ const { page, iframe } = context
7
+
6
8
  return {
7
9
  async takeScreenshot(projectRoot, relativeFilePath, selector, options) {
8
- const subject = context.iframe.locator(selector)
10
+ const subject = iframe.locator(selector)
9
11
  return subject.screenshot({
10
12
  path: resolve(projectRoot, relativeFilePath),
11
13
  ...options,
12
14
  })
13
15
  },
14
16
  async takePageScreenshot(projectRoot, relativeFilePath, options) {
15
- return context.page.screenshot({
17
+ return page.screenshot({
16
18
  path: resolve(projectRoot, relativeFilePath),
17
19
  ...options,
18
20
  })
@@ -1,8 +1,8 @@
1
- import type { BrowserCommandContext } from 'vitest/node'
1
+ import type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'
2
2
  import type { BrowserApi } from './types.ts'
3
3
 
4
- export function webdriverio(context: BrowserCommandContext): BrowserApi {
5
- const browser = context.browser
4
+ export function webdriverio(context: ExtendedBrowserCommandContext): BrowserApi {
5
+ const { browser } = context
6
6
  return {
7
7
  async takeScreenshot(_projectRoot, relativeFilePath, selector) {
8
8
  const element = await browser.$(`${selector}`)
@@ -1,11 +1,11 @@
1
1
  import { isAbsolute } from 'pathe'
2
2
  import type { RequiredPick } from 'type-plus'
3
- import type { BrowserCommandContext } from 'vitest/node'
3
+ import type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'
4
4
 
5
5
  export function assertTestPathDefined(
6
- context: BrowserCommandContext,
6
+ context: ExtendedBrowserCommandContext,
7
7
  commandName: string,
8
- ): asserts context is RequiredPick<BrowserCommandContext, 'testPath'> {
8
+ ): asserts context is RequiredPick<ExtendedBrowserCommandContext, 'testPath'> {
9
9
  if (!context.testPath) {
10
10
  throw new Error(`'commands.${commandName}' requires testPath to be defined`)
11
11
  }
@@ -1,11 +1,13 @@
1
- import type { HasImageSnapshotCommand } from './has_image_snapshot.ts'
2
- import type { ImageSnapshotNextIndexCommand } from './image_snapshot_next_index.ts'
3
- import type { LoadImageSnapshotResultsCommand } from './load_image_snapshot_results.ts'
4
- import type { PrepareImageSnapshotComparisonCommand } from './prepare_image_snapshot_comparison.ts'
5
- import type { PreparePageImageSnapshotComparisonCommand } from './prepare_page_image_snapshot_comparison.ts'
6
- import type { SetupVisSuiteCommand } from './setup_vis_suite.ts'
1
+ import type {
2
+ HasImageSnapshotCommand,
3
+ ImageSnapshotNextIndexCommand,
4
+ LoadImageSnapshotResultsCommand,
5
+ PrepareImageSnapshotComparisonCommand,
6
+ PreparePageImageSnapshotComparisonCommand,
7
+ SetupVisSuiteCommand,
8
+ } from '../../shared/commands.types.ts'
7
9
 
8
- declare module '@vitest/browser/context' {
10
+ declare module 'vitest/browser' {
9
11
  interface BrowserCommands
10
12
  extends SetupVisSuiteCommand,
11
13
  ImageSnapshotNextIndexCommand,
@@ -1,12 +1,9 @@
1
- import type { BrowserCommand } from 'vitest/node'
1
+ import type { HasImageSnapshotCommand } from '../../shared/commands.types.ts'
2
2
  import { visServerContext } from '../vis_server_context.ts'
3
+ import type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'
3
4
  import { assertTestPathDefined } from './_assertions.ts'
4
5
 
5
- export interface HasImageSnapshotCommand {
6
- hasImageSnapshot(taskId: string, snapshotKey: string | undefined): Promise<boolean>
7
- }
8
-
9
- export const hasImageSnapshot: BrowserCommand<Parameters<HasImageSnapshotCommand['hasImageSnapshot']>> = async (
6
+ export const hasImageSnapshot: ExtendedBrowserCommand<Parameters<HasImageSnapshotCommand['hasImageSnapshot']>> = async (
10
7
  context,
11
8
  taskId,
12
9
  snapshotKey,
@@ -1,15 +1,9 @@
1
- import type { BrowserCommand } from 'vitest/node'
1
+ import type { ImageSnapshotNextIndexCommand } from '../../shared/commands.types.ts'
2
2
  import { visServerContext } from '../vis_server_context.ts'
3
+ import type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'
3
4
  import { assertTestPathDefined } from './_assertions.ts'
4
5
 
5
- export interface ImageSnapshotNextIndexCommand {
6
- /**
7
- * Get the index of the snapshot image to be created.
8
- */
9
- imageSnapshotNextIndex(taskId: string): Promise<number>
10
- }
11
-
12
- export const imageSnapshotNextIndex: BrowserCommand<
6
+ export const imageSnapshotNextIndex: ExtendedBrowserCommand<
13
7
  Parameters<ImageSnapshotNextIndexCommand['imageSnapshotNextIndex']>
14
8
  > = async (context, taskId) => {
15
9
  assertTestPathDefined(context, 'imageSnapshotNextIndex')
@@ -1,32 +1,12 @@
1
- import type { BrowserCommand } from 'vitest/node'
1
+ import type { ImageSnapshotResult } from '../../shared/commands.types.ts'
2
2
  import { visServerContext } from '../vis_server_context.ts'
3
+ import type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'
3
4
  import { assertTestPathDefined } from './_assertions.ts'
4
5
 
5
- export interface ImageSnapshotResult {
6
- filename: string
7
- /**
8
- * The base64 encoded image of the baseline snapshot.
9
- */
10
- baseline?: string | undefined
11
- /**
12
- * The base64 encoded image of the result snapshot.
13
- */
14
- result?: string | undefined
15
- /**
16
- * The base64 encoded image of the diff snapshot.
17
- */
18
- diff?: string | undefined
19
- }
20
-
21
- export interface LoadImageSnapshotResultsCommand {
22
- loadImageSnapshotResults(taskId: string): Promise<ImageSnapshotResult[]>
23
- }
24
-
25
- export const loadImageSnapshotResults: BrowserCommand<[taskId: string]> = async (
6
+ export const loadImageSnapshotResults: ExtendedBrowserCommand<[taskId: string]> = async (
26
7
  context,
27
8
  taskId,
28
9
  ): Promise<ImageSnapshotResult[]> => {
29
10
  assertTestPathDefined(context, 'loadImageSnapshotResults')
30
-
31
11
  return visServerContext.getSnapshotResults(context, taskId)
32
12
  }
@@ -1,62 +1,16 @@
1
1
  import { resolve } from 'pathe'
2
- import type { BrowserCommand } from 'vitest/node'
3
2
  import { isBase64String } from '../../shared/base64.ts'
4
- import type {
5
- FailureThresholdOptions,
6
- ImageSnapshotTimeoutOptions,
7
- PixelComparisonOptions,
8
- SsimComparisonOptions,
9
- } from '../../shared/types.ts'
3
+ import type { PrepareImageSnapshotComparisonCommand } from '../../shared/commands.types.ts'
4
+ import type { ImageSnapshotComparisonInfo } from '../../shared/types.ts'
10
5
  import { file } from '../externals/file.ts'
11
6
  import { getProjectRoot } from '../project.ts'
12
7
  import { takeSnapshot, takeSnapshotByBrowser } from '../snapshot.ts'
13
8
  import { snapshotWriter } from '../snapshot_writer.ts'
14
9
  import { visServerContext } from '../vis_server_context.ts'
10
+ import type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'
15
11
  import { assertTestPathDefined } from './_assertions.ts'
16
- import type { MatchImageSnapshotOptions } from './types.ts'
17
12
 
18
- export type ImageSnapshotComparisonInfo = {
19
- /**
20
- * Path to the project root.
21
- */
22
- projectRoot: string
23
- /**
24
- * Path to the baseline image relative to the project root.
25
- */
26
- baselinePath: string
27
- /**
28
- * Path to the result image relative to the project root.
29
- */
30
- resultPath: string
31
- /**
32
- * Path to the diff image relative to the project root.
33
- */
34
- diffPath: string
35
- /**
36
- * Base64 encoded baseline image.
37
- */
38
- baseline: string
39
- /**
40
- * Base64 encoded result image.
41
- */
42
- result: string
43
- /**
44
- * Base64 encoded diff image.
45
- */
46
- diff?: string | undefined
47
- } & ImageSnapshotTimeoutOptions &
48
- FailureThresholdOptions &
49
- (SsimComparisonOptions | PixelComparisonOptions)
50
-
51
- export interface PrepareImageSnapshotComparisonCommand {
52
- prepareImageSnapshotComparison: (
53
- taskId: string,
54
- subject: string,
55
- options?: MatchImageSnapshotOptions | undefined,
56
- ) => Promise<ImageSnapshotComparisonInfo | undefined>
57
- }
58
-
59
- export const prepareImageSnapshotComparison: BrowserCommand<
13
+ export const prepareImageSnapshotComparison: ExtendedBrowserCommand<
60
14
  Parameters<PrepareImageSnapshotComparisonCommand['prepareImageSnapshotComparison']>
61
15
  > = async (context, taskId, subject, options): Promise<ImageSnapshotComparisonInfo | undefined> => {
62
16
  assertTestPathDefined(context, 'prepareImageSnapshotComparison')
@@ -1,55 +1,13 @@
1
1
  import { resolve } from 'pathe'
2
- import type { BrowserCommand } from 'vitest/node'
3
- import type {
4
- FailureThresholdOptions,
5
- ImageSnapshotTimeoutOptions,
6
- PixelComparisonOptions,
7
- SsimComparisonOptions,
8
- } from '../../shared/types.ts'
2
+ import type { PreparePageImageSnapshotComparisonCommand } from '../../shared/commands.types.ts'
9
3
  import { file } from '../externals/file.ts'
10
4
  import { getProjectRoot } from '../project.ts'
11
5
  import { takePageSnapshot } from '../snapshot.ts'
12
6
  import { visServerContext } from '../vis_server_context.ts'
7
+ import type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'
13
8
  import { assertTestPathDefined } from './_assertions.ts'
14
- import type { MatchImageSnapshotOptions } from './types.ts'
15
9
 
16
- type ImageSnapshotComparisonInfo = {
17
- /**
18
- * Path to the project root.
19
- */
20
- projectRoot: string
21
- /**
22
- * Path to the baseline image relative to the project root.
23
- */
24
- baselinePath: string
25
- /**
26
- * Path to the result image relative to the project root.
27
- */
28
- resultPath: string
29
- /**
30
- * Path to the diff image relative to the project root.
31
- */
32
- diffPath: string
33
- /**
34
- * Base64 encoded baseline image.
35
- */
36
- baseline: string
37
- /**
38
- * Base64 encoded result image.
39
- */
40
- result: string
41
- } & ImageSnapshotTimeoutOptions &
42
- FailureThresholdOptions &
43
- (SsimComparisonOptions | PixelComparisonOptions)
44
-
45
- export interface PreparePageImageSnapshotComparisonCommand {
46
- preparePageImageSnapshotComparison: (
47
- taskId: string,
48
- options?: MatchImageSnapshotOptions | undefined,
49
- ) => Promise<ImageSnapshotComparisonInfo | undefined>
50
- }
51
-
52
- export const preparePageImageSnapshotComparison: BrowserCommand<
10
+ export const preparePageImageSnapshotComparison: ExtendedBrowserCommand<
53
11
  Parameters<PreparePageImageSnapshotComparisonCommand['preparePageImageSnapshotComparison']>
54
12
  > = async (context, taskId, options) => {
55
13
  assertTestPathDefined(context, 'preparePageImageSnapshotComparison')
@@ -1,32 +1,8 @@
1
- import type { Pick } from 'type-plus'
2
- import type { BrowserCommand } from 'vitest/node'
3
- import type { VisOptions } from '../../config/types.ts'
4
1
  import { setupSuite } from '../suite.ts'
2
+ import type { ExtendedBrowserCommand, ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'
5
3
  import { assertTestPathDefined } from './_assertions.ts'
6
4
 
7
- export interface SetupVisSuiteCommand {
8
- /**
9
- * Sets up the visual testing suite by cleaning up previous snapshot and diff output directories.
10
- * When this command is run for the first time,
11
- * it will remove the results and diffs directory of all suites.
12
- *
13
- * In subsequent runs, it will only remove the results and diffs directory of the current suite.
14
- */
15
- setupVisSuite: () => Promise<
16
- Pick<
17
- VisOptions,
18
- | 'comparisonMethod'
19
- | 'diffOptions'
20
- | 'failureThreshold'
21
- | 'failureThresholdType'
22
- | 'snapshotKey'
23
- | 'subject'
24
- | 'timeout'
25
- >
26
- >
27
- }
28
-
29
- export const setupVisSuite: BrowserCommand<[]> = async (context): Promise<{ subject: string | undefined }> => {
5
+ export const setupVisSuite: ExtendedBrowserCommand<[]> = async (context): Promise<{ subject: string | undefined }> => {
30
6
  assertTestPathDefined(context, 'setupVisSuite')
31
- return setupSuite(context)
7
+ return setupSuite(context as unknown as ExtendedBrowserCommandContext)
32
8
  }