From 22ccd5e5bd529d3b7faa00b535480fdbefb2fe9a Mon Sep 17 00:00:00 2001 From: electrovir Date: Wed, 27 Nov 2024 19:34:38 +0000 Subject: [PATCH] [patch] fix import and comparison of web snapshots --- package-lock.json | 88 +++++++++---------- package.json | 2 +- packages/compile/package.json | 6 +- packages/core/package.json | 2 +- packages/deps/package.json | 4 +- packages/docs/package.json | 4 +- packages/format/package.json | 4 +- packages/frontend/package.json | 4 +- packages/help/package.json | 4 +- packages/init/package.json | 4 +- packages/lint/package.json | 4 +- packages/plugin-testing/package.json | 4 +- packages/publish/package.json | 4 +- packages/scripts/package.json | 4 +- packages/spellcheck/package.json | 6 +- packages/test/package.json | 4 +- .../web-snapshot-plugin/snapshot-payload.ts | 2 +- .../src/web-snapshot-plugin/snapshot-store.ts | 30 ++++--- .../web-snapshot-plugin.test.ts | 4 +- .../web-snapshot-plugin.ts | 10 +-- packages/virmator/package.json | 26 +++--- 21 files changed, 115 insertions(+), 105 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8c150940..5d8dde3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@virmator/mono-repo-root", - "version": "13.10.2", + "version": "13.10.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@virmator/mono-repo-root", - "version": "13.10.2", + "version": "13.10.3", "workspaces": [ "packages/*" ], @@ -17654,18 +17654,18 @@ }, "packages/compile": { "name": "@virmator/compile", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2" + "@virmator/core": "^13.10.3" }, "devDependencies": { "@augment-vir/test": "^30.8.2", "@types/node": "^22.9.0", - "@virmator/plugin-testing": "^13.10.2", + "@virmator/plugin-testing": "^13.10.3", "c8": "^10.1.2", "chalk": "^5.3.0", "concurrently": "^9.1.0", @@ -17683,7 +17683,7 @@ }, "packages/core": { "name": "@virmator/core", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", @@ -17709,13 +17709,13 @@ }, "packages/deps": { "name": "@virmator/deps", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { @@ -17733,13 +17733,13 @@ }, "packages/docs": { "name": "@virmator/docs", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "chalk": "^5.3.0", "mri": "^1.2.0" }, @@ -17758,12 +17758,12 @@ }, "packages/format": { "name": "@virmator/format", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { @@ -17786,13 +17786,13 @@ }, "packages/frontend": { "name": "@virmator/frontend", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { @@ -17808,13 +17808,13 @@ }, "packages/help": { "name": "@virmator/help", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2" + "@virmator/core": "^13.10.3" }, "devDependencies": { "@augment-vir/test": "^30.8.2", @@ -17828,13 +17828,13 @@ }, "packages/init": { "name": "@virmator/init", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "simple-git": "^3.27.0" }, "devDependencies": { @@ -17850,12 +17850,12 @@ }, "packages/lint": { "name": "@virmator/lint", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { @@ -17885,13 +17885,13 @@ }, "packages/plugin-testing": { "name": "@virmator/plugin-testing", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "cli-args-vir": "^1.0.0", "type-fest": "^4.27.0" }, @@ -17909,13 +17909,13 @@ }, "packages/publish": { "name": "@virmator/publish", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "chalk": "^5.3.0", "mri": "^1.2.0", "semver": "^7.6.3", @@ -17935,7 +17935,7 @@ }, "packages/scripts": { "name": "@virmator/scripts", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", @@ -17943,7 +17943,7 @@ "@augment-vir/node": "^30.8.2", "mri": "^1.2.0", "tsx": "^4.19.2", - "virmator": "^13.10.2" + "virmator": "^13.10.3" }, "devDependencies": { "@types/node": "^22.9.0" @@ -17954,19 +17954,19 @@ }, "packages/spellcheck": { "name": "@virmator/spellcheck", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { "@augment-vir/test": "^30.8.2", "@types/node": "^22.9.0", - "@virmator/plugin-testing": "^13.10.2", + "@virmator/plugin-testing": "^13.10.3", "c8": "^10.1.2", "concurrently": "^9.1.0", "cspell": "^8.16.0", @@ -17979,13 +17979,13 @@ }, "packages/test": { "name": "@virmator/test", - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "@web/dev-server-core": "^0.7.4", "@web/test-runner-core": "^0.13.4", "glob": "^11.0.0", @@ -18013,23 +18013,23 @@ } }, "packages/virmator": { - "version": "13.10.2", + "version": "13.10.3", "license": "(MIT or CC0 1.0)", "dependencies": { "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/compile": "^13.10.2", - "@virmator/core": "^13.10.2", - "@virmator/deps": "^13.10.2", - "@virmator/docs": "^13.10.2", - "@virmator/format": "^13.10.2", - "@virmator/frontend": "^13.10.2", - "@virmator/help": "^13.10.2", - "@virmator/init": "^13.10.2", - "@virmator/lint": "^13.10.2", - "@virmator/publish": "^13.10.2", - "@virmator/spellcheck": "^13.10.2", - "@virmator/test": "^13.10.2", + "@virmator/compile": "^13.10.3", + "@virmator/core": "^13.10.3", + "@virmator/deps": "^13.10.3", + "@virmator/docs": "^13.10.3", + "@virmator/format": "^13.10.3", + "@virmator/frontend": "^13.10.3", + "@virmator/help": "^13.10.3", + "@virmator/init": "^13.10.3", + "@virmator/lint": "^13.10.3", + "@virmator/publish": "^13.10.3", + "@virmator/spellcheck": "^13.10.3", + "@virmator/test": "^13.10.3", "tsx": "^4.19.2" }, "bin": { diff --git a/package.json b/package.json index 2973c6f3..91dfcf56 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/mono-repo-root", - "version": "13.10.2", + "version": "13.10.3", "private": true, "type": "module", "workspaces": [ diff --git a/packages/compile/package.json b/packages/compile/package.json index 388e751f..6b9cf0d2 100644 --- a/packages/compile/package.json +++ b/packages/compile/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/compile", - "version": "13.10.2", + "version": "13.10.3", "description": "Default TS compile plugin for virmator.", "keywords": [ "virmator", @@ -34,12 +34,12 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2" + "@virmator/core": "^13.10.3" }, "devDependencies": { "@augment-vir/test": "^30.8.2", "@types/node": "^22.9.0", - "@virmator/plugin-testing": "^13.10.2", + "@virmator/plugin-testing": "^13.10.3", "c8": "^10.1.2", "chalk": "^5.3.0", "concurrently": "^9.1.0", diff --git a/packages/core/package.json b/packages/core/package.json index a910a77c..56e5416d 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/core", - "version": "13.10.2", + "version": "13.10.3", "description": "Shared core functionality for all virmator plugins and the virmator CLI.", "keywords": [ "automation", diff --git a/packages/deps/package.json b/packages/deps/package.json index 1b1c200c..84b57e4e 100644 --- a/packages/deps/package.json +++ b/packages/deps/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/deps", - "version": "13.10.2", + "version": "13.10.3", "description": "Default TS deps plugin for virmator.", "keywords": [ "virmator", @@ -36,7 +36,7 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { diff --git a/packages/docs/package.json b/packages/docs/package.json index 8d75903e..a982453a 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/docs", - "version": "13.10.2", + "version": "13.10.3", "description": "Default TS docs plugin for virmator.", "keywords": [ "virmator", @@ -35,7 +35,7 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "chalk": "^5.3.0", "mri": "^1.2.0" }, diff --git a/packages/format/package.json b/packages/format/package.json index 9d4d3dd7..4d2e78bc 100644 --- a/packages/format/package.json +++ b/packages/format/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/format", - "version": "13.10.2", + "version": "13.10.3", "description": "Default format plugin for virmator.", "keywords": [ "virmator", @@ -33,7 +33,7 @@ "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 0384efcb..a6a7bd3f 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/frontend", - "version": "13.10.2", + "version": "13.10.3", "description": "Default frontend plugin for virmator.", "keywords": [ "virmator", @@ -37,7 +37,7 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { diff --git a/packages/help/package.json b/packages/help/package.json index c1063160..06074262 100644 --- a/packages/help/package.json +++ b/packages/help/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/help", - "version": "13.10.2", + "version": "13.10.3", "description": "Default help plugin for virmator.", "keywords": [ "virmator", @@ -34,7 +34,7 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2" + "@virmator/core": "^13.10.3" }, "devDependencies": { "@augment-vir/test": "^30.8.2", diff --git a/packages/init/package.json b/packages/init/package.json index 734f1f19..23e553d3 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/init", - "version": "13.10.2", + "version": "13.10.3", "description": "Default init plugin for virmator.", "keywords": [ "virmator", @@ -33,7 +33,7 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "simple-git": "^3.27.0" }, "devDependencies": { diff --git a/packages/lint/package.json b/packages/lint/package.json index 1c1271f7..f7212b3d 100644 --- a/packages/lint/package.json +++ b/packages/lint/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/lint", - "version": "13.10.2", + "version": "13.10.3", "description": "Default ESLint linting plugin for virmator.", "keywords": [ "virmator", @@ -33,7 +33,7 @@ "dependencies": { "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { diff --git a/packages/plugin-testing/package.json b/packages/plugin-testing/package.json index f37d6d18..e623c925 100644 --- a/packages/plugin-testing/package.json +++ b/packages/plugin-testing/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/plugin-testing", - "version": "13.10.2", + "version": "13.10.3", "description": "Testing for virmator plugins.", "keywords": [ "virmator", @@ -33,7 +33,7 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "cli-args-vir": "^1.0.0", "type-fest": "^4.27.0" }, diff --git a/packages/publish/package.json b/packages/publish/package.json index ff167265..690a9f28 100644 --- a/packages/publish/package.json +++ b/packages/publish/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/publish", - "version": "13.10.2", + "version": "13.10.3", "description": "Default publish plugin for virmator.", "keywords": [ "virmator", @@ -36,7 +36,7 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "chalk": "^5.3.0", "mri": "^1.2.0", "semver": "^7.6.3", diff --git a/packages/scripts/package.json b/packages/scripts/package.json index e6dc277d..0672b2e5 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/scripts", - "version": "13.10.2", + "version": "13.10.3", "private": true, "description": "Internal virmator scripts.", "keywords": [ @@ -32,7 +32,7 @@ "@augment-vir/node": "^30.8.2", "mri": "^1.2.0", "tsx": "^4.19.2", - "virmator": "^13.10.2" + "virmator": "^13.10.3" }, "devDependencies": { "@types/node": "^22.9.0" diff --git a/packages/spellcheck/package.json b/packages/spellcheck/package.json index 036900af..b4aeb10a 100644 --- a/packages/spellcheck/package.json +++ b/packages/spellcheck/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/spellcheck", - "version": "13.10.2", + "version": "13.10.3", "description": "Default spellcheck plugin for virmator", "keywords": [ "virmator", @@ -34,13 +34,13 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "mri": "^1.2.0" }, "devDependencies": { "@augment-vir/test": "^30.8.2", "@types/node": "^22.9.0", - "@virmator/plugin-testing": "^13.10.2", + "@virmator/plugin-testing": "^13.10.3", "c8": "^10.1.2", "concurrently": "^9.1.0", "cspell": "^8.16.0", diff --git a/packages/test/package.json b/packages/test/package.json index 0513970d..45e09cf1 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -1,6 +1,6 @@ { "name": "@virmator/test", - "version": "13.10.2", + "version": "13.10.3", "description": "Default test plugin for virmator.", "keywords": [ "virmator", @@ -38,7 +38,7 @@ "@augment-vir/assert": "^30.8.2", "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/core": "^13.10.2", + "@virmator/core": "^13.10.3", "@web/dev-server-core": "^0.7.4", "@web/test-runner-core": "^0.13.4", "glob": "^11.0.0", diff --git a/packages/test/src/web-snapshot-plugin/snapshot-payload.ts b/packages/test/src/web-snapshot-plugin/snapshot-payload.ts index 66b5b5ff..3e8fd90f 100644 --- a/packages/test/src/web-snapshot-plugin/snapshot-payload.ts +++ b/packages/test/src/web-snapshot-plugin/snapshot-payload.ts @@ -16,7 +16,7 @@ export enum SnapshotCommand { export type CompareCommandResult = { matches: boolean; updated: boolean; - savedContent: string; + savedSnapshot: string; snapshotPath: string; exists: boolean; }; diff --git a/packages/test/src/web-snapshot-plugin/snapshot-store.ts b/packages/test/src/web-snapshot-plugin/snapshot-store.ts index e016314b..1d04c1a8 100644 --- a/packages/test/src/web-snapshot-plugin/snapshot-store.ts +++ b/packages/test/src/web-snapshot-plugin/snapshot-store.ts @@ -1,5 +1,12 @@ import {check} from '@augment-vir/assert'; -import {getOrSet, logColors, PromiseQueue, wrapInTry, type MaybePromise} from '@augment-vir/common'; +import { + ensureErrorAndPrependMessage, + getOrSet, + logColors, + PromiseQueue, + wrapInTry, + type MaybePromise, +} from '@augment-vir/common'; import {readFile, writeFile} from 'node:fs/promises'; import {relative} from 'node:path'; import {defineTypedCustomEvent, ListenTarget} from 'typed-event-target'; @@ -10,7 +17,7 @@ type SnapshotsFile = { }; export function createSnapshotOutputPath(testFilePath: string) { - return testFilePath + '.snapshot.web'; + return testFilePath + '.snapshot.web.mjs'; } export class SnapshotStoreUpdateEvent extends defineTypedCustomEvent<{size: number}>()( @@ -28,12 +35,15 @@ export class SnapshotStore extends ListenTarget { protected async getCachedSnapshotFile(testFilePath: string): Promise { const snapshotFile = await getOrSet(this.snapshotFiles, testFilePath, async () => { - const existingSnapshot = await wrapInTry( - () => import(createSnapshotOutputPath(testFilePath)), - { - fallbackValue: undefined, + const importPath = createSnapshotOutputPath(testFilePath); + const existingSnapshot = await wrapInTry(() => import(importPath), { + handleError(error) { + console.error( + ensureErrorAndPrependMessage(error, `Failed to import '${importPath}'`), + ); + return undefined; }, - ); + }); if (!check.isObject(existingSnapshot)) { return {}; @@ -106,13 +116,13 @@ export class SnapshotStore extends ListenTarget { public async updateSnapshot({ testFilePath, snapshotName, - snapshotContent, + newSnapshot, }: { testFilePath: string; snapshotName: string; - snapshotContent: unknown; + newSnapshot: unknown; }) { - (await this.getCachedSnapshotFile(testFilePath))[snapshotName] = snapshotContent; + (await this.getCachedSnapshotFile(testFilePath))[snapshotName] = newSnapshot; } public override destroy() { diff --git a/packages/test/src/web-snapshot-plugin/web-snapshot-plugin.test.ts b/packages/test/src/web-snapshot-plugin/web-snapshot-plugin.test.ts index d595c9a0..cb5c3b87 100644 --- a/packages/test/src/web-snapshot-plugin/web-snapshot-plugin.test.ts +++ b/packages/test/src/web-snapshot-plugin/web-snapshot-plugin.test.ts @@ -14,13 +14,13 @@ describe('snapshotPlugin', () => { } satisfies SnapshotPayload, ); - assert.endsWith(result.snapshotPath, 'web-snapshot-plugin.test.ts.snapshot.web'); + assert.endsWith(result.snapshotPath, 'web-snapshot-plugin.test.ts.snapshot.web.mjs'); assert.deepEquals(omitObjectKeys(result, ['snapshotPath']), { matches: false, updated: false, exists: false, - savedContent: '', + savedSnapshot: '', }); }); }); diff --git a/packages/test/src/web-snapshot-plugin/web-snapshot-plugin.ts b/packages/test/src/web-snapshot-plugin/web-snapshot-plugin.ts index 5264c861..9b068618 100644 --- a/packages/test/src/web-snapshot-plugin/web-snapshot-plugin.ts +++ b/packages/test/src/web-snapshot-plugin/web-snapshot-plugin.ts @@ -72,13 +72,13 @@ export function snapshotPlugin(repoPath: string): TestRunnerPlugin { ); if (command === SnapshotCommand.CompareSnapshot) { - const snapshotContent: unknown = wrapInTry(() => JSON.parse(payload.content), { + const newSnapshot: unknown = wrapInTry(() => JSON.parse(payload.content), { fallbackValue: payload.content, }); const savedSnapshot = await snapshotStore.getSnapshot(session.testFile, payload); - const matches = savedSnapshot === snapshotContent; + const matches = check.deepEquals(savedSnapshot, newSnapshot); const updated = !matches && snapshotUpdatesAllowed; const snapshotPath = createSnapshotOutputPath(session.testFile); @@ -86,11 +86,11 @@ export function snapshotPlugin(repoPath: string): TestRunnerPlugin { await snapshotStore.updateSnapshot({ testFilePath: session.testFile, snapshotName: payload.name, - snapshotContent, + newSnapshot: newSnapshot, }); } - const savedContent: string = + const savedSnapshotString: string = (check.isString(savedSnapshot) ? savedSnapshot : JSON.stringify(savedSnapshot)) || ''; @@ -98,7 +98,7 @@ export function snapshotPlugin(repoPath: string): TestRunnerPlugin { return { matches, updated, - savedContent, + savedSnapshot: savedSnapshotString, snapshotPath: relative(repoPath, snapshotPath), exists: existsSync(snapshotPath), } satisfies CompareCommandResult; diff --git a/packages/virmator/package.json b/packages/virmator/package.json index 368e9b6c..9367ff7c 100644 --- a/packages/virmator/package.json +++ b/packages/virmator/package.json @@ -1,6 +1,6 @@ { "name": "virmator", - "version": "13.10.2", + "version": "13.10.3", "description": "Handle common package configs, commands, and dependencies.", "keywords": [ "automation", @@ -39,18 +39,18 @@ "dependencies": { "@augment-vir/common": "^30.8.2", "@augment-vir/node": "^30.8.2", - "@virmator/compile": "^13.10.2", - "@virmator/core": "^13.10.2", - "@virmator/deps": "^13.10.2", - "@virmator/docs": "^13.10.2", - "@virmator/format": "^13.10.2", - "@virmator/frontend": "^13.10.2", - "@virmator/help": "^13.10.2", - "@virmator/init": "^13.10.2", - "@virmator/lint": "^13.10.2", - "@virmator/publish": "^13.10.2", - "@virmator/spellcheck": "^13.10.2", - "@virmator/test": "^13.10.2", + "@virmator/compile": "^13.10.3", + "@virmator/core": "^13.10.3", + "@virmator/deps": "^13.10.3", + "@virmator/docs": "^13.10.3", + "@virmator/format": "^13.10.3", + "@virmator/frontend": "^13.10.3", + "@virmator/help": "^13.10.3", + "@virmator/init": "^13.10.3", + "@virmator/lint": "^13.10.3", + "@virmator/publish": "^13.10.3", + "@virmator/spellcheck": "^13.10.3", + "@virmator/test": "^13.10.3", "tsx": "^4.19.2" }, "devDependencies": {