bupkis 0.18.3 → 1.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 (388) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1 -1
  3. package/dist/assertion/assertion-async.cjs +268 -0
  4. package/dist/assertion/assertion-async.cjs.map +1 -0
  5. package/dist/assertion/assertion-async.d.cts +40 -0
  6. package/dist/assertion/assertion-async.d.cts.map +1 -0
  7. package/dist/assertion/assertion-async.d.ts +40 -0
  8. package/dist/assertion/assertion-async.d.ts.map +1 -0
  9. package/dist/assertion/assertion-async.js +259 -0
  10. package/dist/assertion/assertion-async.js.map +1 -0
  11. package/dist/assertion/assertion-standard-schema-async.cjs +132 -0
  12. package/dist/assertion/assertion-standard-schema-async.cjs.map +1 -0
  13. package/dist/assertion/assertion-standard-schema-async.d.cts +52 -0
  14. package/dist/assertion/assertion-standard-schema-async.d.cts.map +1 -0
  15. package/dist/assertion/assertion-standard-schema-async.d.ts +52 -0
  16. package/dist/assertion/assertion-standard-schema-async.d.ts.map +1 -0
  17. package/dist/assertion/assertion-standard-schema-async.js +128 -0
  18. package/dist/assertion/assertion-standard-schema-async.js.map +1 -0
  19. package/dist/assertion/assertion-standard-schema-sync.cjs +141 -0
  20. package/dist/assertion/assertion-standard-schema-sync.cjs.map +1 -0
  21. package/dist/assertion/assertion-standard-schema-sync.d.cts +52 -0
  22. package/dist/assertion/assertion-standard-schema-sync.d.cts.map +1 -0
  23. package/dist/assertion/assertion-standard-schema-sync.d.ts +52 -0
  24. package/dist/assertion/assertion-standard-schema-sync.d.ts.map +1 -0
  25. package/dist/assertion/assertion-standard-schema-sync.js +137 -0
  26. package/dist/assertion/assertion-standard-schema-sync.js.map +1 -0
  27. package/dist/assertion/assertion-sync.cjs +281 -0
  28. package/dist/assertion/assertion-sync.cjs.map +1 -0
  29. package/dist/assertion/assertion-sync.d.cts +60 -0
  30. package/dist/assertion/assertion-sync.d.cts.map +1 -0
  31. package/dist/assertion/assertion-sync.d.ts +60 -0
  32. package/dist/assertion/assertion-sync.d.ts.map +1 -0
  33. package/dist/assertion/assertion-sync.js +275 -0
  34. package/dist/assertion/assertion-sync.js.map +1 -0
  35. package/dist/assertion/assertion-types.cjs +20 -0
  36. package/dist/assertion/assertion-types.cjs.map +1 -0
  37. package/dist/assertion/assertion-types.d.cts +1086 -0
  38. package/dist/assertion/assertion-types.d.cts.map +1 -0
  39. package/dist/assertion/assertion-types.d.ts +1086 -0
  40. package/dist/assertion/assertion-types.d.ts.map +1 -0
  41. package/dist/assertion/assertion-types.js +19 -0
  42. package/dist/assertion/assertion-types.js.map +1 -0
  43. package/dist/assertion/assertion.cjs +382 -0
  44. package/dist/assertion/assertion.cjs.map +1 -0
  45. package/dist/assertion/assertion.d.cts +109 -0
  46. package/dist/assertion/assertion.d.cts.map +1 -0
  47. package/dist/assertion/assertion.d.ts +109 -0
  48. package/dist/assertion/assertion.d.ts.map +1 -0
  49. package/dist/assertion/assertion.js +375 -0
  50. package/dist/assertion/assertion.js.map +1 -0
  51. package/dist/assertion/create.cjs +148 -0
  52. package/dist/assertion/create.cjs.map +1 -0
  53. package/dist/assertion/create.d.cts +85 -0
  54. package/dist/assertion/create.d.cts.map +1 -0
  55. package/dist/assertion/create.d.ts +85 -0
  56. package/dist/assertion/create.d.ts.map +1 -0
  57. package/dist/assertion/create.js +143 -0
  58. package/dist/assertion/create.js.map +1 -0
  59. package/dist/assertion/format-assertion-failure.cjs +63 -0
  60. package/dist/assertion/format-assertion-failure.cjs.map +1 -0
  61. package/dist/assertion/format-assertion-failure.d.cts +21 -0
  62. package/dist/assertion/format-assertion-failure.d.cts.map +1 -0
  63. package/dist/assertion/format-assertion-failure.d.ts +21 -0
  64. package/dist/assertion/format-assertion-failure.d.ts.map +1 -0
  65. package/dist/assertion/format-assertion-failure.js +59 -0
  66. package/dist/assertion/format-assertion-failure.js.map +1 -0
  67. package/dist/assertion/impl/assertion-util.cjs +68 -0
  68. package/dist/assertion/impl/assertion-util.cjs.map +1 -0
  69. package/dist/assertion/impl/assertion-util.d.cts +36 -0
  70. package/dist/assertion/impl/assertion-util.d.cts.map +1 -0
  71. package/dist/assertion/impl/assertion-util.d.ts +36 -0
  72. package/dist/assertion/impl/assertion-util.d.ts.map +1 -0
  73. package/dist/assertion/impl/assertion-util.js +62 -0
  74. package/dist/assertion/impl/assertion-util.js.map +1 -0
  75. package/dist/assertion/impl/async-iterable.cjs +627 -0
  76. package/dist/assertion/impl/async-iterable.cjs.map +1 -0
  77. package/dist/assertion/impl/async-iterable.d.cts +406 -0
  78. package/dist/assertion/impl/async-iterable.d.cts.map +1 -0
  79. package/dist/assertion/impl/async-iterable.d.ts +406 -0
  80. package/dist/assertion/impl/async-iterable.d.ts.map +1 -0
  81. package/dist/assertion/impl/async-iterable.js +624 -0
  82. package/dist/assertion/impl/async-iterable.js.map +1 -0
  83. package/dist/assertion/impl/async-parametric.cjs +412 -0
  84. package/dist/assertion/impl/async-parametric.cjs.map +1 -0
  85. package/dist/assertion/impl/async-parametric.d.cts +278 -0
  86. package/dist/assertion/impl/async-parametric.d.cts.map +1 -0
  87. package/dist/assertion/impl/async-parametric.d.ts +278 -0
  88. package/dist/assertion/impl/async-parametric.d.ts.map +1 -0
  89. package/dist/assertion/impl/async-parametric.js +409 -0
  90. package/dist/assertion/impl/async-parametric.js.map +1 -0
  91. package/dist/assertion/impl/async.cjs +56 -0
  92. package/dist/assertion/impl/async.cjs.map +1 -0
  93. package/dist/assertion/impl/async.d.cts +179 -0
  94. package/dist/assertion/impl/async.d.cts.map +1 -0
  95. package/dist/assertion/impl/async.d.ts +179 -0
  96. package/dist/assertion/impl/async.d.ts.map +1 -0
  97. package/dist/assertion/impl/async.js +39 -0
  98. package/dist/assertion/impl/async.js.map +1 -0
  99. package/dist/assertion/impl/index.cjs +37 -0
  100. package/dist/assertion/impl/index.cjs.map +1 -0
  101. package/dist/assertion/impl/index.d.cts +21 -0
  102. package/dist/assertion/impl/index.d.cts.map +1 -0
  103. package/dist/assertion/impl/index.d.ts +21 -0
  104. package/dist/assertion/impl/index.d.ts.map +1 -0
  105. package/dist/assertion/impl/index.js +21 -0
  106. package/dist/assertion/impl/index.js.map +1 -0
  107. package/dist/assertion/impl/iteration-util.cjs +297 -0
  108. package/dist/assertion/impl/iteration-util.cjs.map +1 -0
  109. package/dist/assertion/impl/iteration-util.d.cts +12 -0
  110. package/dist/assertion/impl/iteration-util.d.cts.map +1 -0
  111. package/dist/assertion/impl/iteration-util.d.ts +12 -0
  112. package/dist/assertion/impl/iteration-util.d.ts.map +1 -0
  113. package/dist/assertion/impl/iteration-util.js +282 -0
  114. package/dist/assertion/impl/iteration-util.js.map +1 -0
  115. package/dist/assertion/impl/snapshot.cjs +276 -0
  116. package/dist/assertion/impl/snapshot.cjs.map +1 -0
  117. package/dist/assertion/impl/snapshot.d.cts +278 -0
  118. package/dist/assertion/impl/snapshot.d.cts.map +1 -0
  119. package/dist/assertion/impl/snapshot.d.ts +278 -0
  120. package/dist/assertion/impl/snapshot.d.ts.map +1 -0
  121. package/dist/assertion/impl/snapshot.js +273 -0
  122. package/dist/assertion/impl/snapshot.js.map +1 -0
  123. package/dist/assertion/impl/sync-basic.cjs +553 -0
  124. package/dist/assertion/impl/sync-basic.cjs.map +1 -0
  125. package/dist/assertion/impl/sync-basic.d.cts +528 -0
  126. package/dist/assertion/impl/sync-basic.d.cts.map +1 -0
  127. package/dist/assertion/impl/sync-basic.d.ts +528 -0
  128. package/dist/assertion/impl/sync-basic.d.ts.map +1 -0
  129. package/dist/assertion/impl/sync-basic.js +550 -0
  130. package/dist/assertion/impl/sync-basic.js.map +1 -0
  131. package/dist/assertion/impl/sync-collection.cjs +1424 -0
  132. package/dist/assertion/impl/sync-collection.cjs.map +1 -0
  133. package/dist/assertion/impl/sync-collection.d.cts +922 -0
  134. package/dist/assertion/impl/sync-collection.d.cts.map +1 -0
  135. package/dist/assertion/impl/sync-collection.d.ts +922 -0
  136. package/dist/assertion/impl/sync-collection.d.ts.map +1 -0
  137. package/dist/assertion/impl/sync-collection.js +1418 -0
  138. package/dist/assertion/impl/sync-collection.js.map +1 -0
  139. package/dist/assertion/impl/sync-date.cjs +341 -0
  140. package/dist/assertion/impl/sync-date.cjs.map +1 -0
  141. package/dist/assertion/impl/sync-date.d.cts +209 -0
  142. package/dist/assertion/impl/sync-date.d.cts.map +1 -0
  143. package/dist/assertion/impl/sync-date.d.ts +209 -0
  144. package/dist/assertion/impl/sync-date.d.ts.map +1 -0
  145. package/dist/assertion/impl/sync-date.js +338 -0
  146. package/dist/assertion/impl/sync-date.js.map +1 -0
  147. package/dist/assertion/impl/sync-esoteric.cjs +214 -0
  148. package/dist/assertion/impl/sync-esoteric.cjs.map +1 -0
  149. package/dist/assertion/impl/sync-esoteric.d.cts +191 -0
  150. package/dist/assertion/impl/sync-esoteric.d.cts.map +1 -0
  151. package/dist/assertion/impl/sync-esoteric.d.ts +191 -0
  152. package/dist/assertion/impl/sync-esoteric.d.ts.map +1 -0
  153. package/dist/assertion/impl/sync-esoteric.js +211 -0
  154. package/dist/assertion/impl/sync-esoteric.js.map +1 -0
  155. package/dist/assertion/impl/sync-iterable.cjs +512 -0
  156. package/dist/assertion/impl/sync-iterable.cjs.map +1 -0
  157. package/dist/assertion/impl/sync-iterable.d.cts +334 -0
  158. package/dist/assertion/impl/sync-iterable.d.cts.map +1 -0
  159. package/dist/assertion/impl/sync-iterable.d.ts +334 -0
  160. package/dist/assertion/impl/sync-iterable.d.ts.map +1 -0
  161. package/dist/assertion/impl/sync-iterable.js +509 -0
  162. package/dist/assertion/impl/sync-iterable.js.map +1 -0
  163. package/dist/assertion/impl/sync-parametric.cjs +805 -0
  164. package/dist/assertion/impl/sync-parametric.cjs.map +1 -0
  165. package/dist/assertion/impl/sync-parametric.d.cts +560 -0
  166. package/dist/assertion/impl/sync-parametric.d.cts.map +1 -0
  167. package/dist/assertion/impl/sync-parametric.d.ts +560 -0
  168. package/dist/assertion/impl/sync-parametric.d.ts.map +1 -0
  169. package/dist/assertion/impl/sync-parametric.js +802 -0
  170. package/dist/assertion/impl/sync-parametric.js.map +1 -0
  171. package/dist/assertion/impl/sync.cjs +229 -0
  172. package/dist/assertion/impl/sync.cjs.map +1 -0
  173. package/dist/assertion/impl/sync.d.cts +536 -0
  174. package/dist/assertion/impl/sync.d.cts.map +1 -0
  175. package/dist/assertion/impl/sync.d.ts +536 -0
  176. package/dist/assertion/impl/sync.d.ts.map +1 -0
  177. package/dist/assertion/impl/sync.js +212 -0
  178. package/dist/assertion/impl/sync.js.map +1 -0
  179. package/dist/assertion/index.cjs +38 -0
  180. package/dist/assertion/index.cjs.map +1 -0
  181. package/dist/assertion/index.d.cts +18 -0
  182. package/dist/assertion/index.d.cts.map +1 -0
  183. package/dist/assertion/index.d.ts +18 -0
  184. package/dist/assertion/index.d.ts.map +1 -0
  185. package/dist/assertion/index.js +17 -0
  186. package/dist/assertion/index.js.map +1 -0
  187. package/dist/assertion/slotify.cjs +165 -0
  188. package/dist/assertion/slotify.cjs.map +1 -0
  189. package/dist/assertion/slotify.d.cts +11 -0
  190. package/dist/assertion/slotify.d.cts.map +1 -0
  191. package/dist/assertion/slotify.d.ts +11 -0
  192. package/dist/assertion/slotify.d.ts.map +1 -0
  193. package/dist/assertion/slotify.js +161 -0
  194. package/dist/assertion/slotify.js.map +1 -0
  195. package/dist/bootstrap.cjs +43 -0
  196. package/dist/bootstrap.cjs.map +1 -0
  197. package/dist/bootstrap.d.cts +27 -0
  198. package/dist/bootstrap.d.cts.map +1 -0
  199. package/dist/bootstrap.d.ts +27 -0
  200. package/dist/bootstrap.d.ts.map +1 -0
  201. package/dist/bootstrap.js +40 -0
  202. package/dist/bootstrap.js.map +1 -0
  203. package/dist/constant.cjs +82 -0
  204. package/dist/constant.cjs.map +1 -0
  205. package/dist/constant.d.cts +69 -0
  206. package/dist/constant.d.cts.map +1 -0
  207. package/dist/constant.d.ts +69 -0
  208. package/dist/constant.d.ts.map +1 -0
  209. package/dist/constant.js +79 -0
  210. package/dist/constant.js.map +1 -0
  211. package/dist/diff.cjs +340 -0
  212. package/dist/diff.cjs.map +1 -0
  213. package/dist/diff.d.cts +51 -0
  214. package/dist/diff.d.cts.map +1 -0
  215. package/dist/diff.d.ts +51 -0
  216. package/dist/diff.d.ts.map +1 -0
  217. package/dist/diff.js +334 -0
  218. package/dist/diff.js.map +1 -0
  219. package/dist/error.cjs +194 -0
  220. package/dist/error.cjs.map +1 -0
  221. package/dist/error.d.cts +212 -0
  222. package/dist/error.d.cts.map +1 -0
  223. package/dist/error.d.ts +212 -0
  224. package/dist/error.d.ts.map +1 -0
  225. package/dist/error.js +181 -0
  226. package/dist/error.js.map +1 -0
  227. package/dist/expect.cjs +587 -0
  228. package/dist/expect.cjs.map +1 -0
  229. package/dist/expect.d.cts +138 -0
  230. package/dist/expect.d.cts.map +1 -0
  231. package/dist/expect.d.ts +138 -0
  232. package/dist/expect.d.ts.map +1 -0
  233. package/dist/expect.js +582 -0
  234. package/dist/expect.js.map +1 -0
  235. package/dist/guards.cjs +291 -0
  236. package/dist/guards.cjs.map +1 -0
  237. package/dist/guards.d.cts +225 -0
  238. package/dist/guards.d.cts.map +1 -0
  239. package/dist/guards.d.ts +225 -0
  240. package/dist/guards.d.ts.map +1 -0
  241. package/dist/guards.js +273 -0
  242. package/dist/guards.js.map +1 -0
  243. package/dist/index.cjs +111 -0
  244. package/dist/index.cjs.map +1 -0
  245. package/dist/index.d.cts +460 -0
  246. package/dist/index.d.cts.map +1 -0
  247. package/dist/index.d.ts +460 -0
  248. package/dist/index.d.ts.map +1 -0
  249. package/dist/index.js +71 -0
  250. package/dist/index.js.map +1 -0
  251. package/dist/internal-schema.cjs +234 -0
  252. package/dist/internal-schema.cjs.map +1 -0
  253. package/dist/internal-schema.d.cts +8 -0
  254. package/dist/internal-schema.d.cts.map +1 -0
  255. package/dist/internal-schema.d.ts +8 -0
  256. package/dist/internal-schema.d.ts.map +1 -0
  257. package/dist/internal-schema.js +229 -0
  258. package/dist/internal-schema.js.map +1 -0
  259. package/dist/metadata.cjs +57 -0
  260. package/dist/metadata.cjs.map +1 -0
  261. package/dist/metadata.d.cts +27 -0
  262. package/dist/metadata.d.cts.map +1 -0
  263. package/dist/metadata.d.ts +27 -0
  264. package/dist/metadata.d.ts.map +1 -0
  265. package/dist/metadata.js +54 -0
  266. package/dist/metadata.js.map +1 -0
  267. package/dist/schema.cjs +1522 -0
  268. package/dist/schema.cjs.map +1 -0
  269. package/dist/schema.d.cts +1196 -0
  270. package/dist/schema.d.cts.map +1 -0
  271. package/dist/schema.d.ts +1196 -0
  272. package/dist/schema.d.ts.map +1 -0
  273. package/dist/schema.js +1516 -0
  274. package/dist/schema.js.map +1 -0
  275. package/dist/snapshot/adapter.cjs +29 -0
  276. package/dist/snapshot/adapter.cjs.map +1 -0
  277. package/dist/snapshot/adapter.d.cts +258 -0
  278. package/dist/snapshot/adapter.d.cts.map +1 -0
  279. package/dist/snapshot/adapter.d.ts +258 -0
  280. package/dist/snapshot/adapter.d.ts.map +1 -0
  281. package/dist/snapshot/adapter.js +25 -0
  282. package/dist/snapshot/adapter.js.map +1 -0
  283. package/dist/snapshot/adapters/fallback.cjs +452 -0
  284. package/dist/snapshot/adapters/fallback.cjs.map +1 -0
  285. package/dist/snapshot/adapters/fallback.d.cts +185 -0
  286. package/dist/snapshot/adapters/fallback.d.cts.map +1 -0
  287. package/dist/snapshot/adapters/fallback.d.ts +185 -0
  288. package/dist/snapshot/adapters/fallback.d.ts.map +1 -0
  289. package/dist/snapshot/adapters/fallback.js +445 -0
  290. package/dist/snapshot/adapters/fallback.js.map +1 -0
  291. package/dist/snapshot/adapters/node-test.cjs +297 -0
  292. package/dist/snapshot/adapters/node-test.cjs.map +1 -0
  293. package/dist/snapshot/adapters/node-test.d.cts +131 -0
  294. package/dist/snapshot/adapters/node-test.d.cts.map +1 -0
  295. package/dist/snapshot/adapters/node-test.d.ts +131 -0
  296. package/dist/snapshot/adapters/node-test.d.ts.map +1 -0
  297. package/dist/snapshot/adapters/node-test.js +293 -0
  298. package/dist/snapshot/adapters/node-test.js.map +1 -0
  299. package/dist/snapshot/index.cjs +61 -0
  300. package/dist/snapshot/index.cjs.map +1 -0
  301. package/dist/snapshot/index.d.cts +40 -0
  302. package/dist/snapshot/index.d.cts.map +1 -0
  303. package/dist/snapshot/index.d.ts +40 -0
  304. package/dist/snapshot/index.d.ts.map +1 -0
  305. package/dist/snapshot/index.js +44 -0
  306. package/dist/snapshot/index.js.map +1 -0
  307. package/dist/snapshot/node-version.cjs +49 -0
  308. package/dist/snapshot/node-version.cjs.map +1 -0
  309. package/dist/snapshot/node-version.d.cts +34 -0
  310. package/dist/snapshot/node-version.d.cts.map +1 -0
  311. package/dist/snapshot/node-version.d.ts +34 -0
  312. package/dist/snapshot/node-version.d.ts.map +1 -0
  313. package/dist/snapshot/node-version.js +44 -0
  314. package/dist/snapshot/node-version.js.map +1 -0
  315. package/dist/snapshot/select-adapter.cjs +170 -0
  316. package/dist/snapshot/select-adapter.cjs.map +1 -0
  317. package/dist/snapshot/select-adapter.d.cts +128 -0
  318. package/dist/snapshot/select-adapter.d.cts.map +1 -0
  319. package/dist/snapshot/select-adapter.d.ts +128 -0
  320. package/dist/snapshot/select-adapter.d.ts.map +1 -0
  321. package/dist/snapshot/select-adapter.js +164 -0
  322. package/dist/snapshot/select-adapter.js.map +1 -0
  323. package/dist/snapshot/serializer.cjs +245 -0
  324. package/dist/snapshot/serializer.cjs.map +1 -0
  325. package/dist/snapshot/serializer.d.cts +126 -0
  326. package/dist/snapshot/serializer.d.cts.map +1 -0
  327. package/dist/snapshot/serializer.d.ts +126 -0
  328. package/dist/snapshot/serializer.d.ts.map +1 -0
  329. package/dist/snapshot/serializer.js +237 -0
  330. package/dist/snapshot/serializer.js.map +1 -0
  331. package/dist/standard-schema.cjs +13 -0
  332. package/dist/standard-schema.cjs.map +1 -0
  333. package/dist/standard-schema.d.cts +192 -0
  334. package/dist/standard-schema.d.cts.map +1 -0
  335. package/dist/standard-schema.d.ts +192 -0
  336. package/dist/standard-schema.d.ts.map +1 -0
  337. package/dist/standard-schema.js +12 -0
  338. package/dist/standard-schema.js.map +1 -0
  339. package/dist/types.cjs +22 -0
  340. package/dist/types.cjs.map +1 -0
  341. package/dist/types.d.cts +756 -0
  342. package/dist/types.d.cts.map +1 -0
  343. package/dist/types.d.ts +756 -0
  344. package/dist/types.d.ts.map +1 -0
  345. package/dist/types.js +21 -0
  346. package/dist/types.js.map +1 -0
  347. package/dist/use.cjs +240 -0
  348. package/dist/use.cjs.map +1 -0
  349. package/dist/use.d.cts +8 -0
  350. package/dist/use.d.cts.map +1 -0
  351. package/dist/use.d.ts +8 -0
  352. package/dist/use.d.ts.map +1 -0
  353. package/dist/use.js +236 -0
  354. package/dist/use.js.map +1 -0
  355. package/dist/util.cjs +255 -0
  356. package/dist/util.cjs.map +1 -0
  357. package/dist/util.d.cts +141 -0
  358. package/dist/util.d.cts.map +1 -0
  359. package/dist/util.d.ts +141 -0
  360. package/dist/util.d.ts.map +1 -0
  361. package/dist/util.js +234 -0
  362. package/dist/util.js.map +1 -0
  363. package/dist/value-to-schema.cjs +537 -0
  364. package/dist/value-to-schema.cjs.map +1 -0
  365. package/dist/value-to-schema.d.cts +144 -0
  366. package/dist/value-to-schema.d.cts.map +1 -0
  367. package/dist/value-to-schema.d.ts +144 -0
  368. package/dist/value-to-schema.d.ts.map +1 -0
  369. package/dist/value-to-schema.js +533 -0
  370. package/dist/value-to-schema.js.map +1 -0
  371. package/package.json +22 -19
  372. package/src/assertion/assertion-types.ts +4 -8
  373. package/src/assertion/assertion.ts +1 -1
  374. package/src/assertion/format-assertion-failure.ts +2 -0
  375. package/src/assertion/impl/assertion-util.ts +1 -2
  376. package/src/assertion/impl/iteration-util.ts +1 -3
  377. package/src/assertion/impl/sync-collection.ts +633 -7
  378. package/src/assertion/impl/sync.ts +27 -0
  379. package/src/error.ts +13 -22
  380. package/src/guards.ts +8 -14
  381. package/src/internal-schema.ts +4 -8
  382. package/src/metadata.ts +1 -2
  383. package/src/snapshot/adapter.ts +2 -3
  384. package/src/snapshot/adapters/fallback.ts +2 -3
  385. package/src/snapshot/adapters/node-test.ts +14 -20
  386. package/src/snapshot/select-adapter.ts +3 -3
  387. package/src/snapshot/serializer.ts +2 -3
  388. package/src/types.ts +2 -162
