vitest-plugin-vis 4.1.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/dist/auto_snapshots/_ctx.mjs +15 -0
  2. package/dist/auto_snapshots/_ctx.mjs.map +1 -0
  3. package/dist/auto_snapshots/_extract_auto_snapshot_options.mjs +23 -0
  4. package/dist/auto_snapshots/_extract_auto_snapshot_options.mjs.map +1 -0
  5. package/dist/{auto_snapshot_options-BMRtKmod.d.mts → auto_snapshots/auto_snapshot_options.d.mts} +5 -4
  6. package/dist/auto_snapshots/auto_snapshot_options.d.mts.map +1 -0
  7. package/dist/{auto_snapshot_options-DUOTpF2N.mjs → auto_snapshots/auto_snapshot_options.mjs} +6 -40
  8. package/dist/auto_snapshots/auto_snapshot_options.mjs.map +1 -0
  9. package/dist/auto_snapshots/snapshot_meta.d.mts +15 -0
  10. package/dist/auto_snapshots/snapshot_meta.d.mts.map +1 -0
  11. package/dist/client/actions/has_image_snapshot_action.d.mts +8 -0
  12. package/dist/client/actions/has_image_snapshot_action.d.mts.map +1 -0
  13. package/dist/client/actions/has_image_snapshot_action.mjs +9 -0
  14. package/dist/client/actions/has_image_snapshot_action.mjs.map +1 -0
  15. package/dist/client/actions/load_image_snapshot_results_action.d.mts +7 -0
  16. package/dist/client/actions/load_image_snapshot_results_action.d.mts.map +1 -0
  17. package/dist/client/actions/load_image_snapshot_results_action.mjs +8 -0
  18. package/dist/client/actions/load_image_snapshot_results_action.mjs.map +1 -0
  19. package/dist/client/actions/match_image_snapshot_action.d.mts +9 -0
  20. package/dist/client/actions/match_image_snapshot_action.d.mts.map +1 -0
  21. package/dist/client/actions/match_image_snapshot_action.mjs +20 -0
  22. package/dist/client/actions/match_image_snapshot_action.mjs.map +1 -0
  23. package/dist/client/actions/match_page_image_snapshot_action.d.mts +9 -0
  24. package/dist/client/actions/match_page_image_snapshot_action.d.mts.map +1 -0
  25. package/dist/client/actions/match_page_image_snapshot_action.mjs +14 -0
  26. package/dist/client/actions/match_page_image_snapshot_action.mjs.map +1 -0
  27. package/dist/client/expect/_ctx.mjs +15 -0
  28. package/dist/client/expect/_ctx.mjs.map +1 -0
  29. package/dist/client/expect/augment.d.mts +10 -0
  30. package/dist/client/expect/augment.d.mts.map +1 -0
  31. package/dist/client/expect/expectation_result.d.mts +7 -0
  32. package/dist/client/expect/expectation_result.d.mts.map +1 -0
  33. package/dist/client/expect/expectation_result.mjs +9 -0
  34. package/dist/client/expect/expectation_result.mjs.map +1 -0
  35. package/dist/client/expect/extend.d.mts +1 -0
  36. package/dist/client/expect/extend.mjs +9 -0
  37. package/dist/client/expect/extend.mjs.map +1 -0
  38. package/dist/client/expect/to_match_image_snapshot.mjs +16 -0
  39. package/dist/client/expect/to_match_image_snapshot.mjs.map +1 -0
  40. package/dist/{to_match_image_snapshot.types--tTmHoRA.d.mts → client/expect/to_match_image_snapshot.types.d.mts} +3 -3
  41. package/dist/client/expect/to_match_image_snapshot.types.d.mts.map +1 -0
  42. package/dist/client/external/browser/has_render_content.mjs +8 -0
  43. package/dist/client/external/browser/has_render_content.mjs.map +1 -0
  44. package/dist/client/external/browser/image_data.mjs +37 -0
  45. package/dist/client/external/browser/image_data.mjs.map +1 -0
  46. package/dist/client/external/browser/image_resizer.mjs +32 -0
  47. package/dist/client/external/browser/image_resizer.mjs.map +1 -0
  48. package/dist/client/external/browser/selector.mjs +57 -0
  49. package/dist/client/external/browser/selector.mjs.map +1 -0
  50. package/dist/client/external/vitest/vitest_browser_context_proxy.mjs +12 -0
  51. package/dist/client/external/vitest/vitest_browser_context_proxy.mjs.map +1 -0
  52. package/dist/client/external/vitest/vitest_suite_proxy.d.mts +3 -0
  53. package/dist/client/external/vitest/vitest_suite_proxy.mjs +11 -0
  54. package/dist/client/external/vitest/vitest_suite_proxy.mjs.map +1 -0
  55. package/dist/client/image/align_images.mjs +14 -0
  56. package/dist/client/image/align_images.mjs.map +1 -0
  57. package/dist/client/page/_ctx.d.mts +3 -0
  58. package/dist/client/page/_ctx.mjs +15 -0
  59. package/dist/client/page/_ctx.mjs.map +1 -0
  60. package/dist/client/page/augment.d.mts +9 -0
  61. package/dist/client/page/augment.d.mts.map +1 -0
  62. package/dist/client/page/extend.d.mts +1 -0
  63. package/dist/client/page/extend.mjs +13 -0
  64. package/dist/client/page/extend.mjs.map +1 -0
  65. package/dist/client/page/has_image_snapshot.d.mts +13 -0
  66. package/dist/client/page/has_image_snapshot.d.mts.map +1 -0
  67. package/dist/client/page/has_image_snapshot.mjs +15 -0
  68. package/dist/client/page/has_image_snapshot.mjs.map +1 -0
  69. package/dist/client/page/to_match_image_snapshot.d.mts +9 -0
  70. package/dist/client/page/to_match_image_snapshot.d.mts.map +1 -0
  71. package/dist/client/page/to_match_image_snapshot.mjs +15 -0
  72. package/dist/client/page/to_match_image_snapshot.mjs.map +1 -0
  73. package/dist/client/snapshot/compare_image_snapshot.logic.mjs +14 -0
  74. package/dist/client/snapshot/compare_image_snapshot.logic.mjs.map +1 -0
  75. package/dist/client/snapshot/compare_image_snapshot.mjs +63 -0
  76. package/dist/client/snapshot/compare_image_snapshot.mjs.map +1 -0
  77. package/dist/client/snapshot/should_take_snapshot.mjs +10 -0
  78. package/dist/client/snapshot/should_take_snapshot.mjs.map +1 -0
  79. package/dist/client/suite/_ctx.mjs +13 -0
  80. package/dist/client/suite/_ctx.mjs.map +1 -0
  81. package/dist/client/suite/auto_snapshot_matcher.d.mts +12 -0
  82. package/dist/client/suite/auto_snapshot_matcher.d.mts.map +1 -0
  83. package/dist/client/suite/auto_snapshot_matcher.mjs +50 -0
  84. package/dist/client/suite/auto_snapshot_matcher.mjs.map +1 -0
  85. package/dist/client/task/task_id.d.mts +9 -0
  86. package/dist/client/task/task_id.d.mts.map +1 -0
  87. package/dist/client/task/task_id.mjs +15 -0
  88. package/dist/client/task/task_id.mjs.map +1 -0
  89. package/dist/client-api.d.mts +13 -44
  90. package/dist/client-api.mjs +10 -13
  91. package/dist/{types-DJYCbyT8.d.mts → config/types.d.mts} +8 -9
  92. package/dist/config/types.d.mts.map +1 -0
  93. package/dist/config/vis.d.mts +27 -0
  94. package/dist/config/vis.d.mts.map +1 -0
  95. package/dist/config/vis.mjs +31 -0
  96. package/dist/config/vis.mjs.map +1 -0
  97. package/dist/config.d.mts +5 -28
  98. package/dist/config.mjs +3 -411
  99. package/dist/index.d.mts +5 -5
  100. package/dist/index.mjs +1 -4
  101. package/dist/presets/auto.mjs +4 -7
  102. package/dist/presets/auto.mjs.map +1 -1
  103. package/dist/presets/enable.mjs +2 -6
  104. package/dist/presets/enable.mjs.map +1 -1
  105. package/dist/presets/manual.mjs +2 -6
  106. package/dist/presets/manual.mjs.map +1 -1
  107. package/dist/server/browser_provider/browser_api.mjs +13 -0
  108. package/dist/server/browser_provider/browser_api.mjs.map +1 -0
  109. package/dist/server/browser_provider/playwright.mjs +24 -0
  110. package/dist/server/browser_provider/playwright.mjs.map +1 -0
  111. package/dist/server/browser_provider/webdriverio.mjs +16 -0
  112. package/dist/server/browser_provider/webdriverio.mjs.map +1 -0
  113. package/dist/server/commands/_assertions.mjs +10 -0
  114. package/dist/server/commands/_assertions.mjs.map +1 -0
  115. package/dist/server/commands/augment.d.mts +8 -0
  116. package/dist/server/commands/augment.d.mts.map +1 -0
  117. package/dist/server/commands/commands.mjs +20 -0
  118. package/dist/server/commands/commands.mjs.map +1 -0
  119. package/dist/server/commands/has_image_snapshot.mjs +12 -0
  120. package/dist/server/commands/has_image_snapshot.mjs.map +1 -0
  121. package/dist/server/commands/image_snapshot_next_index.mjs +12 -0
  122. package/dist/server/commands/image_snapshot_next_index.mjs.map +1 -0
  123. package/dist/server/commands/load_image_snapshot_results.mjs +12 -0
  124. package/dist/server/commands/load_image_snapshot_results.mjs.map +1 -0
  125. package/dist/server/commands/prepare_image_snapshot_comparison.mjs +37 -0
  126. package/dist/server/commands/prepare_image_snapshot_comparison.mjs.map +1 -0
  127. package/dist/server/commands/prepare_page_image_snapshot_comparison.mjs +27 -0
  128. package/dist/server/commands/prepare_page_image_snapshot_comparison.mjs.map +1 -0
  129. package/dist/server/commands/setup_vis_suite.mjs +12 -0
  130. package/dist/server/commands/setup_vis_suite.mjs.map +1 -0
  131. package/dist/server/externals/file.mjs +23 -0
  132. package/dist/server/externals/file.mjs.map +1 -0
  133. package/dist/server/project.mjs +13 -0
  134. package/dist/server/project.mjs.map +1 -0
  135. package/dist/server/snapshot.mjs +29 -0
  136. package/dist/server/snapshot.mjs.map +1 -0
  137. package/dist/server/snapshot_path.d.mts +17 -0
  138. package/dist/server/snapshot_path.d.mts.map +1 -0
  139. package/dist/{snapshot_path-7GliOSH_.mjs → server/snapshot_path.mjs} +7 -25
  140. package/dist/server/snapshot_path.mjs.map +1 -0
  141. package/dist/server/snapshot_writer.mjs +21 -0
  142. package/dist/server/snapshot_writer.mjs.map +1 -0
  143. package/dist/server/suite.mjs +82 -0
  144. package/dist/server/suite.mjs.map +1 -0
  145. package/dist/server/vis_options.mjs +19 -0
  146. package/dist/server/vis_options.mjs.map +1 -0
  147. package/dist/server/vis_server_context.deps.mjs +16 -0
  148. package/dist/server/vis_server_context.deps.mjs.map +1 -0
  149. package/dist/server/vis_server_context.logic.mjs +82 -0
  150. package/dist/server/vis_server_context.logic.mjs.map +1 -0
  151. package/dist/server/vis_server_context.mjs +8 -0
  152. package/dist/server/vis_server_context.mjs.map +1 -0
  153. package/dist/server/vis_server_context.types.d.mts +2 -0
  154. package/dist/server-utils.d.mts +4 -19
  155. package/dist/server-utils.mjs +3 -2
  156. package/dist/setup/create_vis.d.mts +108 -0
  157. package/dist/setup/create_vis.d.mts.map +1 -0
  158. package/dist/setup/create_vis.mjs +58 -0
  159. package/dist/setup/create_vis.mjs.map +1 -0
  160. package/dist/setup/vis.d.mts +10 -0
  161. package/dist/setup/vis.d.mts.map +1 -0
  162. package/dist/setup/vis.mjs +12 -0
  163. package/dist/setup/vis.mjs.map +1 -0
  164. package/dist/setup-api.d.mts +4 -0
  165. package/dist/setup-api.mjs +5 -0
  166. package/dist/setup.d.mts +8 -101
  167. package/dist/setup.d.mts.map +1 -1
  168. package/dist/setup.mjs +12 -7
  169. package/dist/setup.mjs.map +1 -0
  170. package/dist/{asserts--HSSlgPD.mjs → shared/asserts.mjs} +2 -2
  171. package/dist/shared/asserts.mjs.map +1 -0
  172. package/dist/{base64-CHSENEAO.mjs → shared/base64.mjs} +2 -2
  173. package/dist/shared/base64.mjs.map +1 -0
  174. package/dist/{commands.types-BVhcnnHw.d.mts → shared/commands.types.d.mts} +6 -6
  175. package/dist/shared/commands.types.d.mts.map +1 -0
  176. package/dist/shared/compare_image.mjs +46 -0
  177. package/dist/shared/compare_image.mjs.map +1 -0
  178. package/dist/shared/constants.d.mts +9 -0
  179. package/dist/shared/constants.d.mts.map +1 -0
  180. package/dist/{constants-CTBaz8Ml.mjs → shared/constants.mjs} +2 -2
  181. package/dist/shared/constants.mjs.map +1 -0
  182. package/dist/shared/convert_threshold_unit.mjs +12 -0
  183. package/dist/shared/convert_threshold_unit.mjs.map +1 -0
  184. package/dist/shared/get_max_size.mjs +11 -0
  185. package/dist/shared/get_max_size.mjs.map +1 -0
  186. package/dist/shared/is_same_size.mjs +8 -0
  187. package/dist/shared/is_same_size.mjs.map +1 -0
  188. package/dist/{trim_common_folder-DBThLerp.d.mts → shared/trim_common_folder.d.mts} +2 -2
  189. package/dist/shared/trim_common_folder.d.mts.map +1 -0
  190. package/dist/shared/trim_common_folder.mjs +23 -0
  191. package/dist/shared/trim_common_folder.mjs.map +1 -0
  192. package/dist/{types-CEmjj-A9.d.mts → shared/types.d.mts} +6 -21
  193. package/dist/shared/types.d.mts.map +1 -0
  194. package/dist/testing/constants.d.mts +12 -0
  195. package/dist/testing/constants.d.mts.map +1 -0
  196. package/dist/testing/constants.mjs +65550 -0
  197. package/dist/{testing.mjs.map → testing/constants.mjs.map} +1 -1
  198. package/dist/testing.d.mts +2 -12
  199. package/dist/testing.mjs +2 -65549
  200. package/package.json +24 -17
  201. package/readme.md +48 -3
  202. package/src/{client/task → auto_snapshots}/_ctx.ts +1 -1
  203. package/src/auto_snapshots/_extract_auto_snapshot_options.ts +26 -0
  204. package/src/{client/task → auto_snapshots}/auto_snapshot_options.mdx +1 -2
  205. package/src/{client/task → auto_snapshots}/auto_snapshot_options.ts +3 -25
  206. package/src/{client/task → auto_snapshots}/snapshot_meta.ts +1 -1
  207. package/src/client/actions/match_image_snapshot_action.ts +0 -2
  208. package/src/client/snapshot/compare_image_snapshot.logic.ts +1 -1
  209. package/src/client/snapshot/compare_image_snapshot.ts +15 -1
  210. package/src/client/snapshot/should_take_snapshot.ts +1 -1
  211. package/src/client/suite/auto_snapshot_matcher.ts +2 -3
  212. package/src/client-api.ts +1 -1
  213. package/src/config/overview.mdx +145 -0
  214. package/src/{shared → config}/trim_common_folder.mdx +1 -1
  215. package/src/config/types.ts +5 -6
  216. package/src/config/vis.mdx +313 -0
  217. package/src/index.ts +1 -1
  218. package/src/overview.mdx +66 -28
  219. package/src/server/commands/prepare_image_snapshot_comparison.ts +8 -8
  220. package/src/server/commands/prepare_page_image_snapshot_comparison.ts +1 -6
  221. package/src/server/snapshot_path.ts +3 -1
  222. package/src/server/vis_options.ts +2 -1
  223. package/src/{setup.create_vis.mdx → setup/create_vis.mdx} +4 -5
  224. package/src/setup/create_vis.ts +12 -7
  225. package/src/setup/overview.mdx +17 -0
  226. package/src/setup/readme.md +3 -1
  227. package/src/{setup.vis.mdx → setup/vis.mdx} +15 -18
  228. package/src/setup-api.ts +5 -0
  229. package/src/setup.ts +8 -4
  230. package/src/shared/commands.types.ts +2 -2
  231. package/src/shared/types.ts +3 -2
  232. package/dist/asserts--HSSlgPD.mjs.map +0 -1
  233. package/dist/augment-C1tjdh5B.d.mts +0 -33
  234. package/dist/augment-C1tjdh5B.d.mts.map +0 -1
  235. package/dist/auto_snapshot_matcher-C0y6mAeS.mjs +0 -381
  236. package/dist/auto_snapshot_matcher-C0y6mAeS.mjs.map +0 -1
  237. package/dist/auto_snapshot_options-BMRtKmod.d.mts.map +0 -1
  238. package/dist/auto_snapshot_options-DUOTpF2N.mjs.map +0 -1
  239. package/dist/base64-CHSENEAO.mjs.map +0 -1
  240. package/dist/client-api.d.mts.map +0 -1
  241. package/dist/client-api.mjs.map +0 -1
  242. package/dist/commands.types-BVhcnnHw.d.mts.map +0 -1
  243. package/dist/config.d.mts.map +0 -1
  244. package/dist/config.mjs.map +0 -1
  245. package/dist/constants-CTBaz8Ml.mjs.map +0 -1
  246. package/dist/server-utils.d.mts.map +0 -1
  247. package/dist/setup-DCytWz48.mjs +0 -124
  248. package/dist/setup-DCytWz48.mjs.map +0 -1
  249. package/dist/snapshot_path-7GliOSH_.mjs.map +0 -1
  250. package/dist/src-CSQnlFa9.mjs +0 -1
  251. package/dist/testing.d.mts.map +0 -1
  252. package/dist/to_match_image_snapshot.types--tTmHoRA.d.mts.map +0 -1
  253. package/dist/trim_common_folder-DBThLerp.d.mts.map +0 -1
  254. package/dist/types-CEmjj-A9.d.mts.map +0 -1
  255. package/dist/types-DJYCbyT8.d.mts.map +0 -1
  256. package/src/config.vis.mdx +0 -76
