@tapjs/snapshot
Advanced tools
Comparing version 0.0.0-12 to 0.0.0-13
@@ -56,11 +56,45 @@ import type { TapPlugin, TestBase } from '@tapjs/core'; | ||
constructor(t: TestBase, opts: SnapshotOptions); | ||
/** | ||
* Options that will be used when formatting snapshots and diffing/comparing | ||
* objects using any assertion methods. | ||
*/ | ||
get compareOptions(): Exclude<SnapshotOptions['compareOptions'], undefined>; | ||
set compareOptions(cmt: Exclude<SnapshotOptions['compareOptions'], undefined>); | ||
/** | ||
* Method that will be called on snapshot strings. This can be used | ||
* to remove transient run-specific data from snapshots using simple | ||
* string transforms. | ||
*/ | ||
get cleanSnapshot(): SnapshotOptions['cleanSnapshot']; | ||
set cleanSnapshot(clean: SnapshotOptions['cleanSnapshot']); | ||
/** | ||
* Function that turns an object into a snapshot string. | ||
* | ||
* By default {@link tcompare!format} is used. If a string is returned, | ||
* then that string is the snapshot string. If any other type is returned, | ||
* then the returned value will be formatted using {@link tcompare!format}. | ||
*/ | ||
get formatSnapshot(): SnapshotOptions['formatSnapshot']; | ||
set formatSnapshot(format: SnapshotOptions['formatSnapshot']); | ||
/** | ||
* The file where snapshots will be written to and read from | ||
*/ | ||
get snapshotFile(): string; | ||
set snapshotFile(f: string); | ||
/** | ||
* In `--snapshot` mode, takes a snapshot of the object provided, and writes | ||
* to the snapshot file. | ||
* | ||
* Otherwise, reads the snapshot file, and verifies that a snapshot of the | ||
* object provided matches the stored snapshot. | ||
* | ||
* @group Assertion Methods | ||
*/ | ||
matchSnapshot(found: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Resolve a promise, and verify that the resulting value matches the | ||
* snapshot. | ||
* | ||
* @group Assertion Methods | ||
*/ | ||
resolveMatchSnapshot<T extends any = any>(fnOrPromise: Promise<T> | (() => Promise<T>), ...[msg, extra]: MessageExtra): Promise<boolean>; | ||
@@ -67,0 +101,0 @@ } |
@@ -73,2 +73,6 @@ "use strict"; | ||
} | ||
/** | ||
* Options that will be used when formatting snapshots and diffing/comparing | ||
* objects using any assertion methods. | ||
*/ | ||
get compareOptions() { | ||
@@ -81,2 +85,7 @@ return this.#compareOptions; | ||
} | ||
/** | ||
* Method that will be called on snapshot strings. This can be used | ||
* to remove transient run-specific data from snapshots using simple | ||
* string transforms. | ||
*/ | ||
get cleanSnapshot() { | ||
@@ -89,2 +98,9 @@ return this.#cleanSnapshot; | ||
} | ||
/** | ||
* Function that turns an object into a snapshot string. | ||
* | ||
* By default {@link tcompare!format} is used. If a string is returned, | ||
* then that string is the snapshot string. If any other type is returned, | ||
* then the returned value will be formatted using {@link tcompare!format}. | ||
*/ | ||
get formatSnapshot() { | ||
@@ -97,2 +113,5 @@ return this.#formatSnapshot; | ||
} | ||
/** | ||
* The file where snapshots will be written to and read from | ||
*/ | ||
get snapshotFile() { | ||
@@ -110,2 +129,11 @@ return this.#snapshot.file; | ||
} | ||
/** | ||
* In `--snapshot` mode, takes a snapshot of the object provided, and writes | ||
* to the snapshot file. | ||
* | ||
* Otherwise, reads the snapshot file, and verifies that a snapshot of the | ||
* object provided matches the stored snapshot. | ||
* | ||
* @group Assertion Methods | ||
*/ | ||
matchSnapshot(found, ...[msg, extra]) { | ||
@@ -162,2 +190,8 @@ this.#t.currentAssert = this.#t.t.matchSnapshot; | ||
} | ||
/** | ||
* Resolve a promise, and verify that the resulting value matches the | ||
* snapshot. | ||
* | ||
* @group Assertion Methods | ||
*/ | ||
async resolveMatchSnapshot(fnOrPromise, ...[msg, extra]) { | ||
@@ -213,11 +247,11 @@ const args = [msg, extra]; | ||
short: 'S', | ||
description: `Generate snapshot files for 't.matchSnapshot()' | ||
description: `Generate snapshot files for \`t.matchSnapshot()\` | ||
assertions. | ||
Defaults to true if the TAP_SNAPSHOT environment variable | ||
is set to '1', or if the npm_lifecycle_event environment | ||
variable is set to either 'snap' or 'snapshot'. | ||
Defaults to true if the \`TAP_SNAPSHOT\` environment variable | ||
is set to \`1\`, or if the \`npm_lifecycle_event\` environment | ||
variable is set to either \`snap\` or \`snapshot\`. | ||
That is, if you put "scripts": { "snap": "tap" } in your | ||
package.json file, then 'npm run snap' will generate | ||
That is, if you put \`"scripts": { "snap": "tap" }\` in your | ||
package.json file, then \`npm run snap\` will generate | ||
snapshots. | ||
@@ -224,0 +258,0 @@ `, |
@@ -56,11 +56,45 @@ import type { TapPlugin, TestBase } from '@tapjs/core'; | ||
constructor(t: TestBase, opts: SnapshotOptions); | ||
/** | ||
* Options that will be used when formatting snapshots and diffing/comparing | ||
* objects using any assertion methods. | ||
*/ | ||
get compareOptions(): Exclude<SnapshotOptions['compareOptions'], undefined>; | ||
set compareOptions(cmt: Exclude<SnapshotOptions['compareOptions'], undefined>); | ||
/** | ||
* Method that will be called on snapshot strings. This can be used | ||
* to remove transient run-specific data from snapshots using simple | ||
* string transforms. | ||
*/ | ||
get cleanSnapshot(): SnapshotOptions['cleanSnapshot']; | ||
set cleanSnapshot(clean: SnapshotOptions['cleanSnapshot']); | ||
/** | ||
* Function that turns an object into a snapshot string. | ||
* | ||
* By default {@link tcompare!format} is used. If a string is returned, | ||
* then that string is the snapshot string. If any other type is returned, | ||
* then the returned value will be formatted using {@link tcompare!format}. | ||
*/ | ||
get formatSnapshot(): SnapshotOptions['formatSnapshot']; | ||
set formatSnapshot(format: SnapshotOptions['formatSnapshot']); | ||
/** | ||
* The file where snapshots will be written to and read from | ||
*/ | ||
get snapshotFile(): string; | ||
set snapshotFile(f: string); | ||
/** | ||
* In `--snapshot` mode, takes a snapshot of the object provided, and writes | ||
* to the snapshot file. | ||
* | ||
* Otherwise, reads the snapshot file, and verifies that a snapshot of the | ||
* object provided matches the stored snapshot. | ||
* | ||
* @group Assertion Methods | ||
*/ | ||
matchSnapshot(found: any, ...[msg, extra]: MessageExtra): boolean; | ||
/** | ||
* Resolve a promise, and verify that the resulting value matches the | ||
* snapshot. | ||
* | ||
* @group Assertion Methods | ||
*/ | ||
resolveMatchSnapshot<T extends any = any>(fnOrPromise: Promise<T> | (() => Promise<T>), ...[msg, extra]: MessageExtra): Promise<boolean>; | ||
@@ -67,0 +101,0 @@ } |
@@ -69,2 +69,6 @@ import { argv, cwd, env, mainScript, normalizeMessageExtra, } from '@tapjs/core'; | ||
} | ||
/** | ||
* Options that will be used when formatting snapshots and diffing/comparing | ||
* objects using any assertion methods. | ||
*/ | ||
get compareOptions() { | ||
@@ -77,2 +81,7 @@ return this.#compareOptions; | ||
} | ||
/** | ||
* Method that will be called on snapshot strings. This can be used | ||
* to remove transient run-specific data from snapshots using simple | ||
* string transforms. | ||
*/ | ||
get cleanSnapshot() { | ||
@@ -85,2 +94,9 @@ return this.#cleanSnapshot; | ||
} | ||
/** | ||
* Function that turns an object into a snapshot string. | ||
* | ||
* By default {@link tcompare!format} is used. If a string is returned, | ||
* then that string is the snapshot string. If any other type is returned, | ||
* then the returned value will be formatted using {@link tcompare!format}. | ||
*/ | ||
get formatSnapshot() { | ||
@@ -93,2 +109,5 @@ return this.#formatSnapshot; | ||
} | ||
/** | ||
* The file where snapshots will be written to and read from | ||
*/ | ||
get snapshotFile() { | ||
@@ -106,2 +125,11 @@ return this.#snapshot.file; | ||
} | ||
/** | ||
* In `--snapshot` mode, takes a snapshot of the object provided, and writes | ||
* to the snapshot file. | ||
* | ||
* Otherwise, reads the snapshot file, and verifies that a snapshot of the | ||
* object provided matches the stored snapshot. | ||
* | ||
* @group Assertion Methods | ||
*/ | ||
matchSnapshot(found, ...[msg, extra]) { | ||
@@ -158,2 +186,8 @@ this.#t.currentAssert = this.#t.t.matchSnapshot; | ||
} | ||
/** | ||
* Resolve a promise, and verify that the resulting value matches the | ||
* snapshot. | ||
* | ||
* @group Assertion Methods | ||
*/ | ||
async resolveMatchSnapshot(fnOrPromise, ...[msg, extra]) { | ||
@@ -208,11 +242,11 @@ const args = [msg, extra]; | ||
short: 'S', | ||
description: `Generate snapshot files for 't.matchSnapshot()' | ||
description: `Generate snapshot files for \`t.matchSnapshot()\` | ||
assertions. | ||
Defaults to true if the TAP_SNAPSHOT environment variable | ||
is set to '1', or if the npm_lifecycle_event environment | ||
variable is set to either 'snap' or 'snapshot'. | ||
Defaults to true if the \`TAP_SNAPSHOT\` environment variable | ||
is set to \`1\`, or if the \`npm_lifecycle_event\` environment | ||
variable is set to either \`snap\` or \`snapshot\`. | ||
That is, if you put "scripts": { "snap": "tap" } in your | ||
package.json file, then 'npm run snap' will generate | ||
That is, if you put \`"scripts": { "snap": "tap" }\` in your | ||
package.json file, then \`npm run snap\` will generate | ||
snapshots. | ||
@@ -219,0 +253,0 @@ `, |
{ | ||
"name": "@tapjs/snapshot", | ||
"version": "0.0.0-12", | ||
"version": "0.0.0-13", | ||
"description": "", | ||
@@ -40,3 +40,3 @@ "author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me)", | ||
"peerDependencies": { | ||
"@tapjs/core": "0.0.0-12" | ||
"@tapjs/core": "0.0.0-13" | ||
}, | ||
@@ -43,0 +43,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87798
916