@@ -0,0 +1,452 @@
1
+ "use strict";
2
+ /**
3
+ * Fallback adapter for frameworks without native snapshot support.
4
+ *
5
+ * This adapter provides custom snapshot storage for test frameworks that don't
6
+ * have built-in snapshot functionality (e.g., Mocha, Tap, custom test
7
+ * runners).
8
+ *
9
+ * **Storage Format:** Snapshots are stored as CommonJS modules in
10
+ * `__snapshots__/` directories:
11
+ *
12
+ * ```javascript
13
+ * // __snapshots__/my-test.test.js.snap.cjs
14
+ * module.exports = {
15
+ * 'test name': '{\n "value": 42\n}',
16
+ * 'test name 2': '"another snapshot"',
17
+ * };
18
+ * ```
19
+ *
20
+ * @packageDocumentation
21
+ */
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.fallbackAdapter = exports.FallbackAdapter = void 0;
27
+ const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
28
+ const node_fs_1 = require("node:fs");
29
+ const node_path_1 = require("node:path");
30
+ const serializer_js_1 = require("../serializer.cjs");
31
+ const { entries } = Object;
32
+ /**
33
+ * Extract snapshot context from Mocha's `this` context.
34
+ *
35
+ * Mocha provides test information through `this.test` in test callbacks. This
36
+ * function attempts to extract the test name and file path from that
37
+ * structure.
38
+ *
39
+ * @example
40
+ *
41
+ * ```typescript
42
+ * describe('suite', function () {
43
+ * it('test', function () {
44
+ * const ctx = extractMochaContext(this);
45
+ * // ctx = {
46
+ * // testPath: 'suite test',
47
+ * // filePath: '/path/to/test.js',
48
+ * // isUpdateMode: false
49
+ * // }
50
+ * });
51
+ * });
52
+ * ```
53
+ *
54
+ * @function
55
+ * @param context - Potential Mocha context object
56
+ * @returns Snapshot context if Mocha context detected, null otherwise
57
+ */
58
+ const extractMochaContext = (context) => {
59
+ const mochaCtx = context;
60
+ if (mochaCtx?.test?.fullTitle) {
61
+ return {
62
+ filePath: mochaCtx.test.file || getTestFilePathFromStack(),
63
+ isUpdateMode: process.env.BUPKIS_UPDATE_SNAPSHOTS === '1',
64
+ testPath: mochaCtx.test.fullTitle(),
65
+ };
66
+ }
67
+ return null;
68
+ };
69
+ /**
70
+ * Get snapshot file path for a test file.
71
+ *
72
+ * Snapshots are stored in a `__snapshots__/` directory next to the test file.
73
+ * The snapshot filename is based on the test file path, with slashes replaced
74
+ * by dashes to create a flat structure.
75
+ *
76
+ * Uses `.cjs` extension for CommonJS compatibility in both CJS and ESM
77
+ * projects.
78
+ *
79
+ * @example
80
+ *
81
+ * ```typescript
82
+ * getSnapshotFilePath('/project/test/unit/foo.test.ts');
83
+ * // Returns: '/project/test/unit/__snapshots__/test-unit-foo.test.ts.snap.cjs'
84
+ * ```
85
+ *
86
+ * @function
87
+ * @param testFilePath - Absolute path to the test file
88
+ * @returns Absolute path to the snapshot file
89
+ */
90
+ const getSnapshotFilePath = (testFilePath) => {
91
+ const dir = (0, node_path_1.dirname)(testFilePath);
92
+ const snapshotDir = (0, node_path_1.join)(dir, '__snapshots__');
93
+ const filename = (0, node_path_1.relative)(process.cwd(), testFilePath).replace(/\//g, '-');
94
+ return (0, node_path_1.join)(snapshotDir, `${filename}.snap.cjs`);
95
+ };
96
+ /**
97
+ * Get test file path from stack trace.
98
+ *
99
+ * Searches the stack trace for lines containing test file paths. Looks for
100
+ * files matching patterns like `*.test.js`, `*.spec.ts`, etc.
101
+ *
102
+ * @function
103
+ * @returns Absolute path to test file, or 'unknown.test.js' if not found
104
+ */
105
+ const getTestFilePathFromStack = () => {
106
+ const stack = new Error().stack || '';
107
+ const lines = stack.split('\n');
108
+ for (const line of lines) {
109
+ // Match file paths in stack traces
110
+ const match = line.match(/\((.+\.(?:test|spec)\.[jt]s):\d+:\d+\)/);
111
+ if (match && match[1]) {
112
+ return (0, node_path_1.resolve)(match[1]);
113
+ }
114
+ }
115
+ return (0, node_path_1.resolve)('unknown.test.js');
116
+ };
117
+ /**
118
+ * Load snapshots from a snapshot file.
119
+ *
120
+ * Reads and parses the CommonJS format snapshot file. If the file doesn't exist
121
+ * or can't be parsed, returns an empty store.
122
+ *
123
+ * **Expected format:**
124
+ *
125
+ * ```javascript
126
+ * module.exports = {
127
+ * 'test name': '{"value": 42}',
128
+ * 'another test': '"string"',
129
+ * };
130
+ * ```
131
+ *
132
+ * @example
133
+ *
134
+ * ```typescript
135
+ * const store = loadSnapshots('/path/to/__snapshots__/test.snap.cjs');
136
+ * console.log(store['my test']); // '{"foo": "bar"}'
137
+ * ```
138
+ *
139
+ * @function
140
+ * @param snapshotPath - Path to the snapshot file
141
+ * @returns Snapshot store (test name → serialized value)
142
+ */
143
+ const loadSnapshots = (snapshotPath) => {
144
+ if (!(0, node_fs_1.existsSync)(snapshotPath)) {
145
+ return {};
146
+ }
147
+ try {
148
+ // Read as CommonJS module
149
+ const content = (0, node_fs_1.readFileSync)(snapshotPath, 'utf-8');
150
+ // Parse the module.exports = { ... } format
151
+ const match = content.match(/module\.exports\s*=\s*(\{[\s\S]*\});?\s*$/);
152
+ if (match) {
153
+ // Use Function constructor to safely eval the object literal
154
+ // This is safe because we're only parsing the object structure,
155
+ // not executing arbitrary code
156
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-call
157
+ const store = new Function(`return ${match[1]}`)();
158
+ return store;
159
+ }
160
+ }
161
+ catch {
162
+ // If parsing fails, return empty store
163
+ // This allows for snapshot regeneration
164
+ }
165
+ return {};
166
+ };
167
+ /**
168
+ * Save snapshots to a snapshot file.
169
+ *
170
+ * Writes the snapshot store to disk in CommonJS format. Creates the
171
+ * `__snapshots__/` directory if it doesn't exist. Entries are sorted
172
+ * alphabetically by test name for consistency.
173
+ *
174
+ * **Output format:**
175
+ *
176
+ * ```javascript
177
+ * module.exports = {
178
+ * 'test 1': '{"value": 1}',
179
+ * 'test 2': '{"value": 2}',
180
+ * };
181
+ * ```
182
+ *
183
+ * @example
184
+ *
185
+ * ```typescript
186
+ * const store = {
187
+ * 'my test': '{"foo": "bar"}',
188
+ * 'another test': '"string"',
189
+ * };
190
+ * saveSnapshots('/path/to/__snapshots__/test.snap.cjs', store);
191
+ * ```
192
+ *
193
+ * @function
194
+ * @param snapshotPath - Path to the snapshot file
195
+ * @param store - Snapshot store to save
196
+ */
197
+ const saveSnapshots = (snapshotPath, store) => {
198
+ const dir = (0, node_path_1.dirname)(snapshotPath);
199
+ // Ensure directory exists
200
+ if (!(0, node_fs_1.existsSync)(dir)) {
201
+ (0, node_fs_1.mkdirSync)(dir, { recursive: true });
202
+ }
203
+ // Generate CommonJS module format with sorted entries
204
+ const snapshotEntries = entries(store)
205
+ .sort(([a], [b]) => a.localeCompare(b))
206
+ .map(([key, value]) => ` ${(0, json_stable_stringify_1.default)(key)}: ${(0, json_stable_stringify_1.default)(value)}`)
207
+ .join(',\n');
208
+ const content = `module.exports = {\n${snapshotEntries}\n};\n`;
209
+ (0, node_fs_1.writeFileSync)(snapshotPath, content, 'utf-8');
210
+ };
211
+ /**
212
+ * Snapshot counters for multiple snapshots per test.
213
+ *
214
+ * Tracks how many snapshots have been taken for each test path to generate
215
+ * unique snapshot names when a test has multiple snapshots.
216
+ */
217
+ const snapshotCounters = new Map();
218
+ /**
219
+ * Fallback adapter for frameworks without native snapshot support.
220
+ *
221
+ * This adapter provides custom snapshot storage and management for test
222
+ * frameworks that don't have built-in snapshot functionality.
223
+ *
224
+ * **Supported Contexts:**
225
+ *
226
+ * - **Mocha**: Pass `this` from test callback
227
+ * - **Explicit names**: Pass a string snapshot name
228
+ *
229
+ * **Storage:**
230
+ *
231
+ * - Snapshots stored in `__snapshots__/*.snap.cjs` files
232
+ * - CommonJS format for compatibility with both CJS and ESM projects
233
+ * - Sorted entries for consistent diffs
234
+ *
235
+ * **Update Mode:**
236
+ *
237
+ * - Controlled by `BUPKIS_UPDATE_SNAPSHOTS=1` environment variable
238
+ *
239
+ * **Features:**
240
+ *
241
+ * - Multiple snapshots per test (automatic counters)
242
+ * - Named snapshots via `hint` option
243
+ * - Circular reference detection
244
+ * - Non-JSON type handling
245
+ *
246
+ * @example
247
+ *
248
+ * ```typescript
249
+ * // Mocha usage
250
+ * describe('MyComponent', function() {
251
+ * it('renders', function() {
252
+ * const output = render(<MyComponent />);
253
+ * expect(output, 'to match snapshot', this);
254
+ * });
255
+ * });
256
+ * ```
257
+ *
258
+ * @example
259
+ *
260
+ * ```typescript
261
+ * // Explicit name (any framework)
262
+ * test('renders component', () => {
263
+ * const output = render(<MyComponent />);
264
+ * expect(output, 'to match snapshot', 'component-default-state');
265
+ * });
266
+ * ```
267
+ *
268
+ * @example
269
+ *
270
+ * ```typescript
271
+ * // Multiple snapshots with hints
272
+ * test('multi-step process', () => {
273
+ * expect(step1(), 'to match snapshot', 'step-1', { hint: 'initial' });
274
+ * expect(step2(), 'to match snapshot', 'step-2', { hint: 'processing' });
275
+ * expect(step3(), 'to match snapshot', 'step-3', { hint: 'complete' });
276
+ * });
277
+ * ```
278
+ *
279
+ * @example
280
+ *
281
+ * ```sh
282
+ * # Update snapshots
283
+ * BUPKIS_UPDATE_SNAPSHOTS=1 npm test
284
+ * ```
285
+ */
286
+ class FallbackAdapter {
287
+ /**
288
+ * Adapter name for identification and debugging.
289
+ */
290
+ name = 'fallback';
291
+ /**
292
+ * Check if this adapter can handle the given context.
293
+ *
294
+ * The fallback adapter accepts both strings (explicit snapshot names) and
295
+ * objects (potential Mocha contexts). It's designed to be the last adapter in
296
+ * the selection chain and will accept most inputs.
297
+ *
298
+ * @param context - Test context or snapshot name
299
+ * @returns `true` for strings or objects
300
+ */
301
+ canHandle = (context) =>
302
+ // Fallback handles strings (explicit names) and objects (Mocha)
303
+ typeof context === 'string' || typeof context === 'object';
304
+ /**
305
+ * Extract snapshot context from Mocha context or string name.
306
+ *
307
+ * **For Mocha contexts:**
308
+ *
309
+ * - Extracts test name from `this.test.fullTitle()`
310
+ * - Gets file path from `this.test.file` or stack trace
311
+ *
312
+ * **For string contexts:**
313
+ *
314
+ * - Uses the string as the test name
315
+ * - Extracts file path from stack trace
316
+ *
317
+ * **Update mode:**
318
+ *
319
+ * - Checks `process.env.BUPKIS_UPDATE_SNAPSHOTS === '1'`
320
+ *
321
+ * @param context - Mocha context or string snapshot name
322
+ * @returns Normalized snapshot context
323
+ * @throws {TypeError} If context is neither a valid Mocha context nor a
324
+ * string
325
+ */
326
+ getContext(context) {
327
+ // Try Mocha first
328
+ const mochaContext = extractMochaContext(context);
329
+ if (mochaContext) {
330
+ return mochaContext;
331
+ }
332
+ // String context (explicit snapshot name)
333
+ if (typeof context === 'string') {
334
+ return {
335
+ filePath: getTestFilePathFromStack(),
336
+ isUpdateMode: process.env.BUPKIS_UPDATE_SNAPSHOTS === '1',
337
+ testPath: context,
338
+ };
339
+ }
340
+ throw new TypeError('Fallback adapter requires either a string snapshot name or Mocha context. ' +
341
+ 'Pass test name as string: expect(value, "to match snapshot", "my-test-name")');
342
+ }
343
+ /**
344
+ * Perform snapshot assertion using custom storage.
345
+ *
346
+ * **Behavior:**
347
+ *
348
+ * - **Update mode**: Creates or updates the snapshot
349
+ * - **Comparison mode**: Loads existing snapshot and compares
350
+ *
351
+ * **Process:**
352
+ *
353
+ * 1. Serialize the value using provided serializer or default
354
+ * 2. Generate unique snapshot name (with counter if needed)
355
+ * 3. Load existing snapshot store from disk
356
+ * 4. Either update snapshot or compare and throw on mismatch
357
+ *
358
+ * @example
359
+ *
360
+ * ```typescript
361
+ * const adapter = new FallbackAdapter();
362
+ *
363
+ * // With Mocha context
364
+ * adapter.assertSnapshot({ foo: 'bar' }, mochaThis);
365
+ *
366
+ * // With explicit name
367
+ * adapter.assertSnapshot({ foo: 'bar' }, 'my-snapshot');
368
+ *
369
+ * // With custom serializer
370
+ * adapter.assertSnapshot(data, 'test', {
371
+ * serializer: (v) => JSON.stringify(v, null, 2),
372
+ * });
373
+ * ```
374
+ *
375
+ * @param value - Value to snapshot
376
+ * @param context - Mocha context or string name
377
+ * @param options - Optional serializer and hint
378
+ * @throws {TypeError} If context is invalid
379
+ * @throws {AssertionError} If snapshot doesn't match (in comparison mode)
380
+ */
381
+ validateSnapshot(value, context, options) {
382
+ const ctx = this.getContext(context);
383
+ const serializer = options?.serializer || serializer_js_1.defaultSerializer;
384
+ const snapshotName = getSnapshotName(ctx.testPath, options?.hint);
385
+ const snapshotPath = getSnapshotFilePath(ctx.filePath);
386
+ const store = loadSnapshots(snapshotPath);
387
+ const actual = serializer(value);
388
+ const expected = store[snapshotName];
389
+ if (ctx.isUpdateMode || expected === undefined) {
390
+ // Update/create snapshot
391
+ store[snapshotName] = actual;
392
+ saveSnapshots(snapshotPath, store);
393
+ return;
394
+ }
395
+ // Compare snapshots
396
+ if (actual !== expected) {
397
+ return {
398
+ actual,
399
+ expected,
400
+ message: `Snapshot mismatch for "${snapshotName}"\n\nExpected:\n${expected}\n\nActual:\n${actual}`,
401
+ };
402
+ }
403
+ }
404
+ }
405
+ exports.FallbackAdapter = FallbackAdapter;
406
+ /**
407
+ * Get the next snapshot name for a test.
408
+ *
409
+ * For the first snapshot in a test, uses the test path as-is. For subsequent
410
+ * snapshots, appends a counter: `"test name 2"`, `"test name 3"`, etc.
411
+ *
412
+ * If a hint is provided, it's appended in brackets: `"test name [hint]"`.
413
+ *
414
+ * @example
415
+ *
416
+ * ```typescript
417
+ * getSnapshotName('MyComponent renders'); // 'MyComponent renders'
418
+ * getSnapshotName('MyComponent renders'); // 'MyComponent renders 2'
419
+ * getSnapshotName('MyComponent renders'); // 'MyComponent renders 3'
420
+ *
421
+ * getSnapshotName('test', 'initial state'); // 'test [initial state]'
422
+ * ```
423
+ *
424
+ * @function
425
+ * @param testPath - Full test path/name
426
+ * @param hint - Optional descriptive hint
427
+ * @returns Unique snapshot name
428
+ */
429
+ const getSnapshotName = (testPath, hint) => {
430
+ if (hint) {
431
+ return `${testPath} [${hint}]`;
432
+ }
433
+ const counter = snapshotCounters.get(testPath) || 0;
434
+ snapshotCounters.set(testPath, counter + 1);
435
+ return counter === 0 ? testPath : `${testPath} ${counter + 1}`;
436
+ };
437
+ /**
438
+ * Singleton instance of the fallback adapter.
439
+ *
440
+ * This is the primary export and should be used for adapter registration.
441
+ *
442
+ * @example
443
+ *
444
+ * ```typescript
445
+ * import { fallbackAdapter } from 'bupkis/snapshot';
446
+ * import { registerAdapter } from 'bupkis/snapshot';
447
+ *
448
+ * registerAdapter(fallbackAdapter);
449
+ * ```
450
+ */
451
+ exports.fallbackAdapter = new FallbackAdapter();
452
+ //# sourceMappingURL=fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../../src/snapshot/adapters/fallback.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,kFAA8C;AAC9C,qCAA6E;AAC7E,yCAA6D;AAS7D,qDAAqD;AAErD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AA0C3B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAA0B,EAAE;IACvE,MAAM,QAAQ,GAAG,OAAuB,CAAC;IAEzC,IAAI,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC9B,OAAO;YACL,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,wBAAwB,EAAE;YAC1D,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,GAAG;YACzD,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE;SACpC,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,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EAAE,CAAC"}
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Fallback adapter for frameworks without native snapshot support.
3
+ *
4
+ * This adapter provides custom snapshot storage for test frameworks that don't
5
+ * have built-in snapshot functionality (e.g., Mocha, Tap, custom test
6
+ * runners).
7
+ *
8
+ * **Storage Format:** Snapshots are stored as CommonJS modules in
9
+ * `__snapshots__/` directories:
10
+ *
11
+ * ```javascript
12
+ * // __snapshots__/my-test.test.js.snap.cjs
13
+ * module.exports = {
14
+ * 'test name': '{\n "value": 42\n}',
15
+ * 'test name 2': '"another snapshot"',
16
+ * };
17
+ * ```
18
+ *
19
+ * @packageDocumentation
20
+ */
21
+ import type { AssertionFailure } from "../../types.cjs";
22
+ import type { SnapshotAdapter, SnapshotContext, SnapshotOptions } from "../adapter.cjs";
23
+ /**
24
+ * Fallback adapter for frameworks without native snapshot support.
25
+ *
26
+ * This adapter provides custom snapshot storage and management for test
27
+ * frameworks that don't have built-in snapshot functionality.
28
+ *
29
+ * **Supported Contexts:**
30
+ *
31
+ * - **Mocha**: Pass `this` from test callback
32
+ * - **Explicit names**: Pass a string snapshot name
33
+ *
34
+ * **Storage:**
35
+ *
36
+ * - Snapshots stored in `__snapshots__/*.snap.cjs` files
37
+ * - CommonJS format for compatibility with both CJS and ESM projects
38
+ * - Sorted entries for consistent diffs
39
+ *
40
+ * **Update Mode:**
41
+ *
42
+ * - Controlled by `BUPKIS_UPDATE_SNAPSHOTS=1` environment variable
43
+ *
44
+ * **Features:**
45
+ *
46
+ * - Multiple snapshots per test (automatic counters)
47
+ * - Named snapshots via `hint` option
48
+ * - Circular reference detection
49
+ * - Non-JSON type handling
50
+ *
51
+ * @example
52
+ *
53
+ * ```typescript
54
+ * // Mocha usage
55
+ * describe('MyComponent', function() {
56
+ * it('renders', function() {
57
+ * const output = render(<MyComponent />);
58
+ * expect(output, 'to match snapshot', this);
59
+ * });
60
+ * });
61
+ * ```
62
+ *
63
+ * @example
64
+ *
65
+ * ```typescript
66
+ * // Explicit name (any framework)
67
+ * test('renders component', () => {
68
+ * const output = render(<MyComponent />);
69
+ * expect(output, 'to match snapshot', 'component-default-state');
70
+ * });
71
+ * ```
72
+ *
73
+ * @example
74
+ *
75
+ * ```typescript
76
+ * // Multiple snapshots with hints
77
+ * test('multi-step process', () => {
78
+ * expect(step1(), 'to match snapshot', 'step-1', { hint: 'initial' });
79
+ * expect(step2(), 'to match snapshot', 'step-2', { hint: 'processing' });
80
+ * expect(step3(), 'to match snapshot', 'step-3', { hint: 'complete' });
81
+ * });
82
+ * ```
83
+ *
84
+ * @example
85
+ *
86
+ * ```sh
87
+ * # Update snapshots
88
+ * BUPKIS_UPDATE_SNAPSHOTS=1 npm test
89
+ * ```
90
+ */
91
+ export declare class FallbackAdapter implements SnapshotAdapter {
92
+ /**
93
+ * Adapter name for identification and debugging.
94
+ */
95
+ readonly name = "fallback";
96
+ /**
97
+ * Check if this adapter can handle the given context.
98
+ *
99
+ * The fallback adapter accepts both strings (explicit snapshot names) and
100
+ * objects (potential Mocha contexts). It's designed to be the last adapter in
101
+ * the selection chain and will accept most inputs.
102
+ *
103
+ * @param context - Test context or snapshot name
104
+ * @returns `true` for strings or objects
105
+ */
106
+ canHandle: (context: unknown) => boolean;
107
+ /**
108
+ * Extract snapshot context from Mocha context or string name.
109
+ *
110
+ * **For Mocha contexts:**
111
+ *
112
+ * - Extracts test name from `this.test.fullTitle()`
113
+ * - Gets file path from `this.test.file` or stack trace
114
+ *
115
+ * **For string contexts:**
116
+ *
117
+ * - Uses the string as the test name
118
+ * - Extracts file path from stack trace
119
+ *
120
+ * **Update mode:**
121
+ *
122
+ * - Checks `process.env.BUPKIS_UPDATE_SNAPSHOTS === '1'`
123
+ *
124
+ * @param context - Mocha context or string snapshot name
125
+ * @returns Normalized snapshot context
126
+ * @throws {TypeError} If context is neither a valid Mocha context nor a
127
+ * string
128
+ */
129
+ getContext(context: unknown): SnapshotContext;
130
+ /**
131
+ * Perform snapshot assertion using custom storage.
132
+ *
133
+ * **Behavior:**
134
+ *
135
+ * - **Update mode**: Creates or updates the snapshot
136
+ * - **Comparison mode**: Loads existing snapshot and compares
137
+ *
138
+ * **Process:**
139
+ *
140
+ * 1. Serialize the value using provided serializer or default
141
+ * 2. Generate unique snapshot name (with counter if needed)
142
+ * 3. Load existing snapshot store from disk
143
+ * 4. Either update snapshot or compare and throw on mismatch
144
+ *
145
+ * @example
146
+ *
147
+ * ```typescript
148
+ * const adapter = new FallbackAdapter();
149
+ *
150
+ * // With Mocha context
151
+ * adapter.assertSnapshot({ foo: 'bar' }, mochaThis);
152
+ *
153
+ * // With explicit name
154
+ * adapter.assertSnapshot({ foo: 'bar' }, 'my-snapshot');
155
+ *
156
+ * // With custom serializer
157
+ * adapter.assertSnapshot(data, 'test', {
158
+ * serializer: (v) => JSON.stringify(v, null, 2),
159
+ * });
160
+ * ```
161
+ *
162
+ * @param value - Value to snapshot
163
+ * @param context - Mocha context or string name
164
+ * @param options - Optional serializer and hint
165
+ * @throws {TypeError} If context is invalid
166
+ * @throws {AssertionError} If snapshot doesn't match (in comparison mode)
167
+ */
168
+ validateSnapshot(value: unknown, context: unknown, options?: SnapshotOptions): AssertionFailure | void;
169
+ }
170
+ /**
171
+ * Singleton instance of the fallback adapter.
172
+ *
173
+ * This is the primary export and should be used for adapter registration.
174
+ *
175
+ * @example
176
+ *
177
+ * ```typescript
178
+ * import { fallbackAdapter } from 'bupkis/snapshot';
179
+ * import { registerAdapter } from 'bupkis/snapshot';
180
+ *
181
+ * registerAdapter(fallbackAdapter);
182
+ * ```
183
+ */
184
+ export declare const fallbackAdapter: FallbackAdapter;
185
+ //# sourceMappingURL=fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../../src/snapshot/adapters/fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAuB;AACvD,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,eAAe,EAChB,uBAAsB;AAwPvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,qBAAa,eAAgB,YAAW,eAAe;IACrD;;OAEG;IACH,QAAQ,CAAC,IAAI,cAAc;IAE3B;;;;;;;;;OASG;IACH,SAAS,GAAI,SAAS,OAAO,KAAG,OAAO,CAEsB;IAE7D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe;IAsB7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,gBAAgB,CACd,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,eAAe,GACxB,gBAAgB,GAAG,IAAI;CA2B3B;AAoCD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,iBAAwB,CAAC"}