@@ -1 +0,0 @@
1
- {"version":3,"file":"base64-CHSENEAO.mjs","names":[],"sources":["../src/shared/base64.ts"],"sourcesContent":["export function isBase64String(value: unknown): value is string {\n\treturn typeof value === 'string' && /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/.test(value)\n}\n"],"mappings":";AAAA,SAAgB,eAAe,OAAiC;AAC/D,QAAO,OAAO,UAAU,YAAY,mEAAmE,KAAK,MAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-api.d.mts","names":[],"sources":["../src/server/commands/augment.ts","../src/client/actions/has_image_snapshot_action.ts","../src/client/actions/load_image_snapshot_results_action.ts","../src/client/actions/match_image_snapshot_action.ts","../src/client/actions/match_page_image_snapshot_action.ts","../src/client/expect/expectation_result.ts","../src/client/suite/auto_snapshot_matcher.ts","../src/client/task/task_id.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;oCAWU,sBACP,+BACA,yBACA,2CACA,uCACA;;;;;iBCba,sBAAA,WACL,gCAAgC,mDAEhC,sCAAmC;;;iBCJ9B,8BAAA,WAAyC,kDAA+C,QAAhB,mBAAA;;;iBCSlE,wBAAA,WACX,kBAAkB,wCAAwC,uEAG1D,mCAAgC;;;iBCNrB,4BAAA,WACX,kBAAkB,wCAAwC,yDAE1D,mCAAgC;;;cCV9B,SAAS;;;iBCON,+BAA+B,mDACpC;;0BASe,4BAA4B,iDAC3C,oCAEc,aAAa,KAAK,IAAI,OAAO,mBAAmB,yCACrE;;;;KCvBC,IAAA;;UAEI;;iBAGO,QAAA,OAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-api.mjs","names":[],"sources":["../src/client/actions/load_image_snapshot_results_action.ts"],"sourcesContent":["import type { LoadImageSnapshotResultsCommand } from '../../shared/commands.types.ts'\n\nexport function loadImageSnapshotResultsAction(commands: LoadImageSnapshotResultsCommand, taskId: string) {\n\treturn commands.loadImageSnapshotResults(taskId)\n}\n"],"mappings":";;;;;;;AAEA,SAAgB,+BAA+B,UAA2C,QAAgB;AACzG,QAAO,SAAS,yBAAyB,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"commands.types-BVhcnnHw.d.mts","names":[],"sources":["../src/shared/commands.types.ts"],"sourcesContent":[],"mappings":";;;;;UAIiB,qCAAA;8EAIL,0CACN,QAAQ;AALd;AAIY,UAIK,yCAAA,CAJL;EACE,kCAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAMF,yBANE,GAAA,SAAA,EAAA,GAOR,OAPQ,CAOA,2BAPA,GAAA,SAAA,CAAA;;AAAD,UAUI,oBAAA,CAVJ;EAGI;;;;;AAOjB;;EASE,aAAA,EAAA,GAAA,GADoB,OACpB,CAAA,IAAA,CACC,UADD,EAAA,kBAAA,GAAA,aAAA,GAAA,kBAAA,GAAA,sBAAA,GAAA,aAAA,GAAA,SAAA,GAAA,SAAA,CAAA,CAAA;;AAD2B,UAcZ,+BAAA,CAdY;EAcZ,wBAAA,CAAA,MAAA,EAAA,MAA+B,CAAA,EACL,OAAQ,CAAA,mBAAR,EAAA,CAAA;AAG3C;AAgBiB,UAhBA,mBAAA,CAgBuB;EAIvB,QAAA,EAAA,MAAA;;;;;;;;;;;;;;UAJA,uBAAA;qEACmD;;UAGnD,6BAAA;;;;0CAIwB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.mts","names":[],"sources":["../src/config/vis.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAaA;;AAA8E,iBAA9D,GAA8D,CAAA,UAAhD,gBAAgD,GAAA,OAAA,CAAA,CAAA,OAAA,CAAA,EAAX,UAAW,CAAA,CAAA,CAAA,CAAA,EAAA;EAAX,IAAA,EAAA,MAAA;EAAU,MAGvD,CAAA,IAAA,EAAA,OAAA,EAAA,UAAA,EAHuD,KAAA,CAGvD,UAAA,CAAA,EAAA;IAAA,IAAA,EAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.mjs","names":["visOptions: Record<string, VisOptions<any> | undefined>","suites: VisSuites","visOptions","r: ImageSnapshotResult[]","r","visOptions","hasImageSnapshot: ExtendedBrowserCommand<Parameters<HasImageSnapshotCommand['hasImageSnapshot']>>","imageSnapshotNextIndex: ExtendedBrowserCommand<\n\tParameters<ImageSnapshotNextIndexCommand['imageSnapshotNextIndex']>\n>","loadImageSnapshotResults: ExtendedBrowserCommand<[taskId: string]>","mkdirp","writeFile","prepareImageSnapshotComparison: ExtendedBrowserCommand<\n\tParameters<PrepareImageSnapshotComparisonCommand['prepareImageSnapshotComparison']>\n>","preparePageImageSnapshotComparison: ExtendedBrowserCommand<\n\tParameters<PreparePageImageSnapshotComparisonCommand['preparePageImageSnapshotComparison']>\n>","setupVisSuite: ExtendedBrowserCommand<[]>"],"sources":["../src/server/externals/file.ts","../src/server/project.ts","../src/server/vis_options.ts","../src/server/vis_server_context.deps.ts","../src/server/suite.ts","../src/server/vis_server_context.logic.ts","../src/server/vis_server_context.ts","../src/server/commands/_assertions.ts","../src/server/commands/has_image_snapshot.ts","../src/server/commands/image_snapshot_next_index.ts","../src/server/commands/load_image_snapshot_results.ts","../src/server/browser_provider/playwright.ts","../src/server/browser_provider/webdriverio.ts","../src/server/browser_provider/browser_api.ts","../src/server/snapshot_writer.ts","../src/server/snapshot.ts","../src/server/commands/prepare_image_snapshot_comparison.ts","../src/server/commands/prepare_page_image_snapshot_comparison.ts","../src/server/commands/setup_vis_suite.ts","../src/server/commands/commands.ts","../src/config/vis.ts"],"sourcesContent":["import { glob, type GlobOptionsWithFileTypesUnset } from 'glob'\nimport { mkdirp } from 'mkdirp'\nimport { readFile, stat, writeFile } from 'node:fs/promises'\n\nexport const file = {\n\texistFile(filePath: string) {\n\t\treturn stat(filePath)\n\t\t\t.then((s) => s.isFile())\n\t\t\t.catch(() => false)\n\t},\n\tglob(pattern: string | string[], options?: GlobOptionsWithFileTypesUnset | undefined) {\n\t\treturn glob(pattern, options)\n\t},\n\tmkdirp: mkdirp as (path: string) => Promise<string | undefined>,\n\tasync tryReadFile(filePath: string | undefined): Promise<Buffer | undefined> {\n\t\tif (!filePath) return undefined\n\n\t\treturn readFile(filePath).catch(() => undefined)\n\t},\n\twriteFile,\n}\n","import type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'\n\nexport function getProjectName(context: ExtendedBrowserCommandContext) {\n\tconst { runner } = context.project\n\tconst name = runner.config.name\n\tif (typeof name === 'string') {\n\t\treturn name\n\t}\n\t// if (typeof name === 'object' && 'label' in name) {\n\t// \treturn (name as { label: string }).label\n\t// }\n\treturn undefined\n}\n\nexport function getProjectRoot(context: { project: { config: { root: string } } }) {\n\treturn context.project.config.root\n}\n","import type { TestUserConfig } from 'vitest/node'\nimport type { VisOptions } from '../config/types.ts'\nimport { assertSnapshotKeyWithoutDash } from '../shared/asserts.ts'\nimport { getProjectName } from './project.ts'\nimport type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'\n\nconst DEFAULT_PROJECT_NAME = '__default'\n\nconst visOptions: Record<string, VisOptions<any> | undefined> = {}\n\nexport function setVisOption(\n\tuserConfig: { test?: { name?: TestUserConfig['name'] | undefined } },\n\toptions: VisOptions<any> | undefined,\n) {\n\tassertSnapshotKeyWithoutDash(options?.snapshotKey)\n\n\tconst name = userConfig.test?.name\n\tconst id = typeof name === 'string' ? name : typeof name === 'object' ? name?.label : DEFAULT_PROJECT_NAME\n\tvisOptions[id] = options\n}\n\nexport function getVisOption(context: ExtendedBrowserCommandContext) {\n\tconst id = getProjectName(context) ?? DEFAULT_PROJECT_NAME\n\treturn visOptions[id] ?? {}\n}\n","/* v8 ignore start */\nimport ci from 'is-ci'\nimport { rimraf } from 'rimraf'\n\nexport const deps = {\n\trimraf,\n\tgetSnapshotPlatform() {\n\t\treturn ci ? process.platform : 'local'\n\t},\n}\n/* v8 ignore end */\n","import { join, relative } from 'pathe'\nimport type { VisOptions } from '../config/types.ts'\nimport { BASELINE_DIR, DIFF_DIR, RESULT_DIR } from '../shared/constants.ts'\nimport { getProjectName, getProjectRoot } from './project.ts'\nimport { getSnapshotSubpath, resolveSnapshotRootDir } from './snapshot_path.ts'\nimport { getVisOption } from './vis_options.ts'\nimport { deps } from './vis_server_context.deps.ts'\nimport type { ExtendedBrowserCommandContext, VisSuite, VisSuites } from './vis_server_context.types.ts'\n\nconst suites: VisSuites = {}\n\n/**\n * Setup suite is called on each test file's beforeAll hook.\n * Test files include vitest test files and storybook story files.\n * It needs to make sure there is no race condition between the test files.\n */\nexport async function setupSuite(browserContext: ExtendedBrowserCommandContext) {\n\tconst suiteId = getSuiteId(browserContext)\n\tconst visOptions = getVisOption(browserContext)\n\n\tif (!suites[suiteId]) {\n\t\tsuites[suiteId] = createSuite(browserContext, visOptions)\n\t}\n\n\tconst suite = await suites[suiteId]\n\n\tconst { taskSubpath, baselineDir, diffDir, resultDir, tasks } = createModule(\n\t\tsuite,\n\t\tbrowserContext.testPath!,\n\t\tvisOptions,\n\t)\n\tsuite.modules[taskSubpath] = { baselineDir, diffDir, resultDir, tasks }\n\n\tawait Promise.allSettled([deps.rimraf(diffDir), deps.rimraf(resultDir)])\n\treturn {\n\t\tcomparisonMethod: visOptions.comparisonMethod,\n\t\tdiffOptions: visOptions.diffOptions,\n\t\tfailureThreshold: visOptions.failureThreshold,\n\t\tfailureThresholdType: visOptions.failureThresholdType,\n\t\tsnapshotKey: visOptions.snapshotKey,\n\t\tsubject: visOptions.subject,\n\t\ttimeout: visOptions.timeout,\n\t}\n}\n\n/**\n * Suite ID also contains the project name to make it unique\n * across different projects.\n */\nexport function getSuiteId(context: ExtendedBrowserCommandContext) {\n\treturn `${getProjectName(context)}/${context.project.config.name}`\n}\n\nasync function createSuite(\n\tbrowserContext: ExtendedBrowserCommandContext,\n\tvisOptions: Pick<VisOptions, 'snapshotRootDir' | 'subject'>,\n) {\n\t// console.log('visOptions', visOptions)\n\tconst snapshotRootDir = resolveSnapshotRootDir(browserContext, visOptions)\n\tconst projectRoot = getProjectRoot(browserContext)\n\n\tconst state = {\n\t\tprojectRoot,\n\t\ttestTimeout: browserContext.project.config.testTimeout,\n\t\thookTimeout: browserContext.project.config.hookTimeout,\n\t\tsnapshotRootDir,\n\t\tsnapshotBaselineDir: join(snapshotRootDir, BASELINE_DIR),\n\t\tsnapshotResultDir: join(snapshotRootDir, RESULT_DIR),\n\t\tsnapshotDiffDir: join(snapshotRootDir, DIFF_DIR),\n\t\tsnapshotRootPath: join(projectRoot, snapshotRootDir),\n\t\tsubject: visOptions.subject,\n\t\tmodules: {},\n\t}\n\tawait Promise.allSettled([deps.rimraf(join(state.snapshotDiffDir)), deps.rimraf(join(state.snapshotResultDir))])\n\treturn state\n}\n\nexport function createModule(state: VisSuite, testPath: string, options: Pick<VisOptions, 'snapshotSubpath'>) {\n\tconst taskSubpath = getTaskSubpath(state, testPath, options)\n\treturn {\n\t\ttaskSubpath,\n\t\tbaselineDir: join(state.snapshotBaselineDir, taskSubpath),\n\t\tresultDir: join(state.snapshotResultDir, taskSubpath),\n\t\tdiffDir: join(state.snapshotDiffDir, taskSubpath),\n\t\ttasks: {},\n\t}\n}\n\nexport function getTaskSubpath(state: VisSuite, testPath: string, options: Pick<VisOptions, 'snapshotSubpath'>) {\n\treturn getSnapshotSubpath(relative(state.projectRoot, testPath), options)\n}\n\nexport function getSuite(context: ExtendedBrowserCommandContext) {\n\treturn suites[getSuiteId(context)]!\n}\n","import { basename, join, resolve } from 'pathe'\nimport { pick } from 'type-plus'\nimport type { ImageSnapshotKeyOptions } from '../client-api.ts'\nimport type { ImageSnapshotResult } from '../shared/commands.types.ts'\nimport { file } from './externals/file.ts'\nimport { getSuite, getTaskSubpath } from './suite.ts'\nimport { getVisOption } from './vis_options.ts'\nimport type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'\n\nexport function createVisServerContext() {\n\tconst context = {\n\t\tasync getSnapshotResults(browserContext: ExtendedBrowserCommandContext, taskId: string) {\n\t\t\tconst suiteInfo = await context.getSuiteInfo(browserContext, taskId)\n\t\t\tconst baselines = await file.glob(join(suiteInfo.projectRoot, suiteInfo.baselineDir, `${suiteInfo.taskId}-*.png`))\n\t\t\tconst results = await file.glob(join(suiteInfo.projectRoot, suiteInfo.resultDir, `${suiteInfo.taskId}-*.png`))\n\t\t\tconst diffs = await file.glob(join(suiteInfo.projectRoot, suiteInfo.diffDir, `${suiteInfo.taskId}-*.png`))\n\n\t\t\tconst r: ImageSnapshotResult[] = []\n\t\t\tawait Promise.all(\n\t\t\t\tbaselines.map(async (baselinePath) => {\n\t\t\t\t\tconst filename = basename(baselinePath)\n\t\t\t\t\tconst resultPath = results.find((r) => r.endsWith(filename))\n\t\t\t\t\tconst diffPath = diffs.find((d) => d.endsWith(filename))\n\n\t\t\t\t\tconst baselineBuffer = await file.tryReadFile(baselinePath)\n\t\t\t\t\tconst resultBuffer = await file.tryReadFile(resultPath)\n\t\t\t\t\tconst diffBuffer = await file.tryReadFile(diffPath)\n\t\t\t\t\tr.push({\n\t\t\t\t\t\tfilename,\n\t\t\t\t\t\tbaseline: baselineBuffer?.toString('base64'),\n\t\t\t\t\t\tresult: resultBuffer?.toString('base64'),\n\t\t\t\t\t\tdiff: diffBuffer?.toString('base64'),\n\t\t\t\t\t})\n\t\t\t\t}),\n\t\t\t)\n\t\t\treturn r\n\t\t},\n\t\tasync getSnapshotInfo(\n\t\t\tbrowserContext: ExtendedBrowserCommandContext,\n\t\t\ttaskId: string,\n\t\t\toptions?: ImageSnapshotKeyOptions,\n\t\t) {\n\t\t\tconst suiteInfo = await context.getSuiteInfo(browserContext, taskId)\n\t\t\tconst snapshotFilename = context.getSnapshotFilename(browserContext, suiteInfo, options?.snapshotKey)\n\n\t\t\tconst { baselineDir, resultDir, diffDir, task } = suiteInfo\n\n\t\t\ttask.count = task.count + 1\n\t\t\tconst baselinePath = join(baselineDir, snapshotFilename)\n\t\t\tconst resultPath = join(resultDir, snapshotFilename)\n\t\t\tconst diffPath = join(diffDir, snapshotFilename)\n\n\t\t\treturn {\n\t\t\t\t...pick(\n\t\t\t\t\tgetVisOption(browserContext),\n\t\t\t\t\t'comparisonMethod',\n\t\t\t\t\t'diffOptions',\n\t\t\t\t\t'failureThreshold',\n\t\t\t\t\t'failureThresholdType',\n\t\t\t\t\t'timeout',\n\t\t\t\t),\n\t\t\t\tbaselinePath,\n\t\t\t\tresultPath,\n\t\t\t\tdiffPath,\n\t\t\t}\n\t\t},\n\n\t\tasync getTaskCount(browserContext: ExtendedBrowserCommandContext, taskId: string) {\n\t\t\treturn (await context.getSuiteInfo(browserContext, taskId)).task.count\n\t\t},\n\t\tasync hasImageSnapshot(\n\t\t\tbrowserContext: ExtendedBrowserCommandContext,\n\t\t\ttaskId: string,\n\t\t\tsnapshotKey: string | undefined,\n\t\t) {\n\t\t\tconst info = await context.getSuiteInfo(browserContext, taskId)\n\n\t\t\treturn file.existFile(\n\t\t\t\tresolve(info.projectRoot, info.baselineDir, context.getSnapshotFilename(browserContext, info, snapshotKey)),\n\t\t\t)\n\t\t},\n\t\tgetSnapshotFilename(\n\t\t\tbrowserContext: ExtendedBrowserCommandContext,\n\t\t\tinfo: { taskId: string; task: { count: number } },\n\t\t\tsnapshotKey: string | undefined,\n\t\t) {\n\t\t\tif (snapshotKey) return `${info.taskId}-${snapshotKey}.png`\n\t\t\tconst visOptions = getVisOption(browserContext)\n\t\t\tif (typeof visOptions.snapshotKey === 'string') {\n\t\t\t\treturn `${info.taskId}-${visOptions.snapshotKey}.png`\n\t\t\t}\n\t\t\treturn `${info.taskId}-${info.task.count}.png`\n\t\t},\n\t\tasync getSuiteInfo(browserContext: ExtendedBrowserCommandContext, taskId: string) {\n\t\t\tconst projectState = await getSuite(browserContext)\n\t\t\tconst visOptions = getVisOption(browserContext)\n\t\t\tconst moduleId = getTaskSubpath(projectState, browserContext.testPath, visOptions)\n\t\t\tconst m = projectState.modules[moduleId]!\n\t\t\tconst task = (m.tasks[taskId] = m.tasks[taskId] ?? { count: 1 })\n\t\t\treturn {\n\t\t\t\tprojectRoot: projectState.projectRoot,\n\t\t\t\tsuiteId: moduleId,\n\t\t\t\ttaskId,\n\t\t\t\tbaselineDir: m.baselineDir,\n\t\t\t\tresultDir: m.resultDir,\n\t\t\t\tdiffDir: m.diffDir,\n\t\t\t\ttask,\n\t\t\t}\n\t\t},\n\t}\n\treturn context\n}\n","import { createVisServerContext } from './vis_server_context.logic.ts'\n\nexport const visServerContext = createVisServerContext()\n","import { isAbsolute } from 'pathe'\nimport type { RequiredPick } from 'type-plus'\nimport type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'\n\nexport function assertTestPathDefined(\n\tcontext: ExtendedBrowserCommandContext,\n\tcommandName: string,\n): asserts context is RequiredPick<ExtendedBrowserCommandContext, 'testPath'> {\n\tif (!context.testPath) {\n\t\tthrow new Error(`'commands.${commandName}' requires testPath to be defined`)\n\t}\n}\n\nexport function assertIsRelativePath(relativeFilePath: string, propName: string) {\n\tif (isAbsolute(relativeFilePath)) {\n\t\tthrow new Error(`'${propName}' must be a relative path`)\n\t}\n}\n","import type { HasImageSnapshotCommand } from '../../shared/commands.types.ts'\nimport { visServerContext } from '../vis_server_context.ts'\nimport type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'\nimport { assertTestPathDefined } from './_assertions.ts'\n\nexport const hasImageSnapshot: ExtendedBrowserCommand<Parameters<HasImageSnapshotCommand['hasImageSnapshot']>> = async (\n\tcontext,\n\ttaskId,\n\tsnapshotKey,\n) => {\n\tassertTestPathDefined(context, 'hasImageSnapshot')\n\n\treturn visServerContext.hasImageSnapshot(context as any, taskId, snapshotKey)\n}\n","import type { ImageSnapshotNextIndexCommand } from '../../shared/commands.types.ts'\nimport { visServerContext } from '../vis_server_context.ts'\nimport type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'\nimport { assertTestPathDefined } from './_assertions.ts'\n\nexport const imageSnapshotNextIndex: ExtendedBrowserCommand<\n\tParameters<ImageSnapshotNextIndexCommand['imageSnapshotNextIndex']>\n> = async (context, taskId) => {\n\tassertTestPathDefined(context, 'imageSnapshotNextIndex')\n\n\treturn visServerContext.getTaskCount(context, taskId)\n}\n","import type { ImageSnapshotResult } from '../../shared/commands.types.ts'\nimport { visServerContext } from '../vis_server_context.ts'\nimport type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'\nimport { assertTestPathDefined } from './_assertions.ts'\n\nexport const loadImageSnapshotResults: ExtendedBrowserCommand<[taskId: string]> = async (\n\tcontext,\n\ttaskId,\n): Promise<ImageSnapshotResult[]> => {\n\tassertTestPathDefined(context, 'loadImageSnapshotResults')\n\treturn visServerContext.getSnapshotResults(context, taskId)\n}\n","import { resolve } from 'pathe'\nimport type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'\nimport type { BrowserApi } from './types.ts'\n\nexport function playwright(context: ExtendedBrowserCommandContext): BrowserApi {\n\tconst { page, iframe } = context\n\n\treturn {\n\t\tasync takeScreenshot(projectRoot, relativeFilePath, selector, options) {\n\t\t\tconst subject = iframe.locator(selector)\n\t\t\treturn subject.screenshot({\n\t\t\t\tpath: resolve(projectRoot, relativeFilePath),\n\t\t\t\t...options,\n\t\t\t})\n\t\t},\n\t\tasync takePageScreenshot(projectRoot, relativeFilePath, options) {\n\t\t\treturn page.screenshot({\n\t\t\t\tpath: resolve(projectRoot, relativeFilePath),\n\t\t\t\t...options,\n\t\t\t})\n\t\t},\n\t}\n}\n","import type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'\nimport type { BrowserApi } from './types.ts'\n\nexport function webdriverio(context: ExtendedBrowserCommandContext): BrowserApi {\n\tconst { browser } = context\n\treturn {\n\t\tasync takeScreenshot(_projectRoot, relativeFilePath, selector) {\n\t\t\tconst element = await browser.$(`${selector}`)\n\t\t\treturn element.saveScreenshot(relativeFilePath)\n\t\t},\n\t\tasync takePageScreenshot(_projectRoot, relativeFilePath, options) {\n\t\t\treturn browser.saveScreenshot(relativeFilePath, options)\n\t\t},\n\t}\n}\n","import type { ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'\nimport { playwright } from './playwright.ts'\nimport { webdriverio } from './webdriverio.ts'\n\nexport function browserApi(context: ExtendedBrowserCommandContext) {\n\tif (context.provider.name === 'playwright') {\n\t\treturn playwright(context)\n\t}\n\tif (context.provider.name === 'webdriverio') {\n\t\treturn webdriverio(context)\n\t}\n\tthrow new Error(`Unsupported provider: ${context.provider.name}`)\n}\n","import { dirname } from 'pathe'\nimport { file } from './externals/file.ts'\n\nexport interface SnapshotWriter {\n\twriteBase64(filePath: string, data: string): Promise<void>\n\twriteBuffer(filePath: string, data: Buffer): Promise<void>\n}\n\nexport function createSnapshotWriter({ mkdirp, writeFile } = file): SnapshotWriter {\n\treturn {\n\t\tasync writeBase64(filePath: string, data: string) {\n\t\t\tawait mkdirp(dirname(filePath))\n\t\t\tawait writeFile(filePath, data, { encoding: 'base64' })\n\t\t},\n\t\tasync writeBuffer(filePath, data) {\n\t\t\tawait mkdirp(dirname(filePath))\n\t\t\tawait writeFile(filePath, data)\n\t\t},\n\t}\n}\n\nexport const snapshotWriter = createSnapshotWriter()\n","import { mkdirp } from 'mkdirp'\nimport { dirname, resolve } from 'pathe'\nimport { isBase64String } from '../shared/base64.ts'\nimport type { ImageSnapshotTimeoutOptions, PageImageSnapshotOptions } from '../shared/types.ts'\nimport { browserApi } from './browser_provider/browser_api.ts'\nimport { snapshotWriter } from './snapshot_writer.ts'\nimport type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'\n\nexport async function takeSnapshot(\n\tcontext: ExtendedBrowserCommandContext,\n\tprojectRoot: string,\n\trelativeFilePath: string,\n\tsubject: string,\n\toptions: ImageSnapshotTimeoutOptions | undefined,\n) {\n\tif (isBase64String(subject)) {\n\t\tawait snapshotWriter.writeBase64(resolve(projectRoot, relativeFilePath), subject)\n\t\treturn Buffer.from(subject, 'base64')\n\t}\n\treturn takeSnapshotByBrowser(context, projectRoot, relativeFilePath, subject, options)\n}\n\nexport async function takeSnapshotByBrowser(\n\tcontext: ExtendedBrowserCommandContext,\n\tprojectRoot: string,\n\trelativeFilePath: string,\n\tsubject: string,\n\toptions: ImageSnapshotTimeoutOptions | undefined,\n) {\n\tconst filePath = resolve(projectRoot, relativeFilePath)\n\tawait mkdirp(dirname(filePath))\n\tconst browser = browserApi(context)\n\treturn browser.takeScreenshot(projectRoot, relativeFilePath, subject ?? 'body', {\n\t\ttimeout: options?.timeout,\n\t})\n}\n\nexport async function takePageSnapshot(\n\tcontext: ExtendedBrowserCommandContext,\n\tprojectRoot: string,\n\trelativeFilePath: string,\n\toptions: (PageImageSnapshotOptions & ImageSnapshotTimeoutOptions) | undefined,\n) {\n\tconst filePath = resolve(projectRoot, relativeFilePath)\n\tawait mkdirp(dirname(filePath))\n\tconst browser = browserApi(context)\n\treturn browser.takePageScreenshot(projectRoot, relativeFilePath, {\n\t\ttimeout: options?.timeout,\n\t\tfullPage: options?.fullPage,\n\t})\n}\n","import { resolve } from 'pathe'\nimport { isBase64String } from '../../shared/base64.ts'\nimport type { PrepareImageSnapshotComparisonCommand } from '../../shared/commands.types.ts'\nimport type { ImageSnapshotComparisonInfo } from '../../shared/types.ts'\nimport { file } from '../externals/file.ts'\nimport { getProjectRoot } from '../project.ts'\nimport { takeSnapshot, takeSnapshotByBrowser } from '../snapshot.ts'\nimport { snapshotWriter } from '../snapshot_writer.ts'\nimport { visServerContext } from '../vis_server_context.ts'\nimport type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'\nimport { assertTestPathDefined } from './_assertions.ts'\n\nexport const prepareImageSnapshotComparison: ExtendedBrowserCommand<\n\tParameters<PrepareImageSnapshotComparisonCommand['prepareImageSnapshotComparison']>\n> = async (context, taskId, subject, options): Promise<ImageSnapshotComparisonInfo | undefined> => {\n\tassertTestPathDefined(context, 'prepareImageSnapshotComparison')\n\t// vitest:browser passes in `null` when not defined\n\tif (!options) options = {}\n\toptions.timeout = options.timeout ?? 30000\n\n\tconst projectRoot = getProjectRoot(context)\n\tconst info = await visServerContext.getSnapshotInfo(context, taskId, options)\n\n\tconst baselineBuffer = await file.tryReadFile(resolve(projectRoot, info.baselinePath))\n\tif (!baselineBuffer) {\n\t\tif (isBase64String(subject)) {\n\t\t\tawait snapshotWriter.writeBase64(resolve(projectRoot, info.baselinePath), subject)\n\t\t} else {\n\t\t\tawait takeSnapshotByBrowser(context, projectRoot, info.baselinePath, subject, options)\n\t\t}\n\t\treturn\n\t}\n\n\tconst resultBuffer = await takeSnapshot(context, projectRoot, info.resultPath, subject, options)\n\treturn {\n\t\t...info,\n\t\tprojectRoot,\n\t\tbaseline: baselineBuffer.toString('base64'),\n\t\tresult: resultBuffer.toString('base64'),\n\t}\n}\n","import { resolve } from 'pathe'\nimport type { PreparePageImageSnapshotComparisonCommand } from '../../shared/commands.types.ts'\nimport { file } from '../externals/file.ts'\nimport { getProjectRoot } from '../project.ts'\nimport { takePageSnapshot } from '../snapshot.ts'\nimport { visServerContext } from '../vis_server_context.ts'\nimport type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'\nimport { assertTestPathDefined } from './_assertions.ts'\n\nexport const preparePageImageSnapshotComparison: ExtendedBrowserCommand<\n\tParameters<PreparePageImageSnapshotComparisonCommand['preparePageImageSnapshotComparison']>\n> = async (context, taskId, options) => {\n\tassertTestPathDefined(context, 'preparePageImageSnapshotComparison')\n\t// vitest:browser passes in `null` when not defined\n\tif (!options) options = {}\n\toptions.timeout = options.timeout ?? 30000\n\n\tconst projectRoot = getProjectRoot(context)\n\tconst info = await visServerContext.getSnapshotInfo(context, taskId, options)\n\tconst baselineBuffer = await file.tryReadFile(resolve(projectRoot, info.baselinePath))\n\tif (!baselineBuffer) {\n\t\tawait takePageSnapshot(context, projectRoot, info.baselinePath, options)\n\t\treturn\n\t}\n\n\tconst resultBuffer = await takePageSnapshot(context, projectRoot, info.resultPath, options)\n\treturn {\n\t\t...info,\n\t\tprojectRoot,\n\t\tbaseline: baselineBuffer.toString('base64'),\n\t\tresult: resultBuffer.toString('base64'),\n\t}\n}\n","import { setupSuite } from '../suite.ts'\nimport type { ExtendedBrowserCommand, ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'\nimport { assertTestPathDefined } from './_assertions.ts'\n\nexport const setupVisSuite: ExtendedBrowserCommand<[]> = async (context): Promise<{ subject: string | undefined }> => {\n\tassertTestPathDefined(context, 'setupVisSuite')\n\treturn setupSuite(context as unknown as ExtendedBrowserCommandContext)\n}\n","import { hasImageSnapshot } from './has_image_snapshot.ts'\nimport { imageSnapshotNextIndex } from './image_snapshot_next_index.ts'\nimport { loadImageSnapshotResults } from './load_image_snapshot_results.ts'\nimport { prepareImageSnapshotComparison } from './prepare_image_snapshot_comparison.ts'\nimport { preparePageImageSnapshotComparison } from './prepare_page_image_snapshot_comparison.ts'\nimport { setupVisSuite } from './setup_vis_suite.ts'\n\nexport const commands = {\n\tsetupVisSuite,\n\timageSnapshotNextIndex,\n\thasImageSnapshot,\n\tpreparePageImageSnapshotComparison,\n\tprepareImageSnapshotComparison,\n\tloadImageSnapshotResults,\n}\n","import type { Plugin } from 'vitest/config'\nimport { commands } from '../server/commands/commands.ts'\nimport { setVisOption } from '../server/vis_options.ts'\nimport { NAME } from '../shared/constants.ts'\nimport type { ComparisonMethod } from '../shared/types.ts'\nimport type { VisOptions } from './types.ts'\n\n/**\n * Create a Vite plugin for visual testing.\n *\n * If options are not provided, the plugin will use the default options,\n * which enables the `auto` preset.\n */\nexport function vis<M extends ComparisonMethod = 'pixel'>(options: VisOptions<M> = { preset: 'auto' } as any) {\n\treturn {\n\t\tname: NAME,\n\t\tconfig(this: unknown, userConfig) {\n\t\t\tsetVisOption(userConfig, options)\n\t\t\tconst preset = options?.preset\n\t\t\treturn {\n\t\t\t\ttest: {\n\t\t\t\t\tbrowser: {\n\t\t\t\t\t\tname: undefined,\n\t\t\t\t\t\tcommands: commands as any,\n\t\t\t\t\t},\n\t\t\t\t\tsetupFiles: preset && preset !== 'none' && preset !== 'custom' ? [`vitest-plugin-vis/presets/${preset}`] : [],\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t} satisfies Plugin\n}\n"],"mappings":";;;;;;;;;;;;;AAIA,MAAa,OAAO;CACnB,UAAU,UAAkB;AAC3B,SAAO,KAAK,SAAS,CACnB,MAAM,MAAM,EAAE,QAAQ,CAAC,CACvB,YAAY,MAAM;;CAErB,KAAK,SAA4B,SAAqD;AACrF,SAAO,KAAK,SAAS,QAAQ;;CAEtB;CACR,MAAM,YAAY,UAA2D;AAC5E,MAAI,CAAC,SAAU,QAAO;AAEtB,SAAO,SAAS,SAAS,CAAC,YAAY,OAAU;;CAEjD;CACA;;;;AClBD,SAAgB,eAAe,SAAwC;CACtE,MAAM,EAAE,WAAW,QAAQ;CAC3B,MAAM,OAAO,OAAO,OAAO;AAC3B,KAAI,OAAO,SAAS,SACnB,QAAO;;AAQT,SAAgB,eAAe,SAAoD;AAClF,QAAO,QAAQ,QAAQ,OAAO;;;;;ACT/B,MAAM,uBAAuB;AAE7B,M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,eAAe,QAAQ;CAC3C,MAAM,OAAO,MAAM,iBAAiB,gBAAgB,SAAS,QAAQ,QAAQ;CAC7E,MAAM,iBAAiB,MAAM,KAAK,YAAY,QAAQ,aAAa,KAAK,aAAa,CAAC;AACtF,KAAI,CAAC,gBAAgB;AACpB,QAAM,iBAAiB,SAAS,aAAa,KAAK,cAAc,QAAQ;AACxE;;CAGD,MAAM,eAAe,MAAM,iBAAiB,SAAS,aAAa,KAAK,YAAY,QAAQ;AAC3F,QAAO;EACN,GAAG;EACH;EACA,UAAU,eAAe,SAAS,SAAS;EAC3C,QAAQ,aAAa,SAAS,SAAS;EACvC;;;;;AC3BF,MAAaC,gBAA4C,OAAO,YAAsD;AACrH,uBAAsB,SAAS,gBAAgB;AAC/C,QAAO,WAAW,QAAoD;;;;;ACCvE,MAAa,WAAW;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;;;;;;;;;;ACDD,SAAgB,IAA0C,UAAyB,EAAE,QAAQ,QAAQ,EAAS;AAC7G,QAAO;EACN,MAAM;EACN,OAAsB,YAAY;AACjC,gBAAa,YAAY,QAAQ;GACjC,MAAM,SAAS,SAAS;AACxB,UAAO,EACN,MAAM;IACL,SAAS;KACR,MAAM;KACI;KACV;IACD,YAAY,UAAU,WAAW,UAAU,WAAW,WAAW,CAAC,6BAA6B,SAAS,GAAG,EAAE;IAC7G,EACD;;EAEF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-CTBaz8Ml.mjs","names":[],"sources":["../src/shared/constants.ts"],"sourcesContent":["export const NAME = 'vis'\nexport const SNAPSHOT_ROOT_DIR = '__vis__'\nexport const BASELINE_DIR = '__baselines__'\nexport const RESULT_DIR = '__results__'\nexport const DIFF_DIR = '__diffs__'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,oBAAoB;AACjC,MAAa,eAAe;AAC5B,MAAa,aAAa;AAC1B,MAAa,WAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server-utils.d.mts","names":[],"sources":["../src/server/snapshot_path.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AA8BA;;;;;iBAAgB,kBAAA"}
@@ -1,124 +0,0 @@
1
- import { n as setAutoSnapshotOptions, r as getCurrentTest } from "./auto_snapshot_options-DUOTpF2N.mjs";
2
- import { a as matchImageSnapshotAction, i as matchPageImageSnapshotAction, n as toTaskId, o as hasImageSnapshotAction, r as success, t as autoSnapshotMatcher } from "./auto_snapshot_matcher-C0y6mAeS.mjs";
3
- import { afterEach, beforeAll, expect } from "vitest";
4
- import { commands, page } from "vitest/browser";
5
-
6
- //#region src/client/expect/_ctx.ts
7
- const ctx$1 = {
8
- commands,
9
- getCurrentTest,
10
- __test__reset() {
11
- ctx$1.getCurrentTest = getCurrentTest;
12
- }
13
- };
14
-
15
- //#endregion
16
- //#region src/client/expect/to_match_image_snapshot.ts
17
- function toMatchImageSnapshot$1(subject, options) {
18
- const test = ctx$1.getCurrentTest();
19
- if (!test) throw new Error("`toMatchImageSnapshot()` must be called in a test.");
20
- if (test.concurrent) throw new Error("`toMatchImageSnapshot()` cannot be called in a concurrent test because concurrent tests run at the same time in the same iframe and affect each other's environment.");
21
- return matchImageSnapshotAction(ctx$1.commands, toTaskId(test), subject, options).then(() => success);
22
- }
23
-
24
- //#endregion
25
- //#region src/client/expect/extend.ts
26
- expect.extend({ toMatchImageSnapshot: toMatchImageSnapshot$1 });
27
-
28
- //#endregion
29
- //#region src/client/page/_ctx.ts
30
- const ctx = {
31
- commands,
32
- getCurrentTest,
33
- __test__reset() {
34
- ctx.getCurrentTest = getCurrentTest;
35
- }
36
- };
37
-
38
- //#endregion
39
- //#region src/client/page/has_image_snapshot.ts
40
- function hasImageSnapshot(options) {
41
- const test = ctx.getCurrentTest();
42
- if (!test) throw new Error("`hasImageSnapshot()` must be called in a test.");
43
- if (test.concurrent) throw new Error("`hasImageSnapshot()` cannot be called in a concurrent test because concurrent tests run at the same time in the same iframe and affect each other's environment. ");
44
- return hasImageSnapshotAction(ctx.commands, toTaskId(test), options);
45
- }
46
-
47
- //#endregion
48
- //#region src/client/page/to_match_image_snapshot.ts
49
- function toMatchImageSnapshot(options) {
50
- const test = ctx.getCurrentTest();
51
- if (!test) throw new Error("`toMatchImageSnapshot()` must be called in a test.");
52
- if (test.concurrent) throw new Error("`toMatchImageSnapshot()` cannot be called in a concurrent test because concurrent tests run at the same time in the same iframe and affect each other's environment.");
53
- return matchPageImageSnapshotAction(ctx.commands, toTaskId(test), options);
54
- }
55
-
56
- //#endregion
57
- //#region src/client/page/extend.ts
58
- page.extend({
59
- hasImageSnapshot,
60
- toMatchImageSnapshot
61
- });
62
-
63
- //#endregion
64
- //#region src/setup/create_vis.ts
65
- function createVis(commands$1) {
66
- const matcher = autoSnapshotMatcher(commands$1, expect);
67
- return {
68
- setup(options) {
69
- if (!options || options.auto === false) beforeAll(matcher.setup);
70
- else beforeAll(async () => {
71
- await matcher.setup();
72
- setAutoSnapshotOptions(true);
73
- });
74
- if (typeof options?.auto === "function") afterEach(matcher.createMatcher({ auto: options.auto }));
75
- else if (typeof options?.auto === "object") afterEach(matcher.createMatcher(options.auto));
76
- else afterEach(matcher.createMatcher({ async auto() {} }));
77
- },
78
- presets: {
79
- enable() {
80
- beforeAll(matcher.setup);
81
- afterEach(matcher.createMatcher({ async auto() {} }));
82
- },
83
- manual() {
84
- beforeAll(matcher.setup);
85
- },
86
- auto() {
87
- beforeAll(async () => {
88
- await matcher.setup();
89
- setAutoSnapshotOptions(true);
90
- });
91
- afterEach(matcher.createMatcher({ async auto() {} }));
92
- },
93
- theme(themes) {
94
- beforeAll(async () => {
95
- await matcher.setup();
96
- setAutoSnapshotOptions(true);
97
- });
98
- afterEach(matcher.createMatcher(themes));
99
- }
100
- },
101
- beforeAll: { async setup() {
102
- await matcher.setup();
103
- } },
104
- afterEach: {
105
- async matchImageSnapshot() {
106
- return matcher.createMatcher({ async auto() {} })();
107
- },
108
- matchPerTheme(themes) {
109
- return matcher.createMatcher(themes);
110
- }
111
- }
112
- };
113
- }
114
-
115
- //#endregion
116
- //#region src/setup/vis.ts
117
- /**
118
- * Visual test configuration on the client side.
119
- */
120
- const vis = createVis(commands);
121
-
122
- //#endregion
123
- export { createVis as n, vis as t };
124
- //# sourceMappingURL=setup-DCytWz48.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-DCytWz48.mjs","names":["ctx","toMatchImageSnapshot","ctx","commands"],"sources":["../src/client/expect/_ctx.ts","../src/client/expect/to_match_image_snapshot.ts","../src/client/expect/extend.ts","../src/client/page/_ctx.ts","../src/client/page/has_image_snapshot.ts","../src/client/page/to_match_image_snapshot.ts","../src/client/page/extend.ts","../src/setup/create_vis.ts","../src/setup/vis.ts"],"sourcesContent":["import { commands } from 'vitest/browser'\nimport { getCurrentTest } from '../external/vitest/vitest_suite_proxy.ts'\n\nexport const ctx = {\n\tcommands,\n\tgetCurrentTest,\n\t__test__reset() {\n\t\tctx.getCurrentTest = getCurrentTest\n\t},\n}\n","import type { AsyncExpectationResult } from '@vitest/expect'\nimport type { ToMatchImageSnapshotOptions } from '../../shared/types.ts'\nimport { matchImageSnapshotAction } from '../actions/match_image_snapshot_action.ts'\nimport { toTaskId } from '../task/task_id.ts'\nimport { ctx } from './_ctx.ts'\nimport { success } from './expectation_result.ts'\n\nexport function toMatchImageSnapshot(\n\t/**\n\t * The element or locator to take the snapshot of,\n\t * or the base64 value of the image to compare against.\n\t */\n\tsubject: any,\n\toptions?: ToMatchImageSnapshotOptions | undefined,\n): AsyncExpectationResult {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) {\n\t\tthrow new Error('`toMatchImageSnapshot()` must be called in a test.')\n\t}\n\n\tif (test.concurrent) {\n\t\tthrow new Error(\n\t\t\t'`toMatchImageSnapshot()` cannot be called in a concurrent test because ' +\n\t\t\t\t\"concurrent tests run at the same time in the same iframe and affect each other's environment.\",\n\t\t)\n\t}\n\n\treturn matchImageSnapshotAction(ctx.commands, toTaskId(test), subject, options).then(() => success)\n}\n","import { expect } from 'vitest'\nimport { toMatchImageSnapshot } from './to_match_image_snapshot.ts'\nimport './augment.ts'\n\nexpect.extend({ toMatchImageSnapshot })\n","import { type BrowserPage, commands } from 'vitest/browser'\nimport { getCurrentTest } from '../external/vitest/vitest_suite_proxy.ts'\n\nexport type { BrowserPage }\n\nexport const ctx = {\n\tcommands,\n\tgetCurrentTest,\n\t__test__reset() {\n\t\tctx.getCurrentTest = getCurrentTest\n\t},\n}\n","import type { ImageSnapshotKeyOptions } from '../../shared/types.ts'\nimport { hasImageSnapshotAction } from '../actions/has_image_snapshot_action.ts'\nimport { toTaskId } from '../task/task_id.ts'\nimport type { BrowserPage } from './_ctx.ts'\nimport { ctx } from './_ctx.ts'\n\nexport interface HasImageSnapshotAction {\n\t/**\n\t * Check if the snapshot image exists.\n\t */\n\thasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>\n}\n\nexport function hasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOptions | undefined) {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) {\n\t\tthrow new Error('`hasImageSnapshot()` must be called in a test.')\n\t}\n\n\tif (test.concurrent) {\n\t\tthrow new Error(\n\t\t\t'`hasImageSnapshot()` cannot be called in a concurrent test because ' +\n\t\t\t\t\"concurrent tests run at the same time in the same iframe and affect each other's environment. \",\n\t\t)\n\t}\n\treturn hasImageSnapshotAction(ctx.commands, toTaskId(test), options)\n}\n","import type { ComparisonMethod, ToMatchPageImageSnapshotOptions } from '../../shared/types.ts'\nimport { matchPageImageSnapshotAction } from '../actions/match_page_image_snapshot_action.ts'\nimport { toTaskId } from '../task/task_id.ts'\nimport { ctx } from './_ctx.ts'\n\nexport interface ToMatchImageSnapshotAction {\n\ttoMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(\n\t\toptions?: ToMatchPageImageSnapshotOptions<M> | undefined,\n\t): Promise<void>\n}\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(\n\toptions?: ToMatchPageImageSnapshotOptions<M> | undefined,\n) {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) {\n\t\tthrow new Error('`toMatchImageSnapshot()` must be called in a test.')\n\t}\n\n\tif (test.concurrent) {\n\t\tthrow new Error(\n\t\t\t'`toMatchImageSnapshot()` cannot be called in a concurrent test because ' +\n\t\t\t\t\"concurrent tests run at the same time in the same iframe and affect each other's environment.\",\n\t\t)\n\t}\n\n\treturn matchPageImageSnapshotAction(ctx.commands, toTaskId(test), options)\n}\n","import { page } from 'vitest/browser'\nimport './augment.ts'\nimport { hasImageSnapshot } from './has_image_snapshot.ts'\nimport { toMatchImageSnapshot } from './to_match_image_snapshot.ts'\n\npage.extend({ hasImageSnapshot, toMatchImageSnapshot })\n","import { afterEach, beforeAll, expect } from 'vitest'\nimport { autoSnapshotMatcher } from '../client/suite/auto_snapshot_matcher.ts'\nimport { setAutoSnapshotOptions } from '../client/task/auto_snapshot_options.ts'\nimport type { SnapshotMeta } from '../client/task/snapshot_meta.ts'\nimport type { SetupVisSuiteCommand } from '../shared/commands.types.ts'\nimport type { ComparisonMethod, SetupVisOptions } from '../shared/types.ts'\n\n/**\n * Visual test configuration on the client side.\n */\nexport type VisClientConfigurator<GM extends Record<string, any> | unknown = unknown> = {\n\t/**\n\t * Setup the visual test configuration.\n\t *\n\t * @example\n\t * ```ts\n\t * // Setup with auto snapshot enabled\n\t * vis().setup({ auto: true })\n\t *\n\t * // Setup with auto snapshot disabled\n\t * vis().setup({ auto: false })\n\t *\n\t * // Same as `vis.setup({ auto: false })`\n\t * vis.setup()\n\t *\n\t * // Setup with auto snapshot determined by the test meta\n\t * vis.setup({\n\t * \tauto: async ({ meta }) => meta['darkOnly'],\n\t * })\n\t *\n\t * // Setup with multiple auto snapshots\n\t * vis.setup({\n\t * auto: {\n\t * async light() { document.body.classList.remove('dark') },\n\t * async dark() { document.body.classList.add('dark') },\n\t * }\n\t * })\n\t * ```\n\t */\n\tsetup(options?: SetupVisOptions<GM>): void\n\t/**\n\t * @deprecated Use `vis.setup()` instead.\n\t */\n\tpresets: {\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable visual testing.\n\t\t *\n\t\t * auto snapshot is turned off by default.\n\t\t * You can specify the test to take a snapshot during `afterEach()` hook with `setAutoSnapshotOptions()`.\n\t\t */\n\t\tenable(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable visual testing.\n\t\t *\n\t\t * `setAutoSnapshotOptions` will have no effect in this preset.\n\t\t */\n\t\tmanual(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable automatic visual testing.\n\t\t *\n\t\t * This will take a snapshot after each test.\n\t\t */\n\t\tauto(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable automatic visual testing with multiple themes.\n\t\t *\n\t\t * This will take a snapshot after each test for each theme.\n\t\t *\n\t\t * @param themes A record of theme names and their setup functions.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * vis().presets.theme({\n\t\t * light() { document.body.classList.add('light') },\n\t\t * dark() { document.body.classList.add('dark') },\n\t\t * })\n\t\t * ```\n\t\t */\n\t\ttheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(\n\t\t\tthemes: Record<\n\t\t\t\tstring,\n\t\t\t\tboolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)\n\t\t\t>,\n\t\t): void\n\t}\n\tbeforeAll: {\n\t\tsetup(): Promise<void>\n\t}\n\tafterEach: {\n\t\tmatchImageSnapshot(): Promise<void>\n\t\tmatchPerTheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(\n\t\t\tthemes: Record<\n\t\t\t\tstring,\n\t\t\t\tboolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)\n\t\t\t>,\n\t\t): () => Promise<void>\n\t}\n}\n\nexport function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand) {\n\tconst matcher = autoSnapshotMatcher(commands, expect)\n\n\tconst vis: VisClientConfigurator<GM> = {\n\t\tsetup(options) {\n\t\t\tif (!options || options.auto === false) {\n\t\t\t\tbeforeAll(matcher.setup)\n\t\t\t} else {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait matcher.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (typeof options?.auto === 'function') {\n\t\t\t\tafterEach(\n\t\t\t\t\tmatcher.createMatcher({\n\t\t\t\t\t\tauto: options.auto,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t} else if (typeof options?.auto === 'object') {\n\t\t\t\tafterEach(matcher.createMatcher(options.auto))\n\t\t\t} else {\n\t\t\t\tafterEach(matcher.createMatcher({ async auto() {} }))\n\t\t\t}\n\t\t},\n\t\tpresets: {\n\t\t\tenable() {\n\t\t\t\tbeforeAll(matcher.setup)\n\t\t\t\tafterEach(matcher.createMatcher({ async auto() {} }))\n\t\t\t},\n\t\t\tmanual() {\n\t\t\t\tbeforeAll(matcher.setup)\n\t\t\t},\n\t\t\tauto() {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait matcher.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t\tafterEach(matcher.createMatcher({ async auto() {} }))\n\t\t\t},\n\t\t\ttheme(themes) {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait matcher.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t\tafterEach(matcher.createMatcher(themes))\n\t\t\t},\n\t\t},\n\t\tbeforeAll: {\n\t\t\tasync setup() {\n\t\t\t\tawait matcher.setup()\n\t\t\t},\n\t\t},\n\t\tafterEach: {\n\t\t\tasync matchImageSnapshot() {\n\t\t\t\treturn matcher.createMatcher({ async auto() {} })()\n\t\t\t},\n\t\t\tmatchPerTheme(themes) {\n\t\t\t\treturn matcher.createMatcher(themes)\n\t\t\t},\n\t\t},\n\t}\n\treturn vis\n}\n","import { commands } from 'vitest/browser'\nimport { createVis } from './create_vis.ts'\n\n/**\n * Visual test configuration on the client side.\n */\nexport const vis = createVis(commands)\n"],"mappings":";;;;;;AAGA,MAAaA,QAAM;CAClB;CACA;CACA,gBAAgB;AACf,QAAI,iBAAiB;;CAEtB;;;;ACFD,SAAgBC,uBAKf,SACA,SACyB;CACzB,MAAM,OAAOC,MAAI,gBAAgB;AACjC,KAAI,CAAC,KACJ,OAAM,IAAI,MAAM,qDAAqD;AAGtE,KAAI,KAAK,WACR,OAAM,IAAI,MACT,uKAEA;AAGF,QAAO,yBAAyBA,MAAI,UAAU,SAAS,KAAK,EAAE,SAAS,QAAQ,CAAC,WAAW,QAAQ;;;;;ACvBpG,OAAO,OAAO,EAAE,8CAAsB,CAAC;;;;ACCvC,MAAa,MAAM;CAClB;CACA;CACA,gBAAgB;AACf,MAAI,iBAAiB;;CAEtB;;;;ACED,SAAgB,iBAAoC,SAA+C;CAClG,MAAM,OAAO,IAAI,gBAAgB;AACjC,KAAI,CAAC,KACJ,OAAM,IAAI,MAAM,iDAAiD;AAGlE,KAAI,KAAK,WACR,OAAM,IAAI,MACT,oKAEA;AAEF,QAAO,uBAAuB,IAAI,UAAU,SAAS,KAAK,EAAE,QAAQ;;;;;ACdrE,SAAgB,qBACf,SACC;CACD,MAAM,OAAO,IAAI,gBAAgB;AACjC,KAAI,CAAC,KACJ,OAAM,IAAI,MAAM,qDAAqD;AAGtE,KAAI,KAAK,WACR,OAAM,IAAI,MACT,uKAEA;AAGF,QAAO,6BAA6B,IAAI,UAAU,SAAS,KAAK,EAAE,QAAQ;;;;;ACrB3E,KAAK,OAAO;CAAE;CAAkB;CAAsB,CAAC;;;;ACsGvD,SAAgB,UAA8D,YAAgC;CAC7G,MAAM,UAAU,oBAAoBC,YAAU,OAAO;AA8DrD,QA5DuC;EACtC,MAAM,SAAS;AACd,OAAI,CAAC,WAAW,QAAQ,SAAS,MAChC,WAAU,QAAQ,MAAM;OAExB,WAAU,YAAY;AACrB,UAAM,QAAQ,OAAO;AACrB,2BAAuB,KAAK;KAC3B;AAGH,OAAI,OAAO,SAAS,SAAS,WAC5B,WACC,QAAQ,cAAc,EACrB,MAAM,QAAQ,MACd,CAAC,CACF;YACS,OAAO,SAAS,SAAS,SACnC,WAAU,QAAQ,cAAc,QAAQ,KAAK,CAAC;OAE9C,WAAU,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,CAAC,CAAC;;EAGvD,SAAS;GACR,SAAS;AACR,cAAU,QAAQ,MAAM;AACxB,cAAU,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,CAAC,CAAC;;GAEtD,SAAS;AACR,cAAU,QAAQ,MAAM;;GAEzB,OAAO;AACN,cAAU,YAAY;AACrB,WAAM,QAAQ,OAAO;AACrB,4BAAuB,KAAK;MAC3B;AACF,cAAU,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,CAAC,CAAC;;GAEtD,MAAM,QAAQ;AACb,cAAU,YAAY;AACrB,WAAM,QAAQ,OAAO;AACrB,4BAAuB,KAAK;MAC3B;AACF,cAAU,QAAQ,cAAc,OAAO,CAAC;;GAEzC;EACD,WAAW,EACV,MAAM,QAAQ;AACb,SAAM,QAAQ,OAAO;KAEtB;EACD,WAAW;GACV,MAAM,qBAAqB;AAC1B,WAAO,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,CAAC,EAAE;;GAEpD,cAAc,QAAQ;AACrB,WAAO,QAAQ,cAAc,OAAO;;GAErC;EACD;;;;;;;;ACnKF,MAAa,MAAM,UAAU,SAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot_path-7GliOSH_.mjs","names":[],"sources":["../src/shared/trim_common_folder.ts","../src/server/snapshot_path.ts"],"sourcesContent":["/**\n * Trim off common folder such as `src` or `tests` from the test file path.\n * This is used to generate the default snapshot sub-path.\n */\nexport function trimCommonFolder(suiteName: string) {\n\tsuiteName = suiteName.replaceAll('..', '__')\n\tconst suiteDir = suiteName.split('/', 1)[0]!\n\tif (['tests', 'test', 'src', 'source', 'js', 'ts', 'lib'].includes(suiteDir))\n\t\treturn suiteName.slice(suiteDir.length + 1)\n\treturn suiteName\n}\n","import ci from 'is-ci'\nimport { platform } from 'node:process'\nimport type { VisOptions } from '../config/types.ts'\nimport { SNAPSHOT_ROOT_DIR } from '../shared/constants.ts'\nimport { trimCommonFolder } from '../shared/trim_common_folder.ts'\nimport type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'\n\nexport function resolveSnapshotRootDir(browserCommandContext: ExtendedBrowserCommandContext, options: VisOptions) {\n\tif (!options.snapshotRootDir) return getSnapshotRootDir(SNAPSHOT_ROOT_DIR)\n\tconst snapshotRootDir = options.snapshotRootDir\n\tif (typeof snapshotRootDir === 'string') return getSnapshotRootDir(snapshotRootDir)\n\tconst { config } = browserCommandContext.project.browser\n\treturn snapshotRootDir({\n\t\tci,\n\t\tbrowserName: config.browser.name,\n\t\tproviderName: browserCommandContext.provider.name,\n\t\tplatform,\n\t\tscreenshotFailures: config.browser.screenshotFailures,\n\t\tscreenshotDirectory: config.browser.screenshotDirectory,\n\t})\n}\n\n/**\n * Gets the root directory for storing snapshots.\n *\n * @param snapshotRootDir - Base directory for snapshots. Defaults to `__vis__`.\n * @returns The full snapshot root directory path, which includes a platform-specific subdirectory:\n * - When running in CI: `<snapshotRootDir>/<platform>` (e.g. `__vis__/linux`)\n * - When running locally: `<snapshotRootDir>/local`\n */\nexport function getSnapshotRootDir(snapshotRootDir = SNAPSHOT_ROOT_DIR) {\n\treturn `${snapshotRootDir}/${ci ? platform : 'local'}`\n}\n\nexport function getSnapshotSubpath(suiteName: string, options: Pick<VisOptions, 'snapshotSubpath'>) {\n\tconst snapshotSubpath = options.snapshotSubpath ?? (({ subpath }) => trimCommonFolder(subpath))\n\treturn snapshotSubpath({ subpath: suiteName })\n}\n"],"mappings":";;;;;;;;;AAIA,SAAgB,iBAAiB,WAAmB;AACnD,aAAY,UAAU,WAAW,MAAM,KAAK;CAC5C,MAAM,WAAW,UAAU,MAAM,KAAK,EAAE,CAAC;AACzC,KAAI;EAAC;EAAS;EAAQ;EAAO;EAAU;EAAM;EAAM;EAAM,CAAC,SAAS,SAAS,CAC3E,QAAO,UAAU,MAAM,SAAS,SAAS,EAAE;AAC5C,QAAO;;;;;ACFR,SAAgB,uBAAuB,uBAAsD,SAAqB;AACjH,KAAI,CAAC,QAAQ,gBAAiB,QAAO,mBAAmB,kBAAkB;CAC1E,MAAM,kBAAkB,QAAQ;AAChC,KAAI,OAAO,oBAAoB,SAAU,QAAO,mBAAmB,gBAAgB;CACnF,MAAM,EAAE,WAAW,sBAAsB,QAAQ;AACjD,QAAO,gBAAgB;EACtB;EACA,aAAa,OAAO,QAAQ;EAC5B,cAAc,sBAAsB,SAAS;EAC7C;EACA,oBAAoB,OAAO,QAAQ;EACnC,qBAAqB,OAAO,QAAQ;EACpC,CAAC;;;;;;;;;;AAWH,SAAgB,mBAAmB,kBAAkB,mBAAmB;AACvE,QAAO,GAAG,gBAAgB,GAAG,KAAK,WAAW;;AAG9C,SAAgB,mBAAmB,WAAmB,SAA8C;AAEnG,SADwB,QAAQ,qBAAqB,EAAE,cAAc,iBAAiB,QAAQ,GACvE,EAAE,SAAS,WAAW,CAAC"}
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing.d.mts","names":[],"sources":["../src/testing/constants.ts"],"sourcesContent":[],"mappings":";cAAa,cAAA;AAAA,cAGA,WAAA,GAHc,wrGAAA;AAGd,cAEA,cAFW,EAAA;EAEX,KAAA,EAAA,MAAA;EAGU,MAAA,EAAA,MAAA;cAAA"}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"trim_common_folder-DBThLerp.d.mts","names":[],"sources":["../src/shared/trim_common_folder.ts"],"sourcesContent":[],"mappings":";;AAIA;;;iBAAgB,gBAAA"}
@@ -1 +0,0 @@
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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AGc,4BAA4B,kDAC/B,aAAa,KAAK,IAAI,OAC1B,mBAAmB"}
@@ -1 +0,0 @@
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"}
@@ -1,76 +0,0 @@
1
- import { Meta, Source } from "@storybook/addon-docs/blocks";
2
-
3
- <Meta title="vitest-plugin-vis/config/vis" />
4
-
5
- `vis` from `vitest-plugin-vis/config` is the Vitest plugin of `vitest-plugin-vis`.
6
-
7
- ```ts
8
- // vitest.config.ts
9
- import { vis } from 'vitest-plugin-vis/config'
10
-
11
- export default defineConfig({
12
- plugins: [vis()],
13
- })
14
- ```
15
-
16
- It provides a lot of options to customize the behavior of the plugin.
17
- (You can learn more about the default configuration [here](/docs/overview--docs#basic-configuration).)
18
-
19
- ## Preset
20
-
21
- The `preset` option set up typical visual testing strategies.
22
-
23
- ### `auto`
24
-
25
- The `auto` preset is the default preset.
26
- It will take a snapshot of the page at the end of each rendering test.
27
-
28
- ```ts
29
- // vitest.config.ts
30
- import { vis } from 'vitest-plugin-vis/config'
31
-
32
- export default defineConfig({
33
- plugins: [vis({ preset: 'auto' })],
34
- })
35
- ```
36
-
37
- ### `manual`
38
-
39
- The `manual` preset is for manual testing.
40
- It will not take any snapshot automatically.
41
-
42
- ```ts
43
- // vitest.config.ts
44
- import { vis } from 'vitest-plugin-vis/config'
45
-
46
- export default defineConfig({
47
- plugins: [vis({ preset: 'manual' })],
48
- })
49
- ```
50
-
51
- See [Manual Snapshot](/docs/expect-tomatchimagesnapshot--docs) section on how to take an image snapshot manually.
52
-
53
- ### `custom`
54
-
55
- The `custom` preset is for advanced users.
56
- It will not take any snapshot automatically.
57
- You need to set up your own visual testing strategy in `vitest.setup.ts`.
58
-
59
- ```ts
60
- // vitest.config.ts
61
- import { vis } from 'vitest-plugin-vis/config'
62
-
63
- export default defineConfig({
64
- plugins: [vis({ preset: 'custom' })],
65
- test: {
66
- // Set up your own visual testing strategy in `vitest.setup.ts`.
67
- setupFiles: ['./vitest.setup.ts'],
68
- }
69
- })
70
- ```
71
-
72
- When using the `custom` preset, you can set up your own visual testing strategy in `vitest.setup.ts` using the [vis](/docs/vitest-plugin-vis-setup-vis--docs) object from `vitest-plugin-vis/setup`.
73
-
74
- [vitest-plugin-vis]: https://npmjs.org/package/vitest-plugin-vis
75
-
76
-