vitest-plugin-vis 3.5.0 → 4.0.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 (343) hide show
  1. package/dist/asserts--HSSlgPD.mjs +8 -0
  2. package/dist/asserts--HSSlgPD.mjs.map +1 -0
  3. package/dist/augment-BJmy1S7i.d.mts +31 -0
  4. package/dist/augment-BJmy1S7i.d.mts.map +1 -0
  5. package/dist/auto_snapshot_options-CAD43Zkp.mjs +90 -0
  6. package/dist/auto_snapshot_options-CAD43Zkp.mjs.map +1 -0
  7. package/dist/auto_snapshot_options-CaQCXDdi.d.mts +45 -0
  8. package/dist/auto_snapshot_options-CaQCXDdi.d.mts.map +1 -0
  9. package/dist/base64-CHSENEAO.mjs +8 -0
  10. package/dist/base64-CHSENEAO.mjs.map +1 -0
  11. package/dist/client-api.d.mts +141 -0
  12. package/dist/client-api.d.mts.map +1 -0
  13. package/dist/client-api.mjs +14 -0
  14. package/dist/client-api.mjs.map +1 -0
  15. package/dist/config.d.mts +28 -0
  16. package/dist/config.d.mts.map +1 -0
  17. package/dist/config.mjs +412 -0
  18. package/dist/config.mjs.map +1 -0
  19. package/dist/constants-CTBaz8Ml.mjs +10 -0
  20. package/dist/constants-CTBaz8Ml.mjs.map +1 -0
  21. package/dist/index.d.mts +5 -0
  22. package/dist/index.mjs +6 -0
  23. package/dist/presets/auto.d.mts +1 -0
  24. package/dist/presets/auto.mjs +19 -0
  25. package/dist/presets/auto.mjs.map +1 -0
  26. package/dist/presets/enable.d.mts +1 -0
  27. package/dist/presets/enable.mjs +15 -0
  28. package/dist/presets/enable.mjs.map +1 -0
  29. package/dist/presets/manual.d.mts +1 -0
  30. package/dist/presets/manual.mjs +15 -0
  31. package/dist/presets/manual.mjs.map +1 -0
  32. package/dist/server-utils.d.mts +19 -0
  33. package/dist/server-utils.d.mts.map +1 -0
  34. package/dist/server-utils.mjs +4 -0
  35. package/dist/setup-BWgIDtv-.mjs +141 -0
  36. package/dist/setup-BWgIDtv-.mjs.map +1 -0
  37. package/dist/setup.d.mts +110 -0
  38. package/dist/setup.d.mts.map +1 -0
  39. package/dist/setup.mjs +8 -0
  40. package/dist/setup_vis_suite-C6JGGT7B.d.mts +17 -0
  41. package/dist/setup_vis_suite-C6JGGT7B.d.mts.map +1 -0
  42. package/dist/snapshot_path-7GliOSH_.mjs +58 -0
  43. package/dist/snapshot_path-7GliOSH_.mjs.map +1 -0
  44. package/dist/src-CSQnlFa9.mjs +1 -0
  45. package/dist/task_id-DnS9_4Ub.mjs +316 -0
  46. package/dist/task_id-DnS9_4Ub.mjs.map +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-p-zilA_M.d.mts +9 -0
  52. package/dist/to_match_image_snapshot.types-p-zilA_M.d.mts.map +1 -0
  53. package/dist/trim_common_folder-ModiubEJ.d.mts +9 -0
  54. package/dist/trim_common_folder-ModiubEJ.d.mts.map +1 -0
  55. package/dist/types-DFb23VE1.d.mts +110 -0
  56. package/dist/types-DFb23VE1.d.mts.map +1 -0
  57. package/dist/types-Do1N7g4c.d.mts +63 -0
  58. package/dist/types-Do1N7g4c.d.mts.map +1 -0
  59. package/dist/vis_server_context.types-Ce1f9vOO.d.mts +1 -0
  60. package/package.json +60 -44
  61. package/readme.md +58 -6
  62. package/src/client/actions/match_image_snapshot_action.ts +1 -1
  63. package/src/client/actions/match_page_image_snapshot_action.ts +1 -1
  64. package/src/client/auto_snapshot_options.ts +16 -1
  65. package/src/client/compare_image_snapshot.ts +1 -1
  66. package/src/client/expect/to_match_image_snapshot.ts +1 -1
  67. package/src/client/page/extend.ts +1 -1
  68. package/src/client/page/has_image_snapshot.mdx +1 -1
  69. package/src/client/page/has_image_snapshot.ts +1 -1
  70. package/src/client/page/to_match_image_snapshot.mdx +1 -1
  71. package/src/client/page/to_match_image_snapshot.ts +1 -1
  72. package/src/client/setup/create_vis.ts +16 -14
  73. package/src/client/setup/vis.ctx.ts +4 -3
  74. package/src/client/setup/vis.ts +1 -1
  75. package/src/client/snapshot_meta.ts +5 -0
  76. package/src/client/vitest_browser_context_proxy.ts +3 -3
  77. package/src/config/vis.ts +4 -4
  78. package/src/server/browser_provider/browser_api.ts +2 -2
  79. package/src/server/browser_provider/playwright.ts +6 -4
  80. package/src/server/browser_provider/webdriverio.ts +3 -3
  81. package/src/server/commands/_assertions.ts +3 -3
  82. package/src/server/commands/augment.ts +1 -1
  83. package/src/server/commands/has_image_snapshot.ts +2 -2
  84. package/src/server/commands/image_snapshot_next_index.ts +2 -2
  85. package/src/server/commands/load_image_snapshot_results.ts +2 -3
  86. package/src/server/commands/prepare_image_snapshot_comparison.ts +2 -2
  87. package/src/server/commands/prepare_page_image_snapshot_comparison.ts +2 -2
  88. package/src/server/commands/setup_vis_suite.ts +3 -3
  89. package/src/server/project.ts +8 -7
  90. package/src/server/snapshot.ts +4 -4
  91. package/src/server/snapshot_path.ts +6 -5
  92. package/src/server/suite.ts +7 -12
  93. package/src/server/testing/stubBrowserCommandContext.ts +16 -0
  94. package/src/{testing → server/testing}/stubSuite.ts +7 -9
  95. package/src/server/testing/stubUserConfig.ts +6 -0
  96. package/src/server/vis_options.ts +4 -5
  97. package/src/server/vis_server_context.logic.ts +7 -7
  98. package/src/server/vis_server_context.types.ts +31 -26
  99. package/src/shared/trim_common_folder.ts +1 -0
  100. package/src/shared/types.ts +2 -0
  101. package/src/testing.ts +0 -1
  102. package/esm/client/actions/has_image_snapshot_action.d.ts +0 -4
  103. package/esm/client/actions/has_image_snapshot_action.d.ts.map +0 -1
  104. package/esm/client/actions/has_image_snapshot_action.js +0 -6
  105. package/esm/client/actions/load_image_snapshot_results_action.d.ts +0 -3
  106. package/esm/client/actions/load_image_snapshot_results_action.d.ts.map +0 -1
  107. package/esm/client/actions/load_image_snapshot_results_action.js +0 -3
  108. package/esm/client/actions/match_image_snapshot_action.d.ts +0 -6
  109. package/esm/client/actions/match_image_snapshot_action.d.ts.map +0 -1
  110. package/esm/client/actions/match_image_snapshot_action.js +0 -20
  111. package/esm/client/actions/match_page_image_snapshot_action.d.ts +0 -6
  112. package/esm/client/actions/match_page_image_snapshot_action.d.ts.map +0 -1
  113. package/esm/client/actions/match_page_image_snapshot_action.js +0 -9
  114. package/esm/client/align_images.d.ts +0 -2
  115. package/esm/client/align_images.d.ts.map +0 -1
  116. package/esm/client/align_images.js +0 -10
  117. package/esm/client/auto_snapshot_options.d.ts +0 -29
  118. package/esm/client/auto_snapshot_options.d.ts.map +0 -1
  119. package/esm/client/auto_snapshot_options.js +0 -49
  120. package/esm/client/compare_image_snapshot.d.ts +0 -6
  121. package/esm/client/compare_image_snapshot.d.ts.map +0 -1
  122. package/esm/client/compare_image_snapshot.js +0 -52
  123. package/esm/client/compare_image_snapshot.logic.d.ts +0 -3
  124. package/esm/client/compare_image_snapshot.logic.d.ts.map +0 -1
  125. package/esm/client/compare_image_snapshot.logic.js +0 -12
  126. package/esm/client/ctx.d.ts +0 -7
  127. package/esm/client/ctx.d.ts.map +0 -1
  128. package/esm/client/ctx.js +0 -11
  129. package/esm/client/expect/augment.d.ts +0 -8
  130. package/esm/client/expect/augment.d.ts.map +0 -1
  131. package/esm/client/expect/augment.js +0 -1
  132. package/esm/client/expect/expectation_result.d.ts +0 -3
  133. package/esm/client/expect/expectation_result.d.ts.map +0 -1
  134. package/esm/client/expect/expectation_result.js +0 -5
  135. package/esm/client/expect/extend.d.ts +0 -2
  136. package/esm/client/expect/extend.d.ts.map +0 -1
  137. package/esm/client/expect/extend.js +0 -4
  138. package/esm/client/expect/to_match_image_snapshot.d.ts +0 -9
  139. package/esm/client/expect/to_match_image_snapshot.d.ts.map +0 -1
  140. package/esm/client/expect/to_match_image_snapshot.js +0 -21
  141. package/esm/client/expect/to_match_image_snapshot.types.d.ts +0 -5
  142. package/esm/client/expect/to_match_image_snapshot.types.d.ts.map +0 -1
  143. package/esm/client/expect/to_match_image_snapshot.types.js +0 -1
  144. package/esm/client/image_data.d.ts +0 -3
  145. package/esm/client/image_data.d.ts.map +0 -1
  146. package/esm/client/image_data.js +0 -33
  147. package/esm/client/image_resizer.d.ts +0 -9
  148. package/esm/client/image_resizer.d.ts.map +0 -1
  149. package/esm/client/image_resizer.js +0 -49
  150. package/esm/client/image_snapshot_options.d.ts +0 -2
  151. package/esm/client/image_snapshot_options.d.ts.map +0 -1
  152. package/esm/client/image_snapshot_options.js +0 -6
  153. package/esm/client/page/augment.d.ts +0 -7
  154. package/esm/client/page/augment.d.ts.map +0 -1
  155. package/esm/client/page/augment.js +0 -1
  156. package/esm/client/page/extend.d.ts +0 -2
  157. package/esm/client/page/extend.d.ts.map +0 -1
  158. package/esm/client/page/extend.js +0 -5
  159. package/esm/client/page/has_image_snapshot.d.ts +0 -10
  160. package/esm/client/page/has_image_snapshot.d.ts.map +0 -1
  161. package/esm/client/page/has_image_snapshot.js +0 -15
  162. package/esm/client/page/to_match_image_snapshot.d.ts +0 -6
  163. package/esm/client/page/to_match_image_snapshot.d.ts.map +0 -1
  164. package/esm/client/page/to_match_image_snapshot.js +0 -15
  165. package/esm/client/selector.d.ts +0 -7
  166. package/esm/client/selector.d.ts.map +0 -1
  167. package/esm/client/selector.js +0 -97
  168. package/esm/client/setup/create_vis.d.ts +0 -96
  169. package/esm/client/setup/create_vis.d.ts.map +0 -1
  170. package/esm/client/setup/create_vis.js +0 -109
  171. package/esm/client/setup/vis.ctx.d.ts +0 -12
  172. package/esm/client/setup/vis.ctx.d.ts.map +0 -1
  173. package/esm/client/setup/vis.ctx.js +0 -32
  174. package/esm/client/setup/vis.d.ts +0 -5
  175. package/esm/client/setup/vis.d.ts.map +0 -1
  176. package/esm/client/setup/vis.js +0 -6
  177. package/esm/client/should_take_snapshot.d.ts +0 -3
  178. package/esm/client/should_take_snapshot.d.ts.map +0 -1
  179. package/esm/client/should_take_snapshot.js +0 -3
  180. package/esm/client/snapshot_meta.d.ts +0 -6
  181. package/esm/client/snapshot_meta.d.ts.map +0 -1
  182. package/esm/client/snapshot_meta.js +0 -1
  183. package/esm/client/task_id.d.ts +0 -7
  184. package/esm/client/task_id.d.ts.map +0 -1
  185. package/esm/client/task_id.js +0 -10
  186. package/esm/client/vitest_browser_context_proxy.d.ts +0 -32
  187. package/esm/client/vitest_browser_context_proxy.d.ts.map +0 -1
  188. package/esm/client/vitest_browser_context_proxy.js +0 -11
  189. package/esm/client/vitest_suite_proxy.d.ts +0 -7
  190. package/esm/client/vitest_suite_proxy.d.ts.map +0 -1
  191. package/esm/client/vitest_suite_proxy.js +0 -8
  192. package/esm/client-api.d.ts +0 -12
  193. package/esm/client-api.d.ts.map +0 -1
  194. package/esm/client-api.js +0 -9
  195. package/esm/commands.d.ts +0 -5
  196. package/esm/commands.d.ts.map +0 -1
  197. package/esm/commands.js +0 -4
  198. package/esm/config/types.d.ts +0 -60
  199. package/esm/config/types.d.ts.map +0 -1
  200. package/esm/config/types.js +0 -1
  201. package/esm/config/vis.d.ts +0 -28
  202. package/esm/config/vis.d.ts.map +0 -1
  203. package/esm/config/vis.js +0 -27
  204. package/esm/config.d.ts +0 -4
  205. package/esm/config.d.ts.map +0 -1
  206. package/esm/config.js +0 -2
  207. package/esm/index.d.ts +0 -5
  208. package/esm/index.d.ts.map +0 -1
  209. package/esm/index.js +0 -4
  210. package/esm/presets/auto.d.ts +0 -2
  211. package/esm/presets/auto.d.ts.map +0 -1
  212. package/esm/presets/auto.js +0 -8
  213. package/esm/presets/enable.d.ts +0 -2
  214. package/esm/presets/enable.d.ts.map +0 -1
  215. package/esm/presets/enable.js +0 -4
  216. package/esm/presets/manual.d.ts +0 -2
  217. package/esm/presets/manual.d.ts.map +0 -1
  218. package/esm/presets/manual.js +0 -4
  219. package/esm/server/browser_provider/browser_api.d.ts +0 -3
  220. package/esm/server/browser_provider/browser_api.d.ts.map +0 -1
  221. package/esm/server/browser_provider/browser_api.js +0 -11
  222. package/esm/server/browser_provider/playwright.d.ts +0 -4
  223. package/esm/server/browser_provider/playwright.d.ts.map +0 -1
  224. package/esm/server/browser_provider/playwright.js +0 -18
  225. package/esm/server/browser_provider/types.d.ts +0 -10
  226. package/esm/server/browser_provider/types.d.ts.map +0 -1
  227. package/esm/server/browser_provider/types.js +0 -1
  228. package/esm/server/browser_provider/webdriverio.d.ts +0 -4
  229. package/esm/server/browser_provider/webdriverio.d.ts.map +0 -1
  230. package/esm/server/browser_provider/webdriverio.js +0 -12
  231. package/esm/server/commands/_assertions.d.ts +0 -5
  232. package/esm/server/commands/_assertions.d.ts.map +0 -1
  233. package/esm/server/commands/_assertions.js +0 -11
  234. package/esm/server/commands/augment.d.ts +0 -11
  235. package/esm/server/commands/augment.d.ts.map +0 -1
  236. package/esm/server/commands/augment.js +0 -1
  237. package/esm/server/commands/commands.d.ts +0 -9
  238. package/esm/server/commands/commands.d.ts.map +0 -1
  239. package/esm/server/commands/commands.js +0 -14
  240. package/esm/server/commands/has_image_snapshot.d.ts +0 -6
  241. package/esm/server/commands/has_image_snapshot.d.ts.map +0 -1
  242. package/esm/server/commands/has_image_snapshot.js +0 -6
  243. package/esm/server/commands/image_snapshot_next_index.d.ts +0 -9
  244. package/esm/server/commands/image_snapshot_next_index.d.ts.map +0 -1
  245. package/esm/server/commands/image_snapshot_next_index.js +0 -6
  246. package/esm/server/commands/load_image_snapshot_results.d.ts +0 -21
  247. package/esm/server/commands/load_image_snapshot_results.d.ts.map +0 -1
  248. package/esm/server/commands/load_image_snapshot_results.js +0 -6
  249. package/esm/server/commands/prepare_image_snapshot_comparison.d.ts +0 -38
  250. package/esm/server/commands/prepare_image_snapshot_comparison.d.ts.map +0 -1
  251. package/esm/server/commands/prepare_image_snapshot_comparison.js +0 -34
  252. package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts +0 -35
  253. package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts.map +0 -1
  254. package/esm/server/commands/prepare_page_image_snapshot_comparison.js +0 -27
  255. package/esm/server/commands/setup_vis_suite.d.ts +0 -15
  256. package/esm/server/commands/setup_vis_suite.d.ts.map +0 -1
  257. package/esm/server/commands/setup_vis_suite.js +0 -6
  258. package/esm/server/commands/types.d.ts +0 -3
  259. package/esm/server/commands/types.d.ts.map +0 -1
  260. package/esm/server/commands/types.js +0 -1
  261. package/esm/server/externals/file.d.ts +0 -10
  262. package/esm/server/externals/file.d.ts.map +0 -1
  263. package/esm/server/externals/file.js +0 -20
  264. package/esm/server/project.d.ts +0 -21
  265. package/esm/server/project.d.ts.map +0 -1
  266. package/esm/server/project.js +0 -13
  267. package/esm/server/snapshot.d.ts +0 -6
  268. package/esm/server/snapshot.d.ts.map +0 -1
  269. package/esm/server/snapshot.js +0 -29
  270. package/esm/server/snapshot_path.d.ts +0 -14
  271. package/esm/server/snapshot_path.d.ts.map +0 -1
  272. package/esm/server/snapshot_path.js +0 -34
  273. package/esm/server/snapshot_writer.d.ts +0 -13
  274. package/esm/server/snapshot_writer.d.ts.map +0 -1
  275. package/esm/server/snapshot_writer.js +0 -15
  276. package/esm/server/suite.d.ts +0 -54
  277. package/esm/server/suite.d.ts.map +0 -1
  278. package/esm/server/suite.js +0 -73
  279. package/esm/server/vis_options.d.ts +0 -19
  280. package/esm/server/vis_options.d.ts.map +0 -1
  281. package/esm/server/vis_options.js +0 -14
  282. package/esm/server/vis_server_context.d.ts +0 -50
  283. package/esm/server/vis_server_context.d.ts.map +0 -1
  284. package/esm/server/vis_server_context.deps.d.ts +0 -29
  285. package/esm/server/vis_server_context.deps.d.ts.map +0 -1
  286. package/esm/server/vis_server_context.deps.js +0 -10
  287. package/esm/server/vis_server_context.js +0 -2
  288. package/esm/server/vis_server_context.logic.d.ts +0 -53
  289. package/esm/server/vis_server_context.logic.d.ts.map +0 -1
  290. package/esm/server/vis_server_context.logic.js +0 -79
  291. package/esm/server/vis_server_context.types.d.ts +0 -54
  292. package/esm/server/vis_server_context.types.d.ts.map +0 -1
  293. package/esm/server/vis_server_context.types.js +0 -1
  294. package/esm/server-utils.d.ts +0 -4
  295. package/esm/server-utils.d.ts.map +0 -1
  296. package/esm/server-utils.js +0 -3
  297. package/esm/setup.d.ts +0 -5
  298. package/esm/setup.d.ts.map +0 -1
  299. package/esm/setup.js +0 -5
  300. package/esm/shared/asserts.d.ts +0 -2
  301. package/esm/shared/asserts.d.ts.map +0 -1
  302. package/esm/shared/asserts.js +0 -5
  303. package/esm/shared/base64.d.ts +0 -2
  304. package/esm/shared/base64.d.ts.map +0 -1
  305. package/esm/shared/base64.js +0 -3
  306. package/esm/shared/compare_image.d.ts +0 -6
  307. package/esm/shared/compare_image.d.ts.map +0 -1
  308. package/esm/shared/compare_image.js +0 -42
  309. package/esm/shared/constants.d.ts +0 -6
  310. package/esm/shared/constants.d.ts.map +0 -1
  311. package/esm/shared/constants.js +0 -5
  312. package/esm/shared/convert_threshold_unit.d.ts +0 -6
  313. package/esm/shared/convert_threshold_unit.d.ts.map +0 -1
  314. package/esm/shared/convert_threshold_unit.js +0 -10
  315. package/esm/shared/get_max_size.d.ts +0 -11
  316. package/esm/shared/get_max_size.d.ts.map +0 -1
  317. package/esm/shared/get_max_size.js +0 -5
  318. package/esm/shared/is_same_size.d.ts +0 -8
  319. package/esm/shared/is_same_size.d.ts.map +0 -1
  320. package/esm/shared/is_same_size.js +0 -3
  321. package/esm/shared/trim_common_folder.d.ts +0 -6
  322. package/esm/shared/trim_common_folder.d.ts.map +0 -1
  323. package/esm/shared/trim_common_folder.js +0 -10
  324. package/esm/shared/types.d.ts +0 -90
  325. package/esm/shared/types.d.ts.map +0 -1
  326. package/esm/shared/types.js +0 -1
  327. package/esm/testing/constants.d.ts +0 -9
  328. package/esm/testing/constants.d.ts.map +0 -1
  329. package/esm/testing/constants.js +0 -1933
  330. package/esm/testing/stubBrowserCommandContext.d.ts +0 -8
  331. package/esm/testing/stubBrowserCommandContext.d.ts.map +0 -1
  332. package/esm/testing/stubBrowserCommandContext.js +0 -12
  333. package/esm/testing/stubSuite.d.ts +0 -10
  334. package/esm/testing/stubSuite.d.ts.map +0 -1
  335. package/esm/testing/stubSuite.js +0 -27
  336. package/esm/testing/stubUserConfig.d.ts +0 -7
  337. package/esm/testing/stubUserConfig.d.ts.map +0 -1
  338. package/esm/testing/stubUserConfig.js +0 -4
  339. package/esm/testing.d.ts +0 -3
  340. package/esm/testing.d.ts.map +0 -1
  341. package/esm/testing.js +0 -2
  342. package/src/testing/stubBrowserCommandContext.ts +0 -16
  343. package/src/testing/stubUserConfig.ts +0 -6
