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
@@ -1,13 +1,14 @@
1
- export function getProjectName(context: {
2
- project: { vite: { config: { test?: { name?: { label: string } | string | undefined } } } }
3
- }) {
4
- const name = context.project.vite.config.test?.name
1
+ import type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'
2
+
3
+ export function getProjectName(context: ExtendedBrowserCommandContext) {
4
+ const { runner } = context.project
5
+ const name = runner.config.name
5
6
  if (typeof name === 'string') {
6
7
  return name
7
8
  }
8
- if (typeof name === 'object' && 'label' in name) {
9
- return name.label
10
- }
9
+ // if (typeof name === 'object' && 'label' in name) {
10
+ // return (name as { label: string }).label
11
+ // }
11
12
  return undefined
12
13
  }
13
14
 
@@ -1,13 +1,13 @@
1
1
  import { mkdirp } from 'mkdirp'
2
2
  import { dirname, resolve } from 'pathe'
3
- import type { BrowserCommandContext } from 'vitest/node'
4
3
  import { isBase64String } from '../shared/base64.ts'
5
4
  import type { ImageSnapshotTimeoutOptions, PageImageSnapshotOptions } from '../shared/types.ts'
6
5
  import { browserApi } from './browser_provider/browser_api.ts'
7
6
  import { snapshotWriter } from './snapshot_writer.ts'
7
+ import type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'
8
8
 
9
9
  export async function takeSnapshot(
10
- context: BrowserCommandContext,
10
+ context: ExtendedBrowserCommandContext,
11
11
  projectRoot: string,
12
12
  relativeFilePath: string,
13
13
  subject: string,
@@ -21,7 +21,7 @@ export async function takeSnapshot(
21
21
  }
22
22
 
23
23
  export async function takeSnapshotByBrowser(
24
- context: BrowserCommandContext,
24
+ context: ExtendedBrowserCommandContext,
25
25
  projectRoot: string,
26
26
  relativeFilePath: string,
27
27
  subject: string,
@@ -36,7 +36,7 @@ export async function takeSnapshotByBrowser(
36
36
  }
37
37
 
38
38
  export async function takePageSnapshot(
39
- context: BrowserCommandContext,
39
+ context: ExtendedBrowserCommandContext,
40
40
  projectRoot: string,
41
41
  relativeFilePath: string,
42
42
  options: (PageImageSnapshotOptions & ImageSnapshotTimeoutOptions) | undefined,
@@ -3,19 +3,20 @@ import { platform } from 'node:process'
3
3
  import type { VisOptions } from '../config/types.ts'
4
4
  import { SNAPSHOT_ROOT_DIR } from '../shared/constants.ts'
5
5
  import { trimCommonFolder } from '../shared/trim_common_folder.ts'
6
- import type { PartialBrowserCommandContext } from './vis_server_context.types.ts'
6
+ import type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'
7
7
 
8
- export function resolveSnapshotRootDir(browserCommandContext: PartialBrowserCommandContext, options: VisOptions) {
8
+ export function resolveSnapshotRootDir(browserCommandContext: ExtendedBrowserCommandContext, options: VisOptions) {
9
9
  if (!options.snapshotRootDir) return getSnapshotRootDir(SNAPSHOT_ROOT_DIR)
10
10
  const snapshotRootDir = options.snapshotRootDir
11
11
  if (typeof snapshotRootDir === 'string') return getSnapshotRootDir(snapshotRootDir)
12
+ const { config } = browserCommandContext.project.browser
12
13
  return snapshotRootDir({
13
14
  ci,
14
- browserName: browserCommandContext.provider.browserName,
15
+ browserName: config.browser.name,
15
16
  providerName: browserCommandContext.provider.name,
16
17
  platform,
17
- screenshotFailures: browserCommandContext.provider.options?.screenshotFailures,
18
- screenshotDirectory: browserCommandContext.provider.options?.screenshotDirectory,
18
+ screenshotFailures: config.browser.screenshotFailures,
19
+ screenshotDirectory: config.browser.screenshotDirectory,
19
20
  })
20
21
  }
21
22
 
@@ -1,12 +1,11 @@
1
1
  import { join, relative } from 'pathe'
2
- import type { UserConfig } from 'vitest/node'
3
2
  import type { VisOptions } from '../config/types.ts'
4
3
  import { BASELINE_DIR, DIFF_DIR, RESULT_DIR } from '../shared/constants.ts'
5
4
  import { getProjectName, getProjectRoot } from './project.ts'
6
5
  import { getSnapshotSubpath, resolveSnapshotRootDir } from './snapshot_path.ts'
7
6
  import { getVisOption } from './vis_options.ts'
8
7
  import { deps } from './vis_server_context.deps.ts'
9
- import type { PartialBrowserCommandContext, VisSuite, VisSuites } from './vis_server_context.types.ts'
8
+ import type { ExtendedBrowserCommandContext, VisSuite, VisSuites } from './vis_server_context.types.ts'
10
9
 
11
10
  const suites: VisSuites = {}
12
11
 
@@ -15,7 +14,7 @@ const suites: VisSuites = {}
15
14
  * Test files include vitest test files and storybook story files.
16
15
  * It needs to make sure there is no race condition between the test files.
17
16
  */
18
- export async function setupSuite(browserContext: PartialBrowserCommandContext) {
17
+ export async function setupSuite(browserContext: ExtendedBrowserCommandContext) {
19
18
  const suiteId = getSuiteId(browserContext)
20
19
  const visOptions = getVisOption(browserContext)
21
20
 
@@ -27,7 +26,7 @@ export async function setupSuite(browserContext: PartialBrowserCommandContext) {
27
26
 
28
27
  const { taskSubpath, baselineDir, diffDir, resultDir, tasks } = createModule(
29
28
  suite,
30
- browserContext.testPath,
29
+ browserContext.testPath!,
31
30
  visOptions,
32
31
  )
33
32
  suite.modules[taskSubpath] = { baselineDir, diffDir, resultDir, tasks }
@@ -48,19 +47,15 @@ export async function setupSuite(browserContext: PartialBrowserCommandContext) {
48
47
  * Suite ID also contains the project name to make it unique
49
48
  * across different projects.
50
49
  */
51
- export function getSuiteId(context: {
52
- project: {
53
- config: { root: string; name: string }
54
- vite: { config: { test?: { name?: UserConfig['name'] | undefined } } }
55
- }
56
- }) {
50
+ export function getSuiteId(context: ExtendedBrowserCommandContext) {
57
51
  return `${getProjectName(context)}/${context.project.config.name}`
58
52
  }
59
53
 
60
54
  async function createSuite(
61
- browserContext: PartialBrowserCommandContext,
55
+ browserContext: ExtendedBrowserCommandContext,
62
56
  visOptions: Pick<VisOptions, 'snapshotRootDir' | 'subject'>,
63
57
  ) {
58
+ // console.log('visOptions', visOptions)
64
59
  const snapshotRootDir = resolveSnapshotRootDir(browserContext, visOptions)
65
60
  const projectRoot = getProjectRoot(browserContext)
66
61
 
@@ -95,6 +90,6 @@ export function getTaskSubpath(state: VisSuite, testPath: string, options: Pick<
95
90
  return getSnapshotSubpath(relative(state.projectRoot, testPath), options)
96
91
  }
97
92
 
98
- export function getSuite(context: PartialBrowserCommandContext) {
93
+ export function getSuite(context: ExtendedBrowserCommandContext) {
99
94
  return suites[getSuiteId(context)]!
100
95
  }
@@ -0,0 +1,16 @@
1
+ import '@vitest/browser-playwright'
2
+ import { stub } from 'type-plus'
3
+ import type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'
4
+
5
+ export const stubBrowserCommandContext = stub.build<ExtendedBrowserCommandContext>({})
6
+
7
+ export function createStubPartialBrowserCommandContext({ root, testPath }: { root: string; testPath: string }) {
8
+ return stub.build<ExtendedBrowserCommandContext>({
9
+ project: {
10
+ config: { root },
11
+ runner: { config: { name: 'subject' } },
12
+ } as any,
13
+ provider: {},
14
+ testPath,
15
+ })
16
+ }
@@ -1,13 +1,13 @@
1
1
  import { resolve } from 'pathe'
2
2
  import { requiredDeep, type RecursivePartial } from 'type-plus'
3
- import type { UserConfig } from 'vite'
4
- import type { BrowserCommandContext } from 'vitest/node'
3
+ import type { TestUserConfig } from 'vitest/node'
4
+ import type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'
5
5
  import { stubBrowserCommandContext } from './stubBrowserCommandContext.ts'
6
6
  import { stubUserConfig } from './stubUserConfig.ts'
7
7
 
8
8
  export function stubSuite(
9
- partialUserConfig: RecursivePartial<UserConfig> = {},
10
- partialBrowserCommandContext: RecursivePartial<BrowserCommandContext> = {},
9
+ partialUserConfig: RecursivePartial<{ test?: { name?: TestUserConfig['name'] } }> = {},
10
+ partialBrowserCommandContext: RecursivePartial<ExtendedBrowserCommandContext> = {},
11
11
  ) {
12
12
  const root = resolve(import.meta.dirname, '../..')
13
13
  const userConfig = stubUserConfig({
@@ -15,15 +15,13 @@ export function stubSuite(
15
15
  ...partialUserConfig,
16
16
  })
17
17
  const browserCommandContext = stubBrowserCommandContext(
18
- requiredDeep<RecursivePartial<BrowserCommandContext>>(
18
+ requiredDeep<RecursivePartial<ExtendedBrowserCommandContext>>(
19
19
  {
20
20
  project: {
21
21
  config: { root },
22
- vite: {
22
+ runner: {
23
23
  config: {
24
- test: {
25
- name: partialUserConfig.test?.name,
26
- },
24
+ name: partialUserConfig.test?.name as string | undefined,
27
25
  },
28
26
  },
29
27
  },
@@ -0,0 +1,6 @@
1
+ import { stub } from 'type-plus'
2
+ import type { ViteUserConfig } from 'vitest/config'
3
+
4
+ export const stubUserConfig = stub.build<ViteUserConfig>((stub) => ({
5
+ ...stub,
6
+ }))
@@ -1,26 +1,25 @@
1
- import type { UserConfig } from 'vitest/node'
1
+ import type { TestUserConfig } from 'vitest/node'
2
2
  import type { VisOptions } from '../config/types.ts'
3
3
  import { assertSnapshotKeyWithoutDash } from '../shared/asserts.ts'
4
4
  import { getProjectName } from './project.ts'
5
+ import type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'
5
6
 
6
7
  const DEFAULT_PROJECT_NAME = '__default'
7
8
 
8
9
  const visOptions: Record<string, VisOptions<any> | undefined> = {}
9
10
 
10
11
  export function setVisOption(
11
- userConfig: { test?: { name?: UserConfig['name'] | undefined } | undefined },
12
+ userConfig: { test?: { name?: TestUserConfig['name'] | undefined } },
12
13
  options: VisOptions<any> | undefined,
13
14
  ) {
14
15
  assertSnapshotKeyWithoutDash(options?.snapshotKey)
15
16
 
16
17
  const name = userConfig.test?.name
17
18
  const id = typeof name === 'string' ? name : typeof name === 'object' ? name?.label : DEFAULT_PROJECT_NAME
18
-
19
19
  visOptions[id] = options
20
20
  }
21
21
 
22
- export function getVisOption(context: { project: { vite: { config: { test?: { name?: UserConfig['name'] } } } } }) {
22
+ export function getVisOption(context: ExtendedBrowserCommandContext) {
23
23
  const id = getProjectName(context) ?? DEFAULT_PROJECT_NAME
24
-
25
24
  return visOptions[id] ?? {}
26
25
  }
@@ -1,15 +1,15 @@
1
1
  import { basename, join, resolve } from 'pathe'
2
2
  import { pick } from 'type-plus'
3
3
  import type { ImageSnapshotKeyOptions } from '../client-api.ts'
4
- import type { ImageSnapshotResult } from './commands/load_image_snapshot_results.ts'
4
+ import type { ImageSnapshotResult } from '../shared/commands.types.ts'
5
5
  import { file } from './externals/file.ts'
6
6
  import { getSuite, getTaskSubpath } from './suite.ts'
7
7
  import { getVisOption } from './vis_options.ts'
8
- import type { PartialBrowserCommandContext } from './vis_server_context.types.ts'
8
+ import type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'
9
9
 
10
10
  export function createVisServerContext() {
11
11
  const context = {
12
- async getSnapshotResults(browserContext: PartialBrowserCommandContext, taskId: string) {
12
+ async getSnapshotResults(browserContext: ExtendedBrowserCommandContext, taskId: string) {
13
13
  const suiteInfo = await context.getSuiteInfo(browserContext, taskId)
14
14
  const baselines = await file.glob(join(suiteInfo.projectRoot, suiteInfo.baselineDir, `${suiteInfo.taskId}-*.png`))
15
15
  const results = await file.glob(join(suiteInfo.projectRoot, suiteInfo.resultDir, `${suiteInfo.taskId}-*.png`))
@@ -36,7 +36,7 @@ export function createVisServerContext() {
36
36
  return r
37
37
  },
38
38
  async getSnapshotInfo(
39
- browserContext: PartialBrowserCommandContext,
39
+ browserContext: ExtendedBrowserCommandContext,
40
40
  taskId: string,
41
41
  options?: ImageSnapshotKeyOptions,
42
42
  ) {
@@ -65,11 +65,11 @@ export function createVisServerContext() {
65
65
  }
66
66
  },
67
67
 
68
- async getTaskCount(browserContext: PartialBrowserCommandContext, taskId: string) {
68
+ async getTaskCount(browserContext: ExtendedBrowserCommandContext, taskId: string) {
69
69
  return (await context.getSuiteInfo(browserContext, taskId)).task.count
70
70
  },
71
71
  async hasImageSnapshot(
72
- browserContext: PartialBrowserCommandContext,
72
+ browserContext: ExtendedBrowserCommandContext,
73
73
  taskId: string,
74
74
  snapshotKey: string | undefined,
75
75
  ) {
@@ -80,7 +80,7 @@ export function createVisServerContext() {
80
80
  )
81
81
  },
82
82
  getSnapshotFilename(
83
- browserContext: PartialBrowserCommandContext,
83
+ browserContext: ExtendedBrowserCommandContext,
84
84
  info: { taskId: string; task: { count: number } },
85
85
  snapshotKey: string | undefined,
86
86
  ) {
@@ -91,7 +91,7 @@ export function createVisServerContext() {
91
91
  }
92
92
  return `${info.taskId}-${info.task.count}.png`
93
93
  },
94
- async getSuiteInfo(browserContext: PartialBrowserCommandContext, taskId: string) {
94
+ async getSuiteInfo(browserContext: ExtendedBrowserCommandContext, taskId: string) {
95
95
  const projectState = await getSuite(browserContext)
96
96
  const visOptions = getVisOption(browserContext)
97
97
  const moduleId = getTaskSubpath(projectState, browserContext.testPath, visOptions)
@@ -1,4 +1,6 @@
1
- import type { UserConfig } from 'vitest/node'
1
+ import type { Merge } from 'type-plus'
2
+ import type { BrowserCommandContext } from 'vitest/node'
3
+ import type { Awaitable } from '../shared/types.ts'
2
4
 
3
5
  export type VisSuites = {
4
6
  [projectPath: string]: Promise<VisSuite>
@@ -30,33 +32,36 @@ export type VisSuite = {
30
32
  >
31
33
  }
32
34
 
33
- export type PartialBrowserCommandContext = {
34
- project: {
35
- config: {
36
- name: string
37
- root: string
38
- snapshotOptions: {
39
- updateSnapshot: 'all' | 'new' | 'none'
35
+ export type ExtendedBrowserCommand<Payload extends unknown[] = [], ReturnValue = any> = (
36
+ context: ExtendedBrowserCommandContext,
37
+ ...payload: Payload
38
+ ) => Awaitable<ReturnValue>
39
+
40
+ export type ExtendedBrowserCommandContext = {
41
+ page: BrowserCommandContext['page']
42
+ browser: BrowserCommandContext['browser']
43
+ iframe: BrowserCommandContext['iframe']
44
+ testPath: NonNullable<BrowserCommandContext['testPath']>
45
+ provider: BrowserCommandContext['provider']
46
+ // project: BrowserCommandContext['project']
47
+ project: Merge<
48
+ BrowserCommandContext['project'],
49
+ {
50
+ browser: {
51
+ config: {
52
+ browser: {
53
+ name: string
54
+ screenshotFailures: boolean
55
+ screenshotDirectory: string
56
+ }
57
+ }
40
58
  }
41
- testTimeout: number
42
- hookTimeout: number
43
- }
44
- vite: {
45
- config: {
46
- test?: {
47
- name?: UserConfig['name'] | undefined
59
+ config: BrowserCommandContext['project']['config']
60
+ runner: {
61
+ config: {
62
+ name: string
48
63
  }
49
64
  }
50
65
  }
51
- }
52
- provider: {
53
- name: string
54
- browserName?: string | undefined
55
- options?: {
56
- headless?: boolean | undefined
57
- screenshotFailures?: boolean | undefined
58
- screenshotDirectory?: string | undefined
59
- }
60
- }
61
- testPath: string
66
+ >
62
67
  }
@@ -1,12 +1,9 @@
1
- import dedent from 'dedent'
2
- import { afterEach, beforeAll } from 'vitest'
3
- import type { SetupVisSuiteCommand } from '../../server/commands/setup_vis_suite.ts'
4
- import type { ComparisonMethod } from '../../shared/types.ts'
5
- import { extractAutoSnapshotOptions, setAutoSnapshotOptions } from '../auto_snapshot_options.ts'
6
- import { ctx } from '../ctx.ts'
7
- import { shouldTakeSnapshot } from '../should_take_snapshot.ts'
8
- import type { SnapshotMeta } from '../snapshot_meta.ts'
9
- import { toTaskId } from '../task_id.ts'
1
+ import { afterEach, beforeAll, expect } from 'vitest'
2
+ import { autoSnapshotMatcher } from '../client/suite/auto_snapshot_matcher.ts'
3
+ import { setAutoSnapshotOptions } from '../client/task/auto_snapshot_options.ts'
4
+ import type { SnapshotMeta } from '../client/task/snapshot_meta.ts'
5
+ import type { SetupVisSuiteCommand } from '../shared/commands.types.ts'
6
+ import type { ComparisonMethod, SetupVisOptions } from '../shared/types.ts'
10
7
 
11
8
  /**
12
9
  * Visual test configuration on the client side.
@@ -40,20 +37,7 @@ export type VisClientConfigurator<GM extends Record<string, any> | unknown = unk
40
37
  * })
41
38
  * ```
42
39
  */
43
- setup(options?: {
44
- auto?:
45
- | boolean
46
- | (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(
47
- options: SnapshotMeta<C> & M & GM,
48
- ) => Promise<boolean> | Promise<void> | boolean | void)
49
- | Record<
50
- string,
51
- | boolean
52
- | (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(
53
- options: SnapshotMeta<C> & M & GM,
54
- ) => Promise<boolean> | Promise<void> | boolean | void)
55
- >
56
- }): void
40
+ setup(options?: SetupVisOptions<GM>): void
57
41
  /**
58
42
  * @deprecated Use `vis.setup()` instead.
59
43
  */
@@ -122,106 +106,67 @@ export type VisClientConfigurator<GM extends Record<string, any> | unknown = unk
122
106
  }
123
107
 
124
108
  export function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand) {
125
- let subject: string | undefined
109
+ const matcher = autoSnapshotMatcher(commands, expect)
126
110
 
127
111
  const vis: VisClientConfigurator<GM> = {
128
112
  setup(options) {
129
113
  if (!options || options.auto === false) {
130
- beforeAll(vis.beforeAll.setup)
114
+ beforeAll(matcher.setup)
131
115
  } else {
132
116
  beforeAll(async () => {
133
- await vis.beforeAll.setup()
117
+ await matcher.setup()
134
118
  setAutoSnapshotOptions(true)
135
119
  })
136
120
  }
137
121
 
138
122
  if (typeof options?.auto === 'function') {
139
123
  afterEach(
140
- vis.afterEach.matchPerTheme({
124
+ matcher.createMatcher({
141
125
  auto: options.auto,
142
126
  }),
143
127
  )
144
128
  } else if (typeof options?.auto === 'object') {
145
- afterEach(vis.afterEach.matchPerTheme(options.auto))
129
+ afterEach(matcher.createMatcher(options.auto))
146
130
  } else {
147
- afterEach(vis.afterEach.matchImageSnapshot)
131
+ afterEach(matcher.createMatcher({ async auto() {} }))
148
132
  }
149
133
  },
150
134
  presets: {
151
135
  enable() {
152
- beforeAll(vis.beforeAll.setup)
153
- afterEach(vis.afterEach.matchImageSnapshot)
136
+ beforeAll(matcher.setup)
137
+ afterEach(matcher.createMatcher({ async auto() {} }))
154
138
  },
155
139
  manual() {
156
- beforeAll(vis.beforeAll.setup)
140
+ beforeAll(matcher.setup)
157
141
  },
158
142
  auto() {
159
143
  beforeAll(async () => {
160
- await vis.beforeAll.setup()
144
+ await matcher.setup()
161
145
  setAutoSnapshotOptions(true)
162
146
  })
163
- afterEach(vis.afterEach.matchImageSnapshot)
147
+ afterEach(matcher.createMatcher({ async auto() {} }))
164
148
  },
165
149
  theme(themes) {
166
150
  beforeAll(async () => {
167
- await vis.beforeAll.setup()
151
+ await matcher.setup()
168
152
  setAutoSnapshotOptions(true)
169
153
  })
170
- afterEach(vis.afterEach.matchPerTheme(themes))
154
+ afterEach(matcher.createMatcher(themes))
171
155
  },
172
156
  },
173
157
  beforeAll: {
174
158
  async setup() {
175
- subject = (await commands.setupVisSuite()).subject
159
+ await matcher.setup()
176
160
  },
177
161
  },
178
162
  afterEach: {
179
163
  async matchImageSnapshot() {
180
- return vis.afterEach.matchPerTheme({ async auto() {} })()
164
+ return matcher.createMatcher({ async auto() {} })()
181
165
  },
182
166
  matchPerTheme(themes) {
183
- return async function matchImageSnapshot() {
184
- const test = ctx.getCurrentTest()
185
- if ((test?.result?.errors?.length ?? 0) > 0) return
186
-
187
- const meta = extractAutoSnapshotOptions(test)
188
- if (!shouldTakeSnapshot(meta)) return
189
- const errors: Array<[string, Error]> = []
190
- for (const themeId in themes) {
191
- try {
192
- await new Promise((a) => setTimeout(a, 10))
193
- const theme = themes[themeId]
194
- const r = typeof theme === 'function' ? await theme(meta! as any) : theme
195
- if (r === false) continue
196
- await test!.context.expect(getSubject(meta?.subject ?? subject)).toMatchImageSnapshot({
197
- ...meta,
198
- snapshotKey: meta?.snapshotKey ?? themeId,
199
- })
200
- } catch (error) {
201
- errors.push([themeId, error as Error])
202
- }
203
- }
204
- if (errors.length > 0) {
205
- if (errors.length === 1) throw errors[0]![1]
206
- const taskId = toTaskId(test!)
207
- throw new AggregateError(
208
- errors,
209
- dedent`Snapshot \`${taskId}\` mismatched
210
-
211
- ${errors
212
- .map(([themeId, error]) => {
213
- return `Theme \`${themeId}\` failed: ${error.message}`
214
- })
215
- .join('\n\n')}`,
216
- )
217
- }
218
- }
167
+ return matcher.createMatcher(themes)
219
168
  },
220
169
  },
221
170
  }
222
171
  return vis
223
172
  }
224
-
225
- function getSubject(selectors: string | undefined) {
226
- return selectors ? (document.querySelector(selectors) ?? document.body) : document.body
227
- }
@@ -0,0 +1,5 @@
1
+ # setup
2
+
3
+ Code in this directory is used to setup the plugin in `vitest.setup.ts`.
4
+
5
+ The code is executed in a NodeJS main thread.
@@ -1,4 +1,4 @@
1
- import { commands } from '@vitest/browser/context'
1
+ import { commands } from 'vitest/browser'
2
2
  import { createVis } from './create_vis.ts'
3
3
 
4
4
  /**
package/src/setup.ts CHANGED
@@ -2,5 +2,5 @@
2
2
  import './client/expect/extend.ts'
3
3
  import './client/page/extend.ts'
4
4
 
5
- export * from './client/setup/create_vis.ts'
6
- export * from './client/setup/vis.ts'
5
+ export * from './setup/create_vis.ts'
6
+ export * from './setup/vis.ts'
@@ -0,0 +1,71 @@
1
+ import type { Pick } from 'type-plus'
2
+ import type { VisOptions } from '../config/types.ts'
3
+ import type { ImageSnapshotComparisonInfo, MatchImageSnapshotOptions } from './types.ts'
4
+
5
+ export interface PrepareImageSnapshotComparisonCommand {
6
+ prepareImageSnapshotComparison: (
7
+ taskId: string,
8
+ subject: string,
9
+ options?: MatchImageSnapshotOptions | undefined,
10
+ ) => Promise<ImageSnapshotComparisonInfo | undefined>
11
+ }
12
+
13
+ export interface PreparePageImageSnapshotComparisonCommand {
14
+ preparePageImageSnapshotComparison: (
15
+ taskId: string,
16
+ options?: MatchImageSnapshotOptions | undefined,
17
+ ) => Promise<ImageSnapshotComparisonInfo | undefined>
18
+ }
19
+
20
+ export interface SetupVisSuiteCommand {
21
+ /**
22
+ * Sets up the visual testing suite by cleaning up previous snapshot and diff output directories.
23
+ * When this command is run for the first time,
24
+ * it will remove the results and diffs directory of all suites.
25
+ *
26
+ * In subsequent runs, it will only remove the results and diffs directory of the current suite.
27
+ */
28
+ setupVisSuite: () => Promise<
29
+ Pick<
30
+ VisOptions,
31
+ | 'comparisonMethod'
32
+ | 'diffOptions'
33
+ | 'failureThreshold'
34
+ | 'failureThresholdType'
35
+ | 'snapshotKey'
36
+ | 'subject'
37
+ | 'timeout'
38
+ >
39
+ >
40
+ }
41
+
42
+ export interface LoadImageSnapshotResultsCommand {
43
+ loadImageSnapshotResults(taskId: string): Promise<ImageSnapshotResult[]>
44
+ }
45
+
46
+ export interface ImageSnapshotResult {
47
+ filename: string
48
+ /**
49
+ * The base64 encoded image of the baseline snapshot.
50
+ */
51
+ baseline?: string | undefined
52
+ /**
53
+ * The base64 encoded image of the result snapshot.
54
+ */
55
+ result?: string | undefined
56
+ /**
57
+ * The base64 encoded image of the diff snapshot.
58
+ */
59
+ diff?: string | undefined
60
+ }
61
+
62
+ export interface HasImageSnapshotCommand {
63
+ hasImageSnapshot(taskId: string, snapshotKey: string | undefined): Promise<boolean>
64
+ }
65
+
66
+ export interface ImageSnapshotNextIndexCommand {
67
+ /**
68
+ * Get the index of the snapshot image to be created.
69
+ */
70
+ imageSnapshotNextIndex(taskId: string): Promise<number>
71
+ }