bupkis 0.18.0 → 0.18.2
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.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -4
- package/src/assertion/assertion-types.ts +4 -4
- package/src/assertion/impl/async-parametric.ts +4 -21
- package/src/assertion/impl/sync-parametric.ts +5 -17
- package/src/expect.ts +0 -4
- package/src/guards.ts +24 -24
- package/src/internal-schema.ts +16 -32
- package/src/value-to-schema.ts +1 -1
- package/dist/assertion/assertion-async.cjs +0 -268
- package/dist/assertion/assertion-async.cjs.map +0 -1
- package/dist/assertion/assertion-async.d.cts +0 -40
- package/dist/assertion/assertion-async.d.cts.map +0 -1
- package/dist/assertion/assertion-async.d.ts +0 -40
- package/dist/assertion/assertion-async.d.ts.map +0 -1
- package/dist/assertion/assertion-async.js +0 -259
- package/dist/assertion/assertion-async.js.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.cjs +0 -132
- package/dist/assertion/assertion-standard-schema-async.cjs.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.d.cts +0 -52
- package/dist/assertion/assertion-standard-schema-async.d.cts.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.d.ts +0 -52
- package/dist/assertion/assertion-standard-schema-async.d.ts.map +0 -1
- package/dist/assertion/assertion-standard-schema-async.js +0 -128
- package/dist/assertion/assertion-standard-schema-async.js.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.cjs +0 -141
- package/dist/assertion/assertion-standard-schema-sync.cjs.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.d.cts +0 -52
- package/dist/assertion/assertion-standard-schema-sync.d.cts.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.d.ts +0 -52
- package/dist/assertion/assertion-standard-schema-sync.d.ts.map +0 -1
- package/dist/assertion/assertion-standard-schema-sync.js +0 -137
- package/dist/assertion/assertion-standard-schema-sync.js.map +0 -1
- package/dist/assertion/assertion-sync.cjs +0 -284
- package/dist/assertion/assertion-sync.cjs.map +0 -1
- package/dist/assertion/assertion-sync.d.cts +0 -60
- package/dist/assertion/assertion-sync.d.cts.map +0 -1
- package/dist/assertion/assertion-sync.d.ts +0 -60
- package/dist/assertion/assertion-sync.d.ts.map +0 -1
- package/dist/assertion/assertion-sync.js +0 -275
- package/dist/assertion/assertion-sync.js.map +0 -1
- package/dist/assertion/assertion-types.cjs +0 -20
- package/dist/assertion/assertion-types.cjs.map +0 -1
- package/dist/assertion/assertion-types.d.cts +0 -1086
- package/dist/assertion/assertion-types.d.cts.map +0 -1
- package/dist/assertion/assertion-types.d.ts +0 -1086
- package/dist/assertion/assertion-types.d.ts.map +0 -1
- package/dist/assertion/assertion-types.js +0 -19
- package/dist/assertion/assertion-types.js.map +0 -1
- package/dist/assertion/assertion.cjs +0 -382
- package/dist/assertion/assertion.cjs.map +0 -1
- package/dist/assertion/assertion.d.cts +0 -109
- package/dist/assertion/assertion.d.cts.map +0 -1
- package/dist/assertion/assertion.d.ts +0 -109
- package/dist/assertion/assertion.d.ts.map +0 -1
- package/dist/assertion/assertion.js +0 -375
- package/dist/assertion/assertion.js.map +0 -1
- package/dist/assertion/create.cjs +0 -148
- package/dist/assertion/create.cjs.map +0 -1
- package/dist/assertion/create.d.cts +0 -85
- package/dist/assertion/create.d.cts.map +0 -1
- package/dist/assertion/create.d.ts +0 -85
- package/dist/assertion/create.d.ts.map +0 -1
- package/dist/assertion/create.js +0 -143
- package/dist/assertion/create.js.map +0 -1
- package/dist/assertion/format-assertion-failure.cjs +0 -63
- package/dist/assertion/format-assertion-failure.cjs.map +0 -1
- package/dist/assertion/format-assertion-failure.d.cts +0 -21
- package/dist/assertion/format-assertion-failure.d.cts.map +0 -1
- package/dist/assertion/format-assertion-failure.d.ts +0 -21
- package/dist/assertion/format-assertion-failure.d.ts.map +0 -1
- package/dist/assertion/format-assertion-failure.js +0 -59
- package/dist/assertion/format-assertion-failure.js.map +0 -1
- package/dist/assertion/impl/assertion-util.cjs +0 -68
- package/dist/assertion/impl/assertion-util.cjs.map +0 -1
- package/dist/assertion/impl/assertion-util.d.cts +0 -36
- package/dist/assertion/impl/assertion-util.d.cts.map +0 -1
- package/dist/assertion/impl/assertion-util.d.ts +0 -36
- package/dist/assertion/impl/assertion-util.d.ts.map +0 -1
- package/dist/assertion/impl/assertion-util.js +0 -62
- package/dist/assertion/impl/assertion-util.js.map +0 -1
- package/dist/assertion/impl/async-iterable.cjs +0 -627
- package/dist/assertion/impl/async-iterable.cjs.map +0 -1
- package/dist/assertion/impl/async-iterable.d.cts +0 -406
- package/dist/assertion/impl/async-iterable.d.cts.map +0 -1
- package/dist/assertion/impl/async-iterable.d.ts +0 -406
- package/dist/assertion/impl/async-iterable.d.ts.map +0 -1
- package/dist/assertion/impl/async-iterable.js +0 -624
- package/dist/assertion/impl/async-iterable.js.map +0 -1
- package/dist/assertion/impl/async-parametric.cjs +0 -423
- package/dist/assertion/impl/async-parametric.cjs.map +0 -1
- package/dist/assertion/impl/async-parametric.d.cts +0 -278
- package/dist/assertion/impl/async-parametric.d.cts.map +0 -1
- package/dist/assertion/impl/async-parametric.d.ts +0 -278
- package/dist/assertion/impl/async-parametric.d.ts.map +0 -1
- package/dist/assertion/impl/async-parametric.js +0 -420
- package/dist/assertion/impl/async-parametric.js.map +0 -1
- package/dist/assertion/impl/async.cjs +0 -56
- package/dist/assertion/impl/async.cjs.map +0 -1
- package/dist/assertion/impl/async.d.cts +0 -179
- package/dist/assertion/impl/async.d.cts.map +0 -1
- package/dist/assertion/impl/async.d.ts +0 -179
- package/dist/assertion/impl/async.d.ts.map +0 -1
- package/dist/assertion/impl/async.js +0 -39
- package/dist/assertion/impl/async.js.map +0 -1
- package/dist/assertion/impl/index.cjs +0 -37
- package/dist/assertion/impl/index.cjs.map +0 -1
- package/dist/assertion/impl/index.d.cts +0 -21
- package/dist/assertion/impl/index.d.cts.map +0 -1
- package/dist/assertion/impl/index.d.ts +0 -21
- package/dist/assertion/impl/index.d.ts.map +0 -1
- package/dist/assertion/impl/index.js +0 -21
- package/dist/assertion/impl/index.js.map +0 -1
- package/dist/assertion/impl/iteration-util.cjs +0 -297
- package/dist/assertion/impl/iteration-util.cjs.map +0 -1
- package/dist/assertion/impl/iteration-util.d.cts +0 -12
- package/dist/assertion/impl/iteration-util.d.cts.map +0 -1
- package/dist/assertion/impl/iteration-util.d.ts +0 -12
- package/dist/assertion/impl/iteration-util.d.ts.map +0 -1
- package/dist/assertion/impl/iteration-util.js +0 -282
- package/dist/assertion/impl/iteration-util.js.map +0 -1
- package/dist/assertion/impl/snapshot.cjs +0 -276
- package/dist/assertion/impl/snapshot.cjs.map +0 -1
- package/dist/assertion/impl/snapshot.d.cts +0 -278
- package/dist/assertion/impl/snapshot.d.cts.map +0 -1
- package/dist/assertion/impl/snapshot.d.ts +0 -278
- package/dist/assertion/impl/snapshot.d.ts.map +0 -1
- package/dist/assertion/impl/snapshot.js +0 -273
- package/dist/assertion/impl/snapshot.js.map +0 -1
- package/dist/assertion/impl/sync-basic.cjs +0 -553
- package/dist/assertion/impl/sync-basic.cjs.map +0 -1
- package/dist/assertion/impl/sync-basic.d.cts +0 -528
- package/dist/assertion/impl/sync-basic.d.cts.map +0 -1
- package/dist/assertion/impl/sync-basic.d.ts +0 -528
- package/dist/assertion/impl/sync-basic.d.ts.map +0 -1
- package/dist/assertion/impl/sync-basic.js +0 -550
- package/dist/assertion/impl/sync-basic.js.map +0 -1
- package/dist/assertion/impl/sync-collection.cjs +0 -856
- package/dist/assertion/impl/sync-collection.cjs.map +0 -1
- package/dist/assertion/impl/sync-collection.d.cts +0 -607
- package/dist/assertion/impl/sync-collection.d.cts.map +0 -1
- package/dist/assertion/impl/sync-collection.d.ts +0 -607
- package/dist/assertion/impl/sync-collection.d.ts.map +0 -1
- package/dist/assertion/impl/sync-collection.js +0 -850
- package/dist/assertion/impl/sync-collection.js.map +0 -1
- package/dist/assertion/impl/sync-date.cjs +0 -341
- package/dist/assertion/impl/sync-date.cjs.map +0 -1
- package/dist/assertion/impl/sync-date.d.cts +0 -209
- package/dist/assertion/impl/sync-date.d.cts.map +0 -1
- package/dist/assertion/impl/sync-date.d.ts +0 -209
- package/dist/assertion/impl/sync-date.d.ts.map +0 -1
- package/dist/assertion/impl/sync-date.js +0 -338
- package/dist/assertion/impl/sync-date.js.map +0 -1
- package/dist/assertion/impl/sync-esoteric.cjs +0 -214
- package/dist/assertion/impl/sync-esoteric.cjs.map +0 -1
- package/dist/assertion/impl/sync-esoteric.d.cts +0 -191
- package/dist/assertion/impl/sync-esoteric.d.cts.map +0 -1
- package/dist/assertion/impl/sync-esoteric.d.ts +0 -191
- package/dist/assertion/impl/sync-esoteric.d.ts.map +0 -1
- package/dist/assertion/impl/sync-esoteric.js +0 -211
- package/dist/assertion/impl/sync-esoteric.js.map +0 -1
- package/dist/assertion/impl/sync-iterable.cjs +0 -512
- package/dist/assertion/impl/sync-iterable.cjs.map +0 -1
- package/dist/assertion/impl/sync-iterable.d.cts +0 -334
- package/dist/assertion/impl/sync-iterable.d.cts.map +0 -1
- package/dist/assertion/impl/sync-iterable.d.ts +0 -334
- package/dist/assertion/impl/sync-iterable.d.ts.map +0 -1
- package/dist/assertion/impl/sync-iterable.js +0 -509
- package/dist/assertion/impl/sync-iterable.js.map +0 -1
- package/dist/assertion/impl/sync-parametric.cjs +0 -812
- package/dist/assertion/impl/sync-parametric.cjs.map +0 -1
- package/dist/assertion/impl/sync-parametric.d.cts +0 -560
- package/dist/assertion/impl/sync-parametric.d.cts.map +0 -1
- package/dist/assertion/impl/sync-parametric.d.ts +0 -560
- package/dist/assertion/impl/sync-parametric.d.ts.map +0 -1
- package/dist/assertion/impl/sync-parametric.js +0 -809
- package/dist/assertion/impl/sync-parametric.js.map +0 -1
- package/dist/assertion/impl/sync.cjs +0 -214
- package/dist/assertion/impl/sync.cjs.map +0 -1
- package/dist/assertion/impl/sync.d.cts +0 -512
- package/dist/assertion/impl/sync.d.cts.map +0 -1
- package/dist/assertion/impl/sync.d.ts +0 -512
- package/dist/assertion/impl/sync.d.ts.map +0 -1
- package/dist/assertion/impl/sync.js +0 -197
- package/dist/assertion/impl/sync.js.map +0 -1
- package/dist/assertion/index.cjs +0 -38
- package/dist/assertion/index.cjs.map +0 -1
- package/dist/assertion/index.d.cts +0 -18
- package/dist/assertion/index.d.cts.map +0 -1
- package/dist/assertion/index.d.ts +0 -18
- package/dist/assertion/index.d.ts.map +0 -1
- package/dist/assertion/index.js +0 -17
- package/dist/assertion/index.js.map +0 -1
- package/dist/assertion/slotify.cjs +0 -165
- package/dist/assertion/slotify.cjs.map +0 -1
- package/dist/assertion/slotify.d.cts +0 -11
- package/dist/assertion/slotify.d.cts.map +0 -1
- package/dist/assertion/slotify.d.ts +0 -11
- package/dist/assertion/slotify.d.ts.map +0 -1
- package/dist/assertion/slotify.js +0 -161
- package/dist/assertion/slotify.js.map +0 -1
- package/dist/bootstrap.cjs +0 -43
- package/dist/bootstrap.cjs.map +0 -1
- package/dist/bootstrap.d.cts +0 -27
- package/dist/bootstrap.d.cts.map +0 -1
- package/dist/bootstrap.d.ts +0 -27
- package/dist/bootstrap.d.ts.map +0 -1
- package/dist/bootstrap.js +0 -40
- package/dist/bootstrap.js.map +0 -1
- package/dist/constant.cjs +0 -82
- package/dist/constant.cjs.map +0 -1
- package/dist/constant.d.cts +0 -69
- package/dist/constant.d.cts.map +0 -1
- package/dist/constant.d.ts +0 -69
- package/dist/constant.d.ts.map +0 -1
- package/dist/constant.js +0 -79
- package/dist/constant.js.map +0 -1
- package/dist/diff.cjs +0 -340
- package/dist/diff.cjs.map +0 -1
- package/dist/diff.d.cts +0 -51
- package/dist/diff.d.cts.map +0 -1
- package/dist/diff.d.ts +0 -51
- package/dist/diff.d.ts.map +0 -1
- package/dist/diff.js +0 -334
- package/dist/diff.js.map +0 -1
- package/dist/error.cjs +0 -204
- package/dist/error.cjs.map +0 -1
- package/dist/error.d.cts +0 -212
- package/dist/error.d.cts.map +0 -1
- package/dist/error.d.ts +0 -212
- package/dist/error.d.ts.map +0 -1
- package/dist/error.js +0 -191
- package/dist/error.js.map +0 -1
- package/dist/expect.cjs +0 -590
- package/dist/expect.cjs.map +0 -1
- package/dist/expect.d.cts +0 -138
- package/dist/expect.d.cts.map +0 -1
- package/dist/expect.d.ts +0 -138
- package/dist/expect.d.ts.map +0 -1
- package/dist/expect.js +0 -582
- package/dist/expect.js.map +0 -1
- package/dist/guards.cjs +0 -297
- package/dist/guards.cjs.map +0 -1
- package/dist/guards.d.cts +0 -231
- package/dist/guards.d.cts.map +0 -1
- package/dist/guards.d.ts +0 -231
- package/dist/guards.d.ts.map +0 -1
- package/dist/guards.js +0 -277
- package/dist/guards.js.map +0 -1
- package/dist/index.cjs +0 -111
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -448
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts +0 -448
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -71
- package/dist/index.js.map +0 -1
- package/dist/internal-schema.cjs +0 -253
- package/dist/internal-schema.cjs.map +0 -1
- package/dist/internal-schema.d.cts +0 -8
- package/dist/internal-schema.d.cts.map +0 -1
- package/dist/internal-schema.d.ts +0 -8
- package/dist/internal-schema.d.ts.map +0 -1
- package/dist/internal-schema.js +0 -248
- package/dist/internal-schema.js.map +0 -1
- package/dist/metadata.cjs +0 -57
- package/dist/metadata.cjs.map +0 -1
- package/dist/metadata.d.cts +0 -27
- package/dist/metadata.d.cts.map +0 -1
- package/dist/metadata.d.ts +0 -27
- package/dist/metadata.d.ts.map +0 -1
- package/dist/metadata.js +0 -54
- package/dist/metadata.js.map +0 -1
- package/dist/schema.cjs +0 -1522
- package/dist/schema.cjs.map +0 -1
- package/dist/schema.d.cts +0 -1196
- package/dist/schema.d.cts.map +0 -1
- package/dist/schema.d.ts +0 -1196
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -1516
- package/dist/schema.js.map +0 -1
- package/dist/snapshot/adapter.cjs +0 -31
- package/dist/snapshot/adapter.cjs.map +0 -1
- package/dist/snapshot/adapter.d.cts +0 -258
- package/dist/snapshot/adapter.d.cts.map +0 -1
- package/dist/snapshot/adapter.d.ts +0 -258
- package/dist/snapshot/adapter.d.ts.map +0 -1
- package/dist/snapshot/adapter.js +0 -27
- package/dist/snapshot/adapter.js.map +0 -1
- package/dist/snapshot/adapters/fallback.cjs +0 -453
- package/dist/snapshot/adapters/fallback.cjs.map +0 -1
- package/dist/snapshot/adapters/fallback.d.cts +0 -185
- package/dist/snapshot/adapters/fallback.d.cts.map +0 -1
- package/dist/snapshot/adapters/fallback.d.ts +0 -185
- package/dist/snapshot/adapters/fallback.d.ts.map +0 -1
- package/dist/snapshot/adapters/fallback.js +0 -446
- package/dist/snapshot/adapters/fallback.js.map +0 -1
- package/dist/snapshot/adapters/node-test.cjs +0 -301
- package/dist/snapshot/adapters/node-test.cjs.map +0 -1
- package/dist/snapshot/adapters/node-test.d.cts +0 -131
- package/dist/snapshot/adapters/node-test.d.cts.map +0 -1
- package/dist/snapshot/adapters/node-test.d.ts +0 -131
- package/dist/snapshot/adapters/node-test.d.ts.map +0 -1
- package/dist/snapshot/adapters/node-test.js +0 -297
- package/dist/snapshot/adapters/node-test.js.map +0 -1
- package/dist/snapshot/index.cjs +0 -61
- package/dist/snapshot/index.cjs.map +0 -1
- package/dist/snapshot/index.d.cts +0 -40
- package/dist/snapshot/index.d.cts.map +0 -1
- package/dist/snapshot/index.d.ts +0 -40
- package/dist/snapshot/index.d.ts.map +0 -1
- package/dist/snapshot/index.js +0 -44
- package/dist/snapshot/index.js.map +0 -1
- package/dist/snapshot/node-version.cjs +0 -49
- package/dist/snapshot/node-version.cjs.map +0 -1
- package/dist/snapshot/node-version.d.cts +0 -34
- package/dist/snapshot/node-version.d.cts.map +0 -1
- package/dist/snapshot/node-version.d.ts +0 -34
- package/dist/snapshot/node-version.d.ts.map +0 -1
- package/dist/snapshot/node-version.js +0 -44
- package/dist/snapshot/node-version.js.map +0 -1
- package/dist/snapshot/select-adapter.cjs +0 -170
- package/dist/snapshot/select-adapter.cjs.map +0 -1
- package/dist/snapshot/select-adapter.d.cts +0 -128
- package/dist/snapshot/select-adapter.d.cts.map +0 -1
- package/dist/snapshot/select-adapter.d.ts +0 -128
- package/dist/snapshot/select-adapter.d.ts.map +0 -1
- package/dist/snapshot/select-adapter.js +0 -164
- package/dist/snapshot/select-adapter.js.map +0 -1
- package/dist/snapshot/serializer.cjs +0 -246
- package/dist/snapshot/serializer.cjs.map +0 -1
- package/dist/snapshot/serializer.d.cts +0 -126
- package/dist/snapshot/serializer.d.cts.map +0 -1
- package/dist/snapshot/serializer.d.ts +0 -126
- package/dist/snapshot/serializer.d.ts.map +0 -1
- package/dist/snapshot/serializer.js +0 -238
- package/dist/snapshot/serializer.js.map +0 -1
- package/dist/standard-schema.cjs +0 -13
- package/dist/standard-schema.cjs.map +0 -1
- package/dist/standard-schema.d.cts +0 -192
- package/dist/standard-schema.d.cts.map +0 -1
- package/dist/standard-schema.d.ts +0 -192
- package/dist/standard-schema.d.ts.map +0 -1
- package/dist/standard-schema.js +0 -12
- package/dist/standard-schema.js.map +0 -1
- package/dist/types.cjs +0 -22
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.cts +0 -905
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.ts +0 -905
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -21
- package/dist/types.js.map +0 -1
- package/dist/use.cjs +0 -240
- package/dist/use.cjs.map +0 -1
- package/dist/use.d.cts +0 -8
- package/dist/use.d.cts.map +0 -1
- package/dist/use.d.ts +0 -8
- package/dist/use.d.ts.map +0 -1
- package/dist/use.js +0 -236
- package/dist/use.js.map +0 -1
- package/dist/util.cjs +0 -255
- package/dist/util.cjs.map +0 -1
- package/dist/util.d.cts +0 -141
- package/dist/util.d.cts.map +0 -1
- package/dist/util.d.ts +0 -141
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -234
- package/dist/util.js.map +0 -1
- package/dist/value-to-schema.cjs +0 -537
- package/dist/value-to-schema.cjs.map +0 -1
- package/dist/value-to-schema.d.cts +0 -144
- package/dist/value-to-schema.d.cts.map +0 -1
- package/dist/value-to-schema.d.ts +0 -144
- package/dist/value-to-schema.d.ts.map +0 -1
- package/dist/value-to-schema.js +0 -533
- package/dist/value-to-schema.js.map +0 -1
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Adapter for node:test's built-in snapshot support.
|
|
4
|
-
*
|
|
5
|
-
* Node.js native test runner includes snapshot testing capabilities as of
|
|
6
|
-
* Node.js v22. This adapter delegates to node:test's native `assert.snapshot()`
|
|
7
|
-
* function while providing the unified BUPKIS snapshot interface.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
* @see https://nodejs.org/api/test.html#snapshots
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.nodeTestAdapter = exports.NodeTestAdapter = void 0;
|
|
14
|
-
const node_assert_1 = require("node:assert");
|
|
15
|
-
const node_util_1 = require("node:util");
|
|
16
|
-
const guards_js_1 = require("../../guards.cjs");
|
|
17
|
-
const adapter_js_1 = require("../adapter.cjs");
|
|
18
|
-
const node_version_js_1 = require("../node-version.cjs");
|
|
19
|
-
const serializer_js_1 = require("../serializer.cjs");
|
|
20
|
-
/**
|
|
21
|
-
* Adapter for node:test snapshot support.
|
|
22
|
-
*
|
|
23
|
-
* This adapter leverages node:test's native snapshot functionality while
|
|
24
|
-
* providing the unified BUPKIS snapshot interface. It's the preferred adapter
|
|
25
|
-
* when running tests with node:test.
|
|
26
|
-
*
|
|
27
|
-
* **Features:**
|
|
28
|
-
*
|
|
29
|
-
* - Delegates to native `assert.snapshot()`
|
|
30
|
-
* - Supports custom serializers
|
|
31
|
-
* - Automatically detects update mode from CLI flags
|
|
32
|
-
* - Zero configuration required
|
|
33
|
-
*
|
|
34
|
-
* **Detection:** The adapter detects node:test by checking for
|
|
35
|
-
* `context.assert.snapshot`.
|
|
36
|
-
*
|
|
37
|
-
* **Update Mode:** Respects the `--test-update-snapshots` flag.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
*
|
|
41
|
-
* ```typescript
|
|
42
|
-
* import test from 'node:test';
|
|
43
|
-
* import { expect } from 'bupkis';
|
|
44
|
-
*
|
|
45
|
-
* test('renders component', (t) => {
|
|
46
|
-
* const output = render(<MyComponent />);
|
|
47
|
-
* expect(output, 'to match snapshot', t);
|
|
48
|
-
* });
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
*
|
|
53
|
-
* ```typescript
|
|
54
|
-
* // With custom serializer
|
|
55
|
-
* test('redacts secrets', (t) => {
|
|
56
|
-
* const data = { public: 'visible', secret: 'password123' };
|
|
57
|
-
* expect(data, 'to match snapshot', t, {
|
|
58
|
-
* serializer: (value: any) =>
|
|
59
|
-
* JSON.stringify({ ...value, secret: '[REDACTED]' }, null, 2),
|
|
60
|
-
* });
|
|
61
|
-
* });
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
class NodeTestAdapter {
|
|
65
|
-
/**
|
|
66
|
-
* Adapter name for identification and debugging.
|
|
67
|
-
*/
|
|
68
|
-
name = 'node:test';
|
|
69
|
-
/**
|
|
70
|
-
* Check if this adapter can handle the given context.
|
|
71
|
-
*
|
|
72
|
-
* Returns `true` if the context has the structure of a node:test context,
|
|
73
|
-
* specifically checking for `context.assert.snapshot`.
|
|
74
|
-
*
|
|
75
|
-
* @param context - Test context to check
|
|
76
|
-
* @returns `true` if this is a node:test context
|
|
77
|
-
* @throws {Error} If running on Node.js < 22 with a node:test context
|
|
78
|
-
*/
|
|
79
|
-
canHandle(context) {
|
|
80
|
-
if (looksLikeNodeTestContext(context) && !isNodeTestContext(context)) {
|
|
81
|
-
(0, node_version_js_1.assertNodeVersion)();
|
|
82
|
-
}
|
|
83
|
-
return isNodeTestContext(context);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Extract snapshot context from node:test context.
|
|
87
|
-
*
|
|
88
|
-
* Extracts:
|
|
89
|
-
*
|
|
90
|
-
* - **testPath**: The test name from `context.name`
|
|
91
|
-
* - **filePath**: Extracted from stack trace
|
|
92
|
-
* - **isUpdateMode**: Detected from `--test-update-snapshots` flag
|
|
93
|
-
*
|
|
94
|
-
* @param context - Node:test context object
|
|
95
|
-
* @returns Normalized snapshot context
|
|
96
|
-
* @throws {TypeError} If context is not a valid node:test context
|
|
97
|
-
*/
|
|
98
|
-
getContext(context) {
|
|
99
|
-
if (!isNodeTestContext(context)) {
|
|
100
|
-
throw new TypeError('Invalid node:test context');
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
filePath: getTestFilePathFromStack(),
|
|
104
|
-
isUpdateMode: isNodeTestUpdateMode(),
|
|
105
|
-
testPath: context.name,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Perform snapshot assertion using node:test's native functionality.
|
|
110
|
-
*
|
|
111
|
-
* This method delegates to `context.assert.snapshot()`, which handles:
|
|
112
|
-
*
|
|
113
|
-
* - Snapshot file creation and management
|
|
114
|
-
* - Snapshot comparison
|
|
115
|
-
* - Update mode behavior
|
|
116
|
-
* - Error messages and diffs
|
|
117
|
-
*
|
|
118
|
-
* If a custom serializer is provided in options, it will be passed to
|
|
119
|
-
* node:test as a serializer function.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
*
|
|
123
|
-
* ```typescript
|
|
124
|
-
* const adapter = new NodeTestAdapter();
|
|
125
|
-
* adapter.assertSnapshot({ foo: 'bar' }, testContext);
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* @param value - Value to snapshot
|
|
129
|
-
* @param context - Node:test context object
|
|
130
|
-
* @param options - Optional serialization options
|
|
131
|
-
* @throws {TypeError} If context is not a valid node:test context
|
|
132
|
-
* @throws {AssertionError} If snapshot doesn't match (via node:test)
|
|
133
|
-
*/
|
|
134
|
-
validateSnapshot(value, context, options) {
|
|
135
|
-
if (!isNodeTestContext(context)) {
|
|
136
|
-
throw new TypeError('Invalid node:test context');
|
|
137
|
-
}
|
|
138
|
-
// Use custom serializer if provided, otherwise use default serializer
|
|
139
|
-
// to handle circular references and special types
|
|
140
|
-
const serializers = options?.serializer
|
|
141
|
-
? [options.serializer]
|
|
142
|
-
: [serializer_js_1.defaultSerializer];
|
|
143
|
-
try {
|
|
144
|
-
// Build snapshot options - include hint as name if provided
|
|
145
|
-
const snapshotOptions = { serializers };
|
|
146
|
-
if (options?.hint) {
|
|
147
|
-
snapshotOptions.name = options.hint;
|
|
148
|
-
}
|
|
149
|
-
context.assert.snapshot(value, snapshotOptions);
|
|
150
|
-
}
|
|
151
|
-
catch (err) {
|
|
152
|
-
if (isNodeAssertionError(err)) {
|
|
153
|
-
return {
|
|
154
|
-
actual: err.actual,
|
|
155
|
-
expected: err.expected,
|
|
156
|
-
message: err.message,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
if ((0, guards_js_1.isError)(err)) {
|
|
160
|
-
return {
|
|
161
|
-
message: err.message,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
message: (0, node_util_1.inspect)(err),
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
exports.NodeTestAdapter = NodeTestAdapter;
|
|
171
|
-
/**
|
|
172
|
-
* Extract the test file path from the stack trace.
|
|
173
|
-
*
|
|
174
|
-
* This is a fallback method used when the test context doesn't provide the file
|
|
175
|
-
* path directly. It searches the stack trace for lines that look like test file
|
|
176
|
-
* paths (containing `.test.` or `.spec.`).
|
|
177
|
-
*
|
|
178
|
-
* @example
|
|
179
|
-
*
|
|
180
|
-
* ```typescript
|
|
181
|
-
* // If called from /path/to/my.test.ts, returns '/path/to/my.test.ts'
|
|
182
|
-
* const filePath = getTestFilePathFromStack();
|
|
183
|
-
* ```
|
|
184
|
-
*
|
|
185
|
-
* @function
|
|
186
|
-
* @returns Absolute file path, or 'unknown' if not found
|
|
187
|
-
*/
|
|
188
|
-
const getTestFilePathFromStack = () => {
|
|
189
|
-
const stack = new Error().stack || '';
|
|
190
|
-
const lines = stack.split('\n');
|
|
191
|
-
// Look for first line that looks like a test file
|
|
192
|
-
for (const line of lines) {
|
|
193
|
-
const match = line.match(/\((.+\.(?:test|spec)\.[jt]s):\d+:\d+\)/);
|
|
194
|
-
if (match && match[1]) {
|
|
195
|
-
return match[1];
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return 'unknown';
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* Check if a value looks like a node:test context (has `name` and `assert`
|
|
202
|
-
* properties).
|
|
203
|
-
*
|
|
204
|
-
* This is used to detect when someone is passing a node:test context on an
|
|
205
|
-
* older Node.js version that doesn't support `assert.snapshot`.
|
|
206
|
-
*
|
|
207
|
-
* @function
|
|
208
|
-
* @param value - Value to check
|
|
209
|
-
* @returns `true` if value looks like a node:test context
|
|
210
|
-
*/
|
|
211
|
-
const looksLikeNodeTestContext = (value) => {
|
|
212
|
-
return ((0, adapter_js_1.isTestContext)(value) &&
|
|
213
|
-
'name' in value &&
|
|
214
|
-
typeof value.name === 'string' &&
|
|
215
|
-
'assert' in value &&
|
|
216
|
-
typeof value.assert === 'object' &&
|
|
217
|
-
value.assert !== null);
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Type guard for node:test context.
|
|
221
|
-
*
|
|
222
|
-
* Checks if the given value is a valid node:test test context by verifying the
|
|
223
|
-
* presence of required properties.
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
*
|
|
227
|
-
* ```typescript
|
|
228
|
-
* if (isNodeTestContext(context)) {
|
|
229
|
-
* context.assert.snapshot(value);
|
|
230
|
-
* }
|
|
231
|
-
* ```
|
|
232
|
-
*
|
|
233
|
-
* @function
|
|
234
|
-
* @param value - Value to check
|
|
235
|
-
* @returns `true` if value is a node:test context
|
|
236
|
-
*/
|
|
237
|
-
const isNodeTestContext = (value) => {
|
|
238
|
-
return ((0, adapter_js_1.isTestContext)(value) &&
|
|
239
|
-
'assert' in value &&
|
|
240
|
-
typeof value.assert === 'object' &&
|
|
241
|
-
value.assert !== null &&
|
|
242
|
-
'snapshot' in value.assert &&
|
|
243
|
-
typeof value.assert.snapshot === 'function');
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
|
-
* Check if we're running in node:test update mode.
|
|
247
|
-
*
|
|
248
|
-
* Node:test uses the `--test-update-snapshots` flag to indicate that snapshots
|
|
249
|
-
* should be updated rather than compared. This function also respects the
|
|
250
|
-
* `BUPKIS_UPDATE_SNAPSHOTS` environment variable for consistency with other
|
|
251
|
-
* adapters.
|
|
252
|
-
*
|
|
253
|
-
* This function checks:
|
|
254
|
-
*
|
|
255
|
-
* 1. `process.execArgv` (flags passed to Node.js)
|
|
256
|
-
* 2. `process.argv` (arguments passed to the script)
|
|
257
|
-
* 3. `BUPKIS_UPDATE_SNAPSHOTS` environment variable
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
*
|
|
261
|
-
* ```sh
|
|
262
|
-
* # These commands will trigger update mode:
|
|
263
|
-
* node --test --test-update-snapshots
|
|
264
|
-
* node --test-update-snapshots=true --test test.js
|
|
265
|
-
* BUPKIS_UPDATE_SNAPSHOTS=1 node --test
|
|
266
|
-
* ```
|
|
267
|
-
*
|
|
268
|
-
* @function
|
|
269
|
-
* @returns `true` if in update mode
|
|
270
|
-
*/
|
|
271
|
-
const isNodeTestUpdateMode = () => {
|
|
272
|
-
// Check for BUPKIS_UPDATE_SNAPSHOTS environment variable
|
|
273
|
-
if (process.env.BUPKIS_UPDATE_SNAPSHOTS === '1') {
|
|
274
|
-
return true;
|
|
275
|
-
}
|
|
276
|
-
// Check for --test-update-snapshots flag in exec args or argv
|
|
277
|
-
return (process.execArgv.some((arg) => arg === '--test-update-snapshots' ||
|
|
278
|
-
arg.startsWith('--test-update-snapshots=')) ||
|
|
279
|
-
process.argv.some((arg) => arg === '--test-update-snapshots' ||
|
|
280
|
-
arg.startsWith('--test-update-snapshots=')));
|
|
281
|
-
};
|
|
282
|
-
/**
|
|
283
|
-
* Singleton instance of the node:test adapter.
|
|
284
|
-
*
|
|
285
|
-
* This is the primary export and should be used for adapter registration.
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
*
|
|
289
|
-
* ```typescript
|
|
290
|
-
* import { nodeTestAdapter } from 'bupkis/snapshot';
|
|
291
|
-
* import { registerAdapter } from 'bupkis/snapshot';
|
|
292
|
-
*
|
|
293
|
-
* registerAdapter(nodeTestAdapter);
|
|
294
|
-
* ```
|
|
295
|
-
*/
|
|
296
|
-
exports.nodeTestAdapter = new NodeTestAdapter();
|
|
297
|
-
/**
|
|
298
|
-
* @function
|
|
299
|
-
*/
|
|
300
|
-
const isNodeAssertionError = (value) => (0, guards_js_1.isA)(value, node_assert_1.AssertionError);
|
|
301
|
-
//# sourceMappingURL=node-test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-test.js","sourceRoot":"","sources":["../../../src/snapshot/adapters/node-test.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapter for node:test's built-in snapshot support.
|
|
3
|
-
*
|
|
4
|
-
* Node.js native test runner includes snapshot testing capabilities as of
|
|
5
|
-
* Node.js v22. This adapter delegates to node:test's native `assert.snapshot()`
|
|
6
|
-
* function while providing the unified BUPKIS snapshot interface.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
* @see https://nodejs.org/api/test.html#snapshots
|
|
10
|
-
*/
|
|
11
|
-
import { type TestContext } from 'node:test';
|
|
12
|
-
import type { SnapshotAdapter, SnapshotContext, SnapshotOptions } from "../adapter.cjs";
|
|
13
|
-
import { type AssertionFailure } from "../../types.cjs";
|
|
14
|
-
/**
|
|
15
|
-
* Adapter for node:test snapshot support.
|
|
16
|
-
*
|
|
17
|
-
* This adapter leverages node:test's native snapshot functionality while
|
|
18
|
-
* providing the unified BUPKIS snapshot interface. It's the preferred adapter
|
|
19
|
-
* when running tests with node:test.
|
|
20
|
-
*
|
|
21
|
-
* **Features:**
|
|
22
|
-
*
|
|
23
|
-
* - Delegates to native `assert.snapshot()`
|
|
24
|
-
* - Supports custom serializers
|
|
25
|
-
* - Automatically detects update mode from CLI flags
|
|
26
|
-
* - Zero configuration required
|
|
27
|
-
*
|
|
28
|
-
* **Detection:** The adapter detects node:test by checking for
|
|
29
|
-
* `context.assert.snapshot`.
|
|
30
|
-
*
|
|
31
|
-
* **Update Mode:** Respects the `--test-update-snapshots` flag.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
*
|
|
35
|
-
* ```typescript
|
|
36
|
-
* import test from 'node:test';
|
|
37
|
-
* import { expect } from 'bupkis';
|
|
38
|
-
*
|
|
39
|
-
* test('renders component', (t) => {
|
|
40
|
-
* const output = render(<MyComponent />);
|
|
41
|
-
* expect(output, 'to match snapshot', t);
|
|
42
|
-
* });
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
*
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // With custom serializer
|
|
49
|
-
* test('redacts secrets', (t) => {
|
|
50
|
-
* const data = { public: 'visible', secret: 'password123' };
|
|
51
|
-
* expect(data, 'to match snapshot', t, {
|
|
52
|
-
* serializer: (value: any) =>
|
|
53
|
-
* JSON.stringify({ ...value, secret: '[REDACTED]' }, null, 2),
|
|
54
|
-
* });
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare class NodeTestAdapter implements SnapshotAdapter {
|
|
59
|
-
/**
|
|
60
|
-
* Adapter name for identification and debugging.
|
|
61
|
-
*/
|
|
62
|
-
readonly name = "node:test";
|
|
63
|
-
/**
|
|
64
|
-
* Check if this adapter can handle the given context.
|
|
65
|
-
*
|
|
66
|
-
* Returns `true` if the context has the structure of a node:test context,
|
|
67
|
-
* specifically checking for `context.assert.snapshot`.
|
|
68
|
-
*
|
|
69
|
-
* @param context - Test context to check
|
|
70
|
-
* @returns `true` if this is a node:test context
|
|
71
|
-
* @throws {Error} If running on Node.js < 22 with a node:test context
|
|
72
|
-
*/
|
|
73
|
-
canHandle(context: unknown): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Extract snapshot context from node:test context.
|
|
76
|
-
*
|
|
77
|
-
* Extracts:
|
|
78
|
-
*
|
|
79
|
-
* - **testPath**: The test name from `context.name`
|
|
80
|
-
* - **filePath**: Extracted from stack trace
|
|
81
|
-
* - **isUpdateMode**: Detected from `--test-update-snapshots` flag
|
|
82
|
-
*
|
|
83
|
-
* @param context - Node:test context object
|
|
84
|
-
* @returns Normalized snapshot context
|
|
85
|
-
* @throws {TypeError} If context is not a valid node:test context
|
|
86
|
-
*/
|
|
87
|
-
getContext(context: unknown): SnapshotContext;
|
|
88
|
-
/**
|
|
89
|
-
* Perform snapshot assertion using node:test's native functionality.
|
|
90
|
-
*
|
|
91
|
-
* This method delegates to `context.assert.snapshot()`, which handles:
|
|
92
|
-
*
|
|
93
|
-
* - Snapshot file creation and management
|
|
94
|
-
* - Snapshot comparison
|
|
95
|
-
* - Update mode behavior
|
|
96
|
-
* - Error messages and diffs
|
|
97
|
-
*
|
|
98
|
-
* If a custom serializer is provided in options, it will be passed to
|
|
99
|
-
* node:test as a serializer function.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
*
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const adapter = new NodeTestAdapter();
|
|
105
|
-
* adapter.assertSnapshot({ foo: 'bar' }, testContext);
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* @param value - Value to snapshot
|
|
109
|
-
* @param context - Node:test context object
|
|
110
|
-
* @param options - Optional serialization options
|
|
111
|
-
* @throws {TypeError} If context is not a valid node:test context
|
|
112
|
-
* @throws {AssertionError} If snapshot doesn't match (via node:test)
|
|
113
|
-
*/
|
|
114
|
-
validateSnapshot(value: unknown, context: TestContext, options?: SnapshotOptions): AssertionFailure | void;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Singleton instance of the node:test adapter.
|
|
118
|
-
*
|
|
119
|
-
* This is the primary export and should be used for adapter registration.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
*
|
|
123
|
-
* ```typescript
|
|
124
|
-
* import { nodeTestAdapter } from 'bupkis/snapshot';
|
|
125
|
-
* import { registerAdapter } from 'bupkis/snapshot';
|
|
126
|
-
*
|
|
127
|
-
* registerAdapter(nodeTestAdapter);
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
export declare const nodeTestAdapter: NodeTestAdapter;
|
|
131
|
-
//# sourceMappingURL=node-test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-test.d.ts","sourceRoot":"","sources":["../../../src/snapshot/adapters/node-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,eAAe,EAChB,uBAAsB;AAGvB,OAAO,EAAE,KAAK,gBAAgB,EAAE,wBAAuB;AAwBvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBAAa,eAAgB,YAAW,eAAe;IACrD;;OAEG;IACH,QAAQ,CAAC,IAAI,eAAe;IAE5B;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAOpC;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe;IAY7C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,gBAAgB,CACd,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,eAAe,GACxB,gBAAgB,GAAG,IAAI;CAyC3B;AAoID;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapter for node:test's built-in snapshot support.
|
|
3
|
-
*
|
|
4
|
-
* Node.js native test runner includes snapshot testing capabilities as of
|
|
5
|
-
* Node.js v22. This adapter delegates to node:test's native `assert.snapshot()`
|
|
6
|
-
* function while providing the unified BUPKIS snapshot interface.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
* @see https://nodejs.org/api/test.html#snapshots
|
|
10
|
-
*/
|
|
11
|
-
import { type TestContext } from 'node:test';
|
|
12
|
-
import type { SnapshotAdapter, SnapshotContext, SnapshotOptions } from "../adapter.js";
|
|
13
|
-
import { type AssertionFailure } from "../../types.js";
|
|
14
|
-
/**
|
|
15
|
-
* Adapter for node:test snapshot support.
|
|
16
|
-
*
|
|
17
|
-
* This adapter leverages node:test's native snapshot functionality while
|
|
18
|
-
* providing the unified BUPKIS snapshot interface. It's the preferred adapter
|
|
19
|
-
* when running tests with node:test.
|
|
20
|
-
*
|
|
21
|
-
* **Features:**
|
|
22
|
-
*
|
|
23
|
-
* - Delegates to native `assert.snapshot()`
|
|
24
|
-
* - Supports custom serializers
|
|
25
|
-
* - Automatically detects update mode from CLI flags
|
|
26
|
-
* - Zero configuration required
|
|
27
|
-
*
|
|
28
|
-
* **Detection:** The adapter detects node:test by checking for
|
|
29
|
-
* `context.assert.snapshot`.
|
|
30
|
-
*
|
|
31
|
-
* **Update Mode:** Respects the `--test-update-snapshots` flag.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
*
|
|
35
|
-
* ```typescript
|
|
36
|
-
* import test from 'node:test';
|
|
37
|
-
* import { expect } from 'bupkis';
|
|
38
|
-
*
|
|
39
|
-
* test('renders component', (t) => {
|
|
40
|
-
* const output = render(<MyComponent />);
|
|
41
|
-
* expect(output, 'to match snapshot', t);
|
|
42
|
-
* });
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
*
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // With custom serializer
|
|
49
|
-
* test('redacts secrets', (t) => {
|
|
50
|
-
* const data = { public: 'visible', secret: 'password123' };
|
|
51
|
-
* expect(data, 'to match snapshot', t, {
|
|
52
|
-
* serializer: (value: any) =>
|
|
53
|
-
* JSON.stringify({ ...value, secret: '[REDACTED]' }, null, 2),
|
|
54
|
-
* });
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare class NodeTestAdapter implements SnapshotAdapter {
|
|
59
|
-
/**
|
|
60
|
-
* Adapter name for identification and debugging.
|
|
61
|
-
*/
|
|
62
|
-
readonly name = "node:test";
|
|
63
|
-
/**
|
|
64
|
-
* Check if this adapter can handle the given context.
|
|
65
|
-
*
|
|
66
|
-
* Returns `true` if the context has the structure of a node:test context,
|
|
67
|
-
* specifically checking for `context.assert.snapshot`.
|
|
68
|
-
*
|
|
69
|
-
* @param context - Test context to check
|
|
70
|
-
* @returns `true` if this is a node:test context
|
|
71
|
-
* @throws {Error} If running on Node.js < 22 with a node:test context
|
|
72
|
-
*/
|
|
73
|
-
canHandle(context: unknown): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Extract snapshot context from node:test context.
|
|
76
|
-
*
|
|
77
|
-
* Extracts:
|
|
78
|
-
*
|
|
79
|
-
* - **testPath**: The test name from `context.name`
|
|
80
|
-
* - **filePath**: Extracted from stack trace
|
|
81
|
-
* - **isUpdateMode**: Detected from `--test-update-snapshots` flag
|
|
82
|
-
*
|
|
83
|
-
* @param context - Node:test context object
|
|
84
|
-
* @returns Normalized snapshot context
|
|
85
|
-
* @throws {TypeError} If context is not a valid node:test context
|
|
86
|
-
*/
|
|
87
|
-
getContext(context: unknown): SnapshotContext;
|
|
88
|
-
/**
|
|
89
|
-
* Perform snapshot assertion using node:test's native functionality.
|
|
90
|
-
*
|
|
91
|
-
* This method delegates to `context.assert.snapshot()`, which handles:
|
|
92
|
-
*
|
|
93
|
-
* - Snapshot file creation and management
|
|
94
|
-
* - Snapshot comparison
|
|
95
|
-
* - Update mode behavior
|
|
96
|
-
* - Error messages and diffs
|
|
97
|
-
*
|
|
98
|
-
* If a custom serializer is provided in options, it will be passed to
|
|
99
|
-
* node:test as a serializer function.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
*
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const adapter = new NodeTestAdapter();
|
|
105
|
-
* adapter.assertSnapshot({ foo: 'bar' }, testContext);
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* @param value - Value to snapshot
|
|
109
|
-
* @param context - Node:test context object
|
|
110
|
-
* @param options - Optional serialization options
|
|
111
|
-
* @throws {TypeError} If context is not a valid node:test context
|
|
112
|
-
* @throws {AssertionError} If snapshot doesn't match (via node:test)
|
|
113
|
-
*/
|
|
114
|
-
validateSnapshot(value: unknown, context: TestContext, options?: SnapshotOptions): AssertionFailure | void;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Singleton instance of the node:test adapter.
|
|
118
|
-
*
|
|
119
|
-
* This is the primary export and should be used for adapter registration.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
*
|
|
123
|
-
* ```typescript
|
|
124
|
-
* import { nodeTestAdapter } from 'bupkis/snapshot';
|
|
125
|
-
* import { registerAdapter } from 'bupkis/snapshot';
|
|
126
|
-
*
|
|
127
|
-
* registerAdapter(nodeTestAdapter);
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
export declare const nodeTestAdapter: NodeTestAdapter;
|
|
131
|
-
//# sourceMappingURL=node-test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-test.d.ts","sourceRoot":"","sources":["../../../src/snapshot/adapters/node-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,eAAe,EAChB,sBAAsB;AAGvB,OAAO,EAAE,KAAK,gBAAgB,EAAE,uBAAuB;AAwBvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBAAa,eAAgB,YAAW,eAAe;IACrD;;OAEG;IACH,QAAQ,CAAC,IAAI,eAAe;IAE5B;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAOpC;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe;IAY7C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,gBAAgB,CACd,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,eAAe,GACxB,gBAAgB,GAAG,IAAI;CAyC3B;AAoID;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|