@@ -3,6 +3,8 @@ import type { Options as SsimDiffOptions } from 'ssim.js'
3
3
  import type { SnapshotMeta } from '../client/snapshot_meta.ts'
4
4
  import type { NAME } from './constants.ts'
5
5
 
6
+ export type Awaitable<T> = T | PromiseLike<T>
7
+
6
8
  export interface ImageSnapshotTimeoutOptions {
7
9
  /**
8
10
  * Timeout for taking the snapshot.
package/src/testing.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from './testing/constants.ts'
2
- export * from './testing/stubBrowserCommandContext.ts'
@@ -1,4 +0,0 @@
1
- import type { HasImageSnapshotCommand, ImageSnapshotNextIndexCommand } from '../../commands.ts';
2
- import type { ImageSnapshotKeyOptions } from '../../shared/types.ts';
3
- export declare function hasImageSnapshotAction(commands: ImageSnapshotNextIndexCommand & HasImageSnapshotCommand, taskId: string, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>;
4
- //# sourceMappingURL=has_image_snapshot_action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"has_image_snapshot_action.d.ts","sourceRoot":"","sources":["../../../src/client/actions/has_image_snapshot_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEpE,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,6BAA6B,GAAG,uBAAuB,EACjE,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,uBAAuB,GAAG,SAAS,oBAO7C"}
@@ -1,6 +0,0 @@
1
- export function hasImageSnapshotAction(commands, taskId, options) {
2
- if (options?.snapshotKey?.includes('-')) {
3
- throw new Error('Snapshot key cannot contain dash');
4
- }
5
- return commands.hasImageSnapshot(taskId, options?.snapshotKey);
6
- }
@@ -1,3 +0,0 @@
1
- import type { LoadImageSnapshotResultsCommand } from '../../server/commands/load_image_snapshot_results.ts';
2
- export declare function loadImageSnapshotResultsAction(commands: LoadImageSnapshotResultsCommand, taskId: string): Promise<import("../../server/commands/load_image_snapshot_results.ts").ImageSnapshotResult[]>;
3
- //# sourceMappingURL=load_image_snapshot_results_action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"load_image_snapshot_results_action.d.ts","sourceRoot":"","sources":["../../../src/client/actions/load_image_snapshot_results_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sDAAsD,CAAA;AAE3G,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,+BAA+B,EAAE,MAAM,EAAE,MAAM,iGAEvG"}
@@ -1,3 +0,0 @@
1
- export function loadImageSnapshotResultsAction(commands, taskId) {
2
- return commands.loadImageSnapshotResults(taskId);
3
- }
@@ -1,6 +0,0 @@
1
- import type { BrowserCommands } from '@vitest/browser/context';
2
- import type { ImageSnapshotNextIndexCommand } from '../../commands.ts';
3
- import type { PrepareImageSnapshotComparisonCommand } from '../../server/commands/prepare_image_snapshot_comparison.ts';
4
- import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts';
5
- export declare function matchImageSnapshotAction(commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand, taskId: string, subject: any, options?: ToMatchImageSnapshotOptions<any>): Promise<void>;
6
- //# sourceMappingURL=match_image_snapshot_action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"match_image_snapshot_action.d.ts","sourceRoot":"","sources":["../../../src/client/actions/match_image_snapshot_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,4DAA4D,CAAA;AAGvH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAIxE,wBAAsB,wBAAwB,CAC7C,QAAQ,EAAE,eAAe,GAAG,qCAAqC,GAAG,6BAA6B,EACjG,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC,iBAS1C"}
@@ -1,20 +0,0 @@
1
- import { assertSnapshotKeyWithoutDash } from "../../shared/asserts.js";
2
- import { isBase64String } from "../../shared/base64.js";
3
- import { compareImageSnapshot } from "../compare_image_snapshot.js";
4
- import { convertElementToCssSelector } from "../selector.js";
5
- export async function matchImageSnapshotAction(commands, taskId, subject, options) {
6
- assertSnapshotKeyWithoutDash(options?.snapshotKey);
7
- const info = await commands.prepareImageSnapshotComparison(taskId, parseImageSnapshotSubject(subject), options);
8
- if (!info)
9
- return;
10
- return compareImageSnapshot(commands, taskId, info, options);
11
- }
12
- function parseImageSnapshotSubject(subject) {
13
- if (subject instanceof Element)
14
- return convertElementToCssSelector(subject);
15
- if (subject?.['selector'])
16
- return subject['selector'];
17
- if (isBase64String(subject))
18
- return subject;
19
- throw new Error(`'toMatchImageSnapshot()' expects the subject to be an element, locator, or image encoded in base64 string, but got: ${subject}`);
20
- }
@@ -1,6 +0,0 @@
1
- import type { BrowserCommands } from '@vitest/browser/context';
2
- import type { ImageSnapshotNextIndexCommand } from '../../commands.ts';
3
- import type { PrepareImageSnapshotComparisonCommand } from '../../server/commands/prepare_image_snapshot_comparison.ts';
4
- import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts';
5
- export declare function matchPageImageSnapshotAction(commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand, taskId: string, options?: ToMatchImageSnapshotOptions<any>): Promise<void>;
6
- //# sourceMappingURL=match_page_image_snapshot_action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"match_page_image_snapshot_action.d.ts","sourceRoot":"","sources":["../../../src/client/actions/match_page_image_snapshot_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,4DAA4D,CAAA;AAEvH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAGxE,wBAAsB,4BAA4B,CACjD,QAAQ,EAAE,eAAe,GAAG,qCAAqC,GAAG,6BAA6B,EACjG,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC,iBAS1C"}
@@ -1,9 +0,0 @@
1
- import { assertSnapshotKeyWithoutDash } from "../../shared/asserts.js";
2
- import { compareImageSnapshot } from "../compare_image_snapshot.js";
3
- export async function matchPageImageSnapshotAction(commands, taskId, options) {
4
- assertSnapshotKeyWithoutDash(options?.snapshotKey);
5
- const info = await commands.preparePageImageSnapshotComparison(taskId, options);
6
- if (!info)
7
- return;
8
- return compareImageSnapshot(commands, taskId, info, options);
9
- }
@@ -1,2 +0,0 @@
1
- export declare function alignImagesToSameSize(image1: ImageData, image2: ImageData): [image1: ImageData, image2: ImageData];
2
- //# sourceMappingURL=align_images.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"align_images.d.ts","sourceRoot":"","sources":["../../src/client/align_images.ts"],"names":[],"mappings":"AAIA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAMlH"}
@@ -1,10 +0,0 @@
1
- import { getMaxSize } from "../shared/get_max_size.js";
2
- import { isSameSize } from "../shared/is_same_size.js";
3
- import { createImageResizer } from "./image_resizer.js";
4
- export function alignImagesToSameSize(image1, image2) {
5
- if (isSameSize(image1, image2))
6
- return [image1, image2];
7
- const size = getMaxSize(image1, image2);
8
- const resize = createImageResizer(size);
9
- return [resize(image1), resize(image2)];
10
- }
@@ -1,29 +0,0 @@
1
- import type { ComparisonMethod } from '../shared/types.ts';
2
- import type { SnapshotMeta } from './snapshot_meta.ts';
3
- type Suite = {
4
- meta: Record<string, any>;
5
- suite?: Suite | undefined;
6
- };
7
- export type MetaTask = {
8
- file?: {
9
- meta: Record<string, any>;
10
- } | undefined;
11
- suite?: Suite | undefined;
12
- meta: Record<string, any>;
13
- } | undefined;
14
- /**
15
- * Set the snapshot options for auto snapshot.
16
- *
17
- * ```ts
18
- * beforeAll(() => setAutoSnapshotOptions(...))
19
- * beforeEach(() => setAutoSnapshotOptions(...))
20
- *
21
- * it('...', () => {
22
- * setAutoSnapshotOptions(...)
23
- * })
24
- * ```
25
- */
26
- export declare function setAutoSnapshotOptions<M extends ComparisonMethod>(meta: SnapshotMeta<M> | boolean): void;
27
- export declare function extractAutoSnapshotOptions<M extends SnapshotMeta<any> = SnapshotMeta<any>>(task: MetaTask): M | undefined;
28
- export {};
29
- //# sourceMappingURL=auto_snapshot_options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto_snapshot_options.d.ts","sourceRoot":"","sources":["../../src/client/auto_snapshot_options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;CAAE,CAAA;AAErE,MAAM,MAAM,QAAQ,GACjB;IACA,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,SAAS,CAAA;IAChD,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACxB,GACD,SAAS,CAAA;AAEZ;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,IAAI,CAYxG;AAUD,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,EACzF,IAAI,EAAE,QAAQ,GACZ,CAAC,GAAG,SAAS,CAkBf"}
@@ -1,49 +0,0 @@
1
- import { assertSnapshotKeyWithoutDash } from "../shared/asserts.js";
2
- import { NAME } from "../shared/constants.js";
3
- import { ctx } from "./ctx.js";
4
- /**
5
- * Set the snapshot options for auto snapshot.
6
- *
7
- * ```ts
8
- * beforeAll(() => setAutoSnapshotOptions(...))
9
- * beforeEach(() => setAutoSnapshotOptions(...))
10
- *
11
- * it('...', () => {
12
- * setAutoSnapshotOptions(...)
13
- * })
14
- * ```
15
- */
16
- export function setAutoSnapshotOptions(meta) {
17
- if (typeof meta === 'object') {
18
- assertSnapshotKeyWithoutDash(meta.snapshotKey);
19
- }
20
- const task = getTask();
21
- if (!task)
22
- return;
23
- task.meta[NAME] = {
24
- ...task.meta[NAME],
25
- ...parseMeta(meta),
26
- };
27
- }
28
- function getTask() {
29
- return ctx.getCurrentTest() ?? ctx.getCurrentSuite()?.tasks?.[0]?.file;
30
- }
31
- function parseMeta(meta) {
32
- return typeof meta === 'boolean' ? { enable: meta } : { enable: true, ...meta };
33
- }
34
- export function extractAutoSnapshotOptions(task) {
35
- if (!task)
36
- return;
37
- const list = [];
38
- let current = task;
39
- while (current?.suite) {
40
- list.unshift(current.suite.meta);
41
- current = current.suite;
42
- }
43
- list.unshift(task.file?.meta);
44
- list.push(task.meta);
45
- return list.reduce((acc, cur) => {
46
- const meta = cur?.[NAME];
47
- return meta ? Object.assign({}, acc, meta) : acc;
48
- }, { enable: false });
49
- }
@@ -1,6 +0,0 @@
1
- import type { BrowserCommands } from '@vitest/browser/context';
2
- import type { ImageSnapshotNextIndexCommand } from '../commands.ts';
3
- import type { ImageSnapshotComparisonInfo, PrepareImageSnapshotComparisonCommand } from '../server/commands/prepare_image_snapshot_comparison.ts';
4
- import type { ToMatchImageSnapshotOptions } from '../shared/types.ts';
5
- export declare function compareImageSnapshot(commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand, taskId: string, info: ImageSnapshotComparisonInfo, options?: ToMatchImageSnapshotOptions<any>): Promise<void>;
6
- //# sourceMappingURL=compare_image_snapshot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compare_image_snapshot.d.ts","sourceRoot":"","sources":["../../src/client/compare_image_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAG9D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,KAAK,EACX,2BAA2B,EAC3B,qCAAqC,EACrC,MAAM,yDAAyD,CAAA;AAEhE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAMrE,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,eAAe,GAAG,qCAAqC,GAAG,6BAA6B,EACjG,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,2BAA2B,EACjC,OAAO,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC,iBA2D1C"}
@@ -1,52 +0,0 @@
1
- import dedent from 'dedent';
2
- import { resolve } from 'pathe';
3
- import { compareImage } from "../shared/compare_image.js";
4
- import { alignImagesToSameSize } from "./align_images.js";
5
- import { prettifyOptions } from "./compare_image_snapshot.logic.js";
6
- import { toDataURL, toImageData } from "./image_data.js";
7
- import { server } from "./vitest_browser_context_proxy.js";
8
- export async function compareImageSnapshot(commands, taskId, info, options) {
9
- options = { ...info, ...options };
10
- const baselineImage = await toImageData(info.baseline);
11
- const resultImage = await toImageData(info.result);
12
- const [baselineAlignedImage, resultAlignedImage] = alignImagesToSameSize(baselineImage, resultImage);
13
- const { width, height } = baselineAlignedImage;
14
- const diffImage = new ImageData(width, height);
15
- const { pass, diffAmount } = compareImage(baselineAlignedImage.data, resultAlignedImage.data, diffImage.data, width, height, options);
16
- if (pass) {
17
- if (options?.expectToFail) {
18
- throw new Error(dedent `Snapshot \`${taskId}\` matched but expected to fail.
19
-
20
- Options: ${prettifyOptions(options)}
21
- Diff: ${options.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}
22
-
23
- Expected: ${resolve(info.projectRoot, info.baselinePath)}
24
- Actual: ${resolve(info.projectRoot, info.resultPath)}`);
25
- }
26
- return;
27
- }
28
- if (server.config.snapshotOptions.updateSnapshot === 'all' && !options?.expectToFail) {
29
- await writeSnapshot(commands, resolve(info.projectRoot, info.baselinePath), resultImage);
30
- return;
31
- }
32
- await writeSnapshot(commands, resolve(info.projectRoot, info.diffPath), diffImage);
33
- throw new Error(dedent `Snapshot \`${taskId}\` mismatched
34
-
35
- ${options?.failureThreshold
36
- ? options?.failureThresholdType === 'percent'
37
- ? `Expected image to match within ${options.failureThreshold}% but was differ by ${diffAmount}%.`
38
- : `Expected image to match within ${options.failureThreshold} pixels but was differ by ${diffAmount} pixels.`
39
- : `Expected image to match but was differ by ${options?.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}.`}${baselineImage.width !== resultImage.width || baselineImage.height !== resultImage.height
40
- ? `\nThe image size changed from ${baselineImage.width}x${baselineImage.height} to ${resultImage.width}x${resultImage.height}.`
41
- : ''}
42
-
43
- Options: ${prettifyOptions(options)}
44
-
45
- Expected: ${resolve(info.projectRoot, info.baselinePath)}
46
- Actual: ${resolve(info.projectRoot, info.resultPath)}
47
- Difference: ${resolve(info.projectRoot, info.diffPath)}`);
48
- }
49
- async function writeSnapshot(commands, path, image) {
50
- const content = (await toDataURL(image)).split(',')[1];
51
- return commands.writeFile(path, content, { encoding: 'base64' });
52
- }
@@ -1,3 +0,0 @@
1
- import type { ToMatchImageSnapshotOptions } from '../shared/types.ts';
2
- export declare function prettifyOptions(options: ToMatchImageSnapshotOptions<any> | undefined): string;
3
- //# sourceMappingURL=compare_image_snapshot.logic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compare_image_snapshot.logic.d.ts","sourceRoot":"","sources":["../../src/client/compare_image_snapshot.logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAErE,wBAAgB,eAAe,CAAC,OAAO,EAAE,2BAA2B,CAAC,GAAG,CAAC,GAAG,SAAS,UAWpF"}
@@ -1,12 +0,0 @@
1
- export function prettifyOptions(options) {
2
- if (!options)
3
- return 'none';
4
- return [
5
- `failureThreshold: ${options.failureThreshold ?? 0} ${options.failureThresholdType ?? 'pixels'}`,
6
- options.timeout ? `timeout: ${options.timeout} ms` : '',
7
- `comparisonMethod: ${options.comparisonMethod ?? 'pixel'}`,
8
- options.diffOptions ? `diffOptions: ${JSON.stringify(options.diffOptions)}` : '',
9
- ]
10
- .filter(Boolean)
11
- .join('\n ');
12
- }
@@ -1,7 +0,0 @@
1
- export declare const ctx: {
2
- autoEnabled: boolean | undefined;
3
- getCurrentTest: () => import("./vitest_suite_proxy.ts").CurrentTest;
4
- getCurrentSuite: () => import("vitest").SuiteCollector<object>;
5
- __test__reset(): void;
6
- };
7
- //# sourceMappingURL=ctx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ctx.d.ts","sourceRoot":"","sources":["../../src/client/ctx.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG;iBACW,OAAO,GAAG,SAAS;;;;CAQ7C,CAAA"}
package/esm/client/ctx.js DELETED
@@ -1,11 +0,0 @@
1
- import { getCurrentSuite, getCurrentTest } from "./vitest_suite_proxy.js";
2
- export const ctx = {
3
- autoEnabled: undefined,
4
- getCurrentTest,
5
- getCurrentSuite,
6
- __test__reset() {
7
- ctx.getCurrentTest = getCurrentTest;
8
- ctx.getCurrentSuite = getCurrentSuite;
9
- ctx.autoEnabled = undefined;
10
- },
11
- };
@@ -1,8 +0,0 @@
1
- import type { ImageSnapshotMatcher } from './to_match_image_snapshot.types.ts';
2
- declare global {
3
- namespace jest {
4
- interface Matchers<R, T> extends ImageSnapshotMatcher {
5
- }
6
- }
7
- }
8
- //# sourceMappingURL=augment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"augment.d.ts","sourceRoot":"","sources":["../../../src/client/expect/augment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAE9E,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,IAAI,CAAC;QAEd,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,oBAAoB;SAAG;KACxD;CACD"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import type { SyncExpectationResult } from '@vitest/expect';
2
- export declare const success: SyncExpectationResult;
3
- //# sourceMappingURL=expectation_result.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expectation_result.d.ts","sourceRoot":"","sources":["../../../src/client/expect/expectation_result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAE3D,eAAO,MAAM,OAAO,EAAE,qBAIrB,CAAA"}
@@ -1,5 +0,0 @@
1
- export const success = {
2
- pass: true,
3
- /* v8 ignore next */
4
- message: () => '',
5
- };
@@ -1,2 +0,0 @@
1
- import './augment.ts';
2
- //# sourceMappingURL=extend.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../src/client/expect/extend.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAA"}
@@ -1,4 +0,0 @@
1
- import { expect } from 'vitest';
2
- import { toMatchImageSnapshot } from "./to_match_image_snapshot.js";
3
- import "./augment.js";
4
- expect.extend({ toMatchImageSnapshot });
@@ -1,9 +0,0 @@
1
- import type { AsyncExpectationResult } from '@vitest/expect';
2
- import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts';
3
- export declare function toMatchImageSnapshot(
4
- /**
5
- * The element or locator to take the snapshot of,
6
- * or the base64 value of the image to compare against.
7
- */
8
- subject: any, options?: ToMatchImageSnapshotOptions | undefined): AsyncExpectationResult;
9
- //# sourceMappingURL=to_match_image_snapshot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"to_match_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/client/expect/to_match_image_snapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAMxE,wBAAgB,oBAAoB;AACnC;;;GAGG;AACH,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,2BAA2B,GAAG,SAAS,GAC/C,sBAAsB,CAcxB"}
@@ -1,21 +0,0 @@
1
- import { commands } from '@vitest/browser/context';
2
- import { matchImageSnapshotAction } from "../actions/match_image_snapshot_action.js";
3
- import { ctx } from "../ctx.js";
4
- import { toTaskId } from "../task_id.js";
5
- import { success } from "./expectation_result.js";
6
- export function toMatchImageSnapshot(
7
- /**
8
- * The element or locator to take the snapshot of,
9
- * or the base64 value of the image to compare against.
10
- */
11
- subject, options) {
12
- const test = ctx.getCurrentTest();
13
- if (!test) {
14
- throw new Error('`toMatchImageSnapshot()` must be called in a test.');
15
- }
16
- if (test.concurrent) {
17
- throw new Error('`toMatchImageSnapshot()` cannot be called in a concurrent test because ' +
18
- "concurrent tests run at the same time in the same iframe and affect each other's environment.");
19
- }
20
- return matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success);
21
- }
@@ -1,5 +0,0 @@
1
- import type { ComparisonMethod, ToMatchImageSnapshotOptions } from '../../shared/types.ts';
2
- export interface ImageSnapshotMatcher {
3
- toMatchImageSnapshot<M extends ComparisonMethod>(options?: ToMatchImageSnapshotOptions<M> | undefined): Promise<void>;
4
- }
5
- //# sourceMappingURL=to_match_image_snapshot.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"to_match_image_snapshot.types.d.ts","sourceRoot":"","sources":["../../../src/client/expect/to_match_image_snapshot.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAE1F,MAAM,WAAW,oBAAoB;IACpC,oBAAoB,CAAC,CAAC,SAAS,gBAAgB,EAAE,OAAO,CAAC,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrH"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export declare function toImageData(base64: string): Promise<ImageData>;
2
- export declare function toDataURL(imageData: ImageData): Promise<string>;
3
- //# sourceMappingURL=image_data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image_data.d.ts","sourceRoot":"","sources":["../../src/client/image_data.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,sBAkBzC;AAED,wBAAsB,SAAS,CAAC,SAAS,EAAE,SAAS,mBAenD"}
@@ -1,33 +0,0 @@
1
- export function toImageData(base64) {
2
- return new Promise((resolve, reject) => {
3
- const img = new Image();
4
- img.src = `data:image/png;base64,${base64}`;
5
- img.onload = () => {
6
- const canvas = document.createElement('canvas');
7
- canvas.width = img.width;
8
- canvas.height = img.height;
9
- const ctx = canvas.getContext('2d');
10
- ctx.drawImage(img, 0, 0);
11
- resolve(ctx.getImageData(0, 0, canvas.width, canvas.height));
12
- };
13
- img.onerror = () => {
14
- reject(new Error('Failed to load image'));
15
- };
16
- });
17
- }
18
- export async function toDataURL(imageData) {
19
- const canvas = document.createElement('canvas');
20
- canvas.width = imageData.width;
21
- canvas.height = imageData.height;
22
- const ctx = canvas.getContext('2d');
23
- ctx.putImageData(imageData, 0, 0);
24
- return new Promise((resolve) => {
25
- canvas.toBlob((blob) => {
26
- const reader = new FileReader();
27
- reader.onload = () => {
28
- resolve(reader.result);
29
- };
30
- reader.readAsDataURL(blob);
31
- });
32
- });
33
- }
@@ -1,9 +0,0 @@
1
- export declare const createImageResizer: ({ width, height }: {
2
- width: number;
3
- height: number;
4
- }) => (image: ImageData) => ImageData;
5
- export declare const createImageResizer2: ({ width, height }: {
6
- width: number;
7
- height: number;
8
- }) => (image: ImageData) => ImageData;
9
- //# sourceMappingURL=image_resizer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image_resizer.d.ts","sourceRoot":"","sources":["../../src/client/image_resizer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,GAC7B,mBAAmB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,MACpD,OAAO,SAAS,cA2BhB,CAAA;AAGF,eAAO,MAAM,mBAAmB,GAC9B,mBAAmB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,MACpD,OAAO,SAAS,cAsBhB,CAAA"}
@@ -1,49 +0,0 @@
1
- import { isSameSize } from "../shared/is_same_size.js";
2
- export const createImageResizer = ({ width, height }) => (image) => {
3
- if (isSameSize(image, { width, height }))
4
- return image;
5
- const inArea = (x, y) => y <= image.height && x <= image.width;
6
- const data = new Uint8ClampedArray(width * height * 4);
7
- const result = new ImageData(data, width, height, { colorSpace: image.colorSpace });
8
- for (let y = 0; y < height; y++) {
9
- for (let x = 0; x < width; x++) {
10
- const idx = (width * y + x) << 2;
11
- if (inArea(x, y)) {
12
- const old = (image.width * y + x) << 2;
13
- result.data[idx] = image.data[old];
14
- result.data[idx + 1] = image.data[old + 1];
15
- result.data[idx + 2] = image.data[old + 2];
16
- result.data[idx + 3] = image.data[old + 3];
17
- }
18
- else {
19
- result.data[idx] = 0;
20
- result.data[idx + 1] = 0;
21
- result.data[idx + 2] = 0;
22
- result.data[idx + 3] = 64;
23
- }
24
- }
25
- }
26
- return result;
27
- };
28
- // slower
29
- export const createImageResizer2 = ({ width, height }) => (image) => {
30
- if (isSameSize(image, { width, height }))
31
- return image;
32
- const inArea = (x, y) => y <= image.height && x <= image.width;
33
- const data = new Uint8ClampedArray(width * height * 4);
34
- const result = new ImageData(data, width, height, { colorSpace: image.colorSpace });
35
- const copyBytes = image.width * 4;
36
- for (let y = 0; y < height; y++) {
37
- result.data.set(image.data.slice(y * image.width, copyBytes), y * width * 4);
38
- for (let x = image.width; x < width; x++) {
39
- const idx = (width * y + x) << 2;
40
- if (!inArea(x, y)) {
41
- result.data[idx] = 0;
42
- result.data[idx + 1] = 0;
43
- result.data[idx + 2] = 0;
44
- result.data[idx + 3] = 64;
45
- }
46
- }
47
- }
48
- return result;
49
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=image_snapshot_options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image_snapshot_options.d.ts","sourceRoot":"","sources":["../../src/client/image_snapshot_options.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- // import type { ToMatchImageSnapshotOptions } from '../shared/types.ts'
2
- export {};
3
- // export function parseImageSnapshotOptions(taskId: string, options: ToMatchImageSnapshotOptions<any> | undefined) {
4
- // const { snapshotKey, ...rest } = options ?? {}
5
- // return snapshotKey ? { ...options, snapshotFileId: `${taskId}-${snapshotKey}` } : rest
6
- // }
@@ -1,7 +0,0 @@
1
- import type { HasImageSnapshotAction } from './has_image_snapshot.ts';
2
- import type { ToMatchImageSnapshotAction } from './to_match_image_snapshot.ts';
3
- declare module '@vitest/browser/context' {
4
- interface BrowserPage extends HasImageSnapshotAction, ToMatchImageSnapshotAction {
5
- }
6
- }
7
- //# sourceMappingURL=augment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"augment.d.ts","sourceRoot":"","sources":["../../../src/client/page/augment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAE9E,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,WAAY,SAAQ,sBAAsB,EAAE,0BAA0B;KAAG;CACnF"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import './augment.ts';
2
- //# sourceMappingURL=extend.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../src/client/page/extend.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAA"}
@@ -1,5 +0,0 @@
1
- import { page } from '@vitest/browser/context';
2
- import "./augment.js";
3
- import { hasImageSnapshot } from "./has_image_snapshot.js";
4
- import { toMatchImageSnapshot } from "./to_match_image_snapshot.js";
5
- page.extend({ hasImageSnapshot, toMatchImageSnapshot });
@@ -1,10 +0,0 @@
1
- import { type BrowserPage } from '@vitest/browser/context';
2
- import type { ImageSnapshotKeyOptions } from '../../shared/types.ts';
3
- export interface HasImageSnapshotAction {
4
- /**
5
- * Check if the snapshot image exists.
6
- */
7
- hasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>;
8
- }
9
- export declare function hasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>;
10
- //# sourceMappingURL=has_image_snapshot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"has_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/client/page/has_image_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,yBAAyB,CAAA;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAKpE,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACpG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,SAAS,oBAahG"}
@@ -1,15 +0,0 @@
1
- import { commands } from '@vitest/browser/context';
2
- import { hasImageSnapshotAction } from "../actions/has_image_snapshot_action.js";
3
- import { ctx } from "../ctx.js";
4
- import { toTaskId } from "../task_id.js";
5
- export function hasImageSnapshot(options) {
6
- const test = ctx.getCurrentTest();
7
- if (!test) {
8
- throw new Error('`hasImageSnapshot()` must be called in a test.');
9
- }
10
- if (test.concurrent) {
11
- throw new Error('`hasImageSnapshot()` cannot be called in a concurrent test because ' +
12
- "concurrent tests run at the same time in the same iframe and affect each other's environment. ");
13
- }
14
- return hasImageSnapshotAction(commands, toTaskId(test), options);
15
- }
@@ -1,6 +0,0 @@
1
- import type { ComparisonMethod, ToMatchPageImageSnapshotOptions } from '../../shared/types.ts';
2
- export interface ToMatchImageSnapshotAction {
3
- toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(options?: ToMatchPageImageSnapshotOptions<M> | undefined): Promise<void>;
4
- }
5
- export declare function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(options?: ToMatchPageImageSnapshotOptions<M> | undefined): Promise<void>;
6
- //# sourceMappingURL=to_match_image_snapshot.d.ts.map