@vitest/snapshot 1.0.0-beta.3 → 1.0.0-beta.5

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/README.md CHANGED
@@ -22,7 +22,7 @@ const environment = new NodeSnapshotEnvironment()
22
22
  // you need to implement this yourselves,
23
23
  // this depends on your runner
24
24
  function getCurrentFilepath() {
25
- return '/file.spec.ts'
25
+ return '/file.spec.js'
26
26
  }
27
27
  function getCurrentTestName() {
28
28
  return 'test1'
@@ -1,4 +1,4 @@
1
- import { S as SnapshotEnvironment } from './environment-e71c592b.js';
1
+ import { S as SnapshotEnvironment } from './environment-AwZ-cC__.js';
2
2
 
3
3
  declare class NodeSnapshotEnvironment implements SnapshotEnvironment {
4
4
  getVersion(): string;
@@ -1,5 +1,5 @@
1
1
  import { OptionsReceived } from 'pretty-format';
2
- import { S as SnapshotEnvironment } from './environment-e71c592b.js';
2
+ import { S as SnapshotEnvironment } from './environment-AwZ-cC__.js';
3
3
 
4
4
  interface RawSnapshotInfo {
5
5
  file: string;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { S as SnapshotStateOptions, a as SnapshotMatchOptions, b as SnapshotResult, R as RawSnapshotInfo } from './index-d5eca340.js';
2
- export { c as SnapshotData, e as SnapshotSummary, d as SnapshotUpdateState, U as UncheckedSnapshot } from './index-d5eca340.js';
3
- import { S as SnapshotEnvironment } from './environment-e71c592b.js';
1
+ import { S as SnapshotStateOptions, a as SnapshotMatchOptions, b as SnapshotResult, R as RawSnapshotInfo } from './index-lPCXZXKD.js';
2
+ export { c as SnapshotData, e as SnapshotSummary, d as SnapshotUpdateState, U as UncheckedSnapshot } from './index-lPCXZXKD.js';
3
+ import { S as SnapshotEnvironment } from './environment-AwZ-cC__.js';
4
4
  import { Plugin, Plugins } from 'pretty-format';
5
5
 
6
6
  interface ParsedStack {
package/dist/index.js CHANGED
@@ -818,7 +818,7 @@ class TraceMap {
818
818
  const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
819
819
  this.version = version;
820
820
  this.file = file;
821
- this.names = names;
821
+ this.names = names || [];
822
822
  this.sourceRoot = sourceRoot;
823
823
  this.sources = sources;
824
824
  this.sourcesContent = sourcesContent;
@@ -1358,7 +1358,7 @@ ${JSON.stringify(stacks)}`
1358
1358
  }
1359
1359
  }
1360
1360
 
1361
- function createMismatchError(message, actual, expected) {
1361
+ function createMismatchError(message, expand, actual, expected) {
1362
1362
  const error = new Error(message);
1363
1363
  Object.defineProperty(error, "actual", {
1364
1364
  value: actual,
@@ -1372,6 +1372,7 @@ function createMismatchError(message, actual, expected) {
1372
1372
  configurable: true,
1373
1373
  writable: true
1374
1374
  });
1375
+ Object.defineProperty(error, "diffOptions", { value: { expand } });
1375
1376
  return error;
1376
1377
  }
1377
1378
  class SnapshotClient {
@@ -1412,7 +1413,7 @@ class SnapshotClient {
1412
1413
  (_a = this.snapshotState) == null ? void 0 : _a.markSnapshotsAsCheckedForTest(name);
1413
1414
  }
1414
1415
  assert(options) {
1415
- var _a, _b;
1416
+ var _a, _b, _c, _d;
1416
1417
  const {
1417
1418
  filepath = this.filepath,
1418
1419
  name = this.name,
@@ -1433,7 +1434,7 @@ class SnapshotClient {
1433
1434
  try {
1434
1435
  const pass2 = ((_b = (_a = this.options).isEqual) == null ? void 0 : _b.call(_a, received, properties)) ?? false;
1435
1436
  if (!pass2)
1436
- throw createMismatchError("Snapshot properties mismatched", received, properties);
1437
+ throw createMismatchError("Snapshot properties mismatched", (_c = this.snapshotState) == null ? void 0 : _c.expand, received, properties);
1437
1438
  else
1438
1439
  received = deepMergeSnapshot(received, properties);
1439
1440
  } catch (err) {
@@ -1455,7 +1456,7 @@ class SnapshotClient {
1455
1456
  rawSnapshot
1456
1457
  });
1457
1458
  if (!pass)
1458
- throw createMismatchError(`Snapshot \`${key || "unknown"}\` mismatched`, actual == null ? void 0 : actual.trim(), expected == null ? void 0 : expected.trim());
1459
+ throw createMismatchError(`Snapshot \`${key || "unknown"}\` mismatched`, (_d = this.snapshotState) == null ? void 0 : _d.expand, actual == null ? void 0 : actual.trim(), expected == null ? void 0 : expected.trim());
1459
1460
  }
1460
1461
  async assertRaw(options) {
1461
1462
  if (!options.rawSnapshot)
package/dist/manager.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { S as SnapshotStateOptions, e as SnapshotSummary, b as SnapshotResult } from './index-d5eca340.js';
1
+ import { S as SnapshotStateOptions, e as SnapshotSummary, b as SnapshotResult } from './index-lPCXZXKD.js';
2
2
  import 'pretty-format';
3
- import './environment-e71c592b.js';
3
+ import './environment-AwZ-cC__.js';
4
4
 
5
5
  declare class SnapshotManager {
6
6
  options: Omit<SnapshotStateOptions, 'snapshotEnvironment'>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/snapshot",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.3",
4
+ "version": "1.0.0-beta.5",
5
5
  "description": "Vitest snapshot manager",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -18,15 +18,15 @@
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js"
21
+ "default": "./dist/index.js"
22
22
  },
23
23
  "./environment": {
24
24
  "types": "./dist/environment.d.ts",
25
- "import": "./dist/environment.js"
25
+ "default": "./dist/environment.js"
26
26
  },
27
27
  "./manager": {
28
28
  "types": "./dist/manager.d.ts",
29
- "import": "./dist/manager.js"
29
+ "default": "./dist/manager.js"
30
30
  },
31
31
  "./*": "./*"
32
32
  },
@@ -34,18 +34,18 @@
34
34
  "module": "./dist/index.js",
35
35
  "types": "./dist/index.d.ts",
36
36
  "files": [
37
- "dist",
38
- "*.d.ts"
37
+ "*.d.ts",
38
+ "dist"
39
39
  ],
40
40
  "dependencies": {
41
41
  "magic-string": "^0.30.5",
42
42
  "pathe": "^1.1.1",
43
- "pretty-format": "^29.5.0"
43
+ "pretty-format": "^29.7.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/natural-compare": "^1.4.1",
46
+ "@types/natural-compare": "^1.4.3",
47
47
  "natural-compare": "^1.4.0",
48
- "@vitest/utils": "1.0.0-beta.3"
48
+ "@vitest/utils": "1.0.0-beta.5"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "rimraf dist && rollup -c",