@vitest/snapshot 1.6.0 → 2.0.0-beta.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.
@@ -1,4 +1,4 @@
1
- import { S as SnapshotEnvironment, a as SnapshotEnvironmentOptions } from './environment-cMiGIVXz.js';
1
+ import { S as SnapshotEnvironment, a as SnapshotEnvironmentOptions } from './environment-BaTWxlGj.js';
2
2
 
3
3
  declare class NodeSnapshotEnvironment implements SnapshotEnvironment {
4
4
  private options;
@@ -1,5 +1,5 @@
1
1
  import { Plugin, OptionsReceived } from 'pretty-format';
2
- import { S as SnapshotEnvironment } from './environment-cMiGIVXz.js';
2
+ import { S as SnapshotEnvironment } from './environment-BaTWxlGj.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-S94ASl6q.js';
2
- export { c as SnapshotData, e as SnapshotSerializer, f as SnapshotSummary, d as SnapshotUpdateState, U as UncheckedSnapshot } from './index-S94ASl6q.js';
3
- import { S as SnapshotEnvironment } from './environment-cMiGIVXz.js';
1
+ import { S as SnapshotStateOptions, a as SnapshotMatchOptions, b as SnapshotResult, R as RawSnapshotInfo } from './index-CTmsp3V1.js';
2
+ export { c as SnapshotData, e as SnapshotSerializer, f as SnapshotSummary, d as SnapshotUpdateState, U as UncheckedSnapshot } from './index-CTmsp3V1.js';
3
+ import { S as SnapshotEnvironment } from './environment-BaTWxlGj.js';
4
4
  import { Plugin, Plugins } from 'pretty-format';
5
5
 
6
6
  interface ParsedStack {
package/dist/index.js CHANGED
@@ -105,18 +105,20 @@ function getCallLastIndex(code) {
105
105
 
106
106
  let getPromiseValue = () => 'Promise{…}';
107
107
  try {
108
- const { getPromiseDetails, kPending, kRejected } = process.binding('util');
109
- if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
110
- getPromiseValue = (value, options) => {
111
- const [state, innerValue] = getPromiseDetails(value);
112
- if (state === kPending) {
113
- return 'Promise{<pending>}'
114
- }
115
- return `Promise${state === kRejected ? '!' : ''}{${options.inspect(innerValue, options)}}`
116
- };
117
- }
118
- } catch (notNode) {
119
- /* ignore */
108
+ // @ts-ignore
109
+ const { getPromiseDetails, kPending, kRejected } = process.binding('util');
110
+ if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
111
+ getPromiseValue = (value, options) => {
112
+ const [state, innerValue] = getPromiseDetails(value);
113
+ if (state === kPending) {
114
+ return 'Promise{<pending>}';
115
+ }
116
+ return `Promise${state === kRejected ? '!' : ''}{${options.inspect(innerValue, options)}}`;
117
+ };
118
+ }
119
+ }
120
+ catch (notNode) {
121
+ /* ignore */
120
122
  }
121
123
 
122
124
  /* !
@@ -124,14 +126,15 @@ try {
124
126
  * Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
125
127
  * MIT Licensed
126
128
  */
127
-
128
129
  let nodeInspect = false;
129
130
  try {
130
- // eslint-disable-next-line global-require
131
- const nodeUtil = require('util');
132
- nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
133
- } catch (noNodeInspect) {
134
- nodeInspect = false;
131
+ // eslint-disable-next-line global-require
132
+ // @ts-ignore
133
+ const nodeUtil = require('util');
134
+ nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
135
+ }
136
+ catch (noNodeInspect) {
137
+ nodeInspect = false;
135
138
  }
136
139
 
137
140
  const lineSplitRE = /\r?\n/;
@@ -370,8 +373,7 @@ function deepMergeSnapshot(target, source) {
370
373
  if (isObject(source[key]) && !source[key].$$typeof) {
371
374
  if (!(key in target))
372
375
  Object.assign(mergedOutput, { [key]: source[key] });
373
- else
374
- mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
376
+ else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
375
377
  } else if (Array.isArray(source[key])) {
376
378
  mergedOutput[key] = deepMergeArray(target[key], source[key]);
377
379
  } else {
@@ -857,16 +859,6 @@ const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
857
859
  const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
858
860
  const LEAST_UPPER_BOUND = -1;
859
861
  const GREATEST_LOWER_BOUND = 1;
860
- /**
861
- * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
862
- */
863
- let decodedMappings;
864
- /**
865
- * A higher-level API to find the source/line/column associated with a generated line/column
866
- * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
867
- * `source-map` library.
868
- */
869
- let originalPositionFor;
870
862
  class TraceMap {
871
863
  constructor(map, mapUrl) {
872
864
  const isString = typeof map === 'string';
@@ -880,6 +872,7 @@ class TraceMap {
880
872
  this.sourceRoot = sourceRoot;
881
873
  this.sources = sources;
882
874
  this.sourcesContent = sourcesContent;
875
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
883
876
  const from = resolve(sourceRoot || '', stripFilename(mapUrl));
884
877
  this.resolvedSources = sources.map((s) => resolve(s || '', from));
885
878
  const { mappings } = parsed;
@@ -896,32 +889,47 @@ class TraceMap {
896
889
  this._bySourceMemos = undefined;
897
890
  }
898
891
  }
899
- (() => {
900
- decodedMappings = (map) => {
901
- return (map._decoded || (map._decoded = decode(map._encoded)));
902
- };
903
- originalPositionFor = (map, { line, column, bias }) => {
904
- line--;
905
- if (line < 0)
906
- throw new Error(LINE_GTR_ZERO);
907
- if (column < 0)
908
- throw new Error(COL_GTR_EQ_ZERO);
909
- const decoded = decodedMappings(map);
910
- // It's common for parent source maps to have pointers to lines that have no
911
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
912
- if (line >= decoded.length)
913
- return OMapping(null, null, null, null);
914
- const segments = decoded[line];
915
- const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
916
- if (index === -1)
917
- return OMapping(null, null, null, null);
918
- const segment = segments[index];
919
- if (segment.length === 1)
920
- return OMapping(null, null, null, null);
921
- const { names, resolvedSources } = map;
922
- return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
923
- };
924
- })();
892
+ /**
893
+ * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
894
+ * with public access modifiers.
895
+ */
896
+ function cast(map) {
897
+ return map;
898
+ }
899
+ /**
900
+ * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
901
+ */
902
+ function decodedMappings(map) {
903
+ var _a;
904
+ return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)));
905
+ }
906
+ /**
907
+ * A higher-level API to find the source/line/column associated with a generated line/column
908
+ * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
909
+ * `source-map` library.
910
+ */
911
+ function originalPositionFor(map, needle) {
912
+ let { line, column, bias } = needle;
913
+ line--;
914
+ if (line < 0)
915
+ throw new Error(LINE_GTR_ZERO);
916
+ if (column < 0)
917
+ throw new Error(COL_GTR_EQ_ZERO);
918
+ const decoded = decodedMappings(map);
919
+ // It's common for parent source maps to have pointers to lines that have no
920
+ // mapping (like a "//# sourceMappingURL=") at the end of the child file.
921
+ if (line >= decoded.length)
922
+ return OMapping(null, null, null, null);
923
+ const segments = decoded[line];
924
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
925
+ if (index === -1)
926
+ return OMapping(null, null, null, null);
927
+ const segment = segments[index];
928
+ if (segment.length === 1)
929
+ return OMapping(null, null, null, null);
930
+ const { names, resolvedSources } = map;
931
+ return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
932
+ }
925
933
  function OMapping(source, line, column, name) {
926
934
  return { source, line, column, name };
927
935
  }
package/dist/manager.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { S as SnapshotStateOptions, f as SnapshotSummary, b as SnapshotResult } from './index-S94ASl6q.js';
1
+ import { S as SnapshotStateOptions, f as SnapshotSummary, b as SnapshotResult } from './index-CTmsp3V1.js';
2
2
  import 'pretty-format';
3
- import './environment-cMiGIVXz.js';
3
+ import './environment-BaTWxlGj.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.6.0",
4
+ "version": "2.0.0-beta.2",
5
5
  "description": "Vitest snapshot manager",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -38,14 +38,14 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "magic-string": "^0.30.5",
42
- "pathe": "^1.1.1",
41
+ "magic-string": "^0.30.10",
42
+ "pathe": "^1.1.2",
43
43
  "pretty-format": "^29.7.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/natural-compare": "^1.4.3",
47
47
  "natural-compare": "^1.4.0",
48
- "@vitest/utils": "1.6.0"
48
+ "@vitest/utils": "2.0.0-beta.2"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "rimraf dist && rollup -c",