@vitest/snapshot 0.30.0 → 0.30.1
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/dist/{environment-8fbbf71b.d.ts → environment-38cdead3.d.ts} +1 -1
- package/dist/environment.d.ts +2 -2
- package/dist/environment.js +3 -2
- package/dist/{index-2c775746.d.ts → index-6461367c.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -1
- package/dist/manager.d.ts +2 -2
- package/environment.d.ts +1 -0
- package/manager.d.ts +1 -0
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ interface SnapshotEnvironment {
|
|
|
3
3
|
getHeader(): string;
|
|
4
4
|
resolvePath(filepath: string): Promise<string>;
|
|
5
5
|
resolveRawPath(testPath: string, rawPath: string): Promise<string>;
|
|
6
|
-
prepareDirectory(
|
|
6
|
+
prepareDirectory(dirPath: string): Promise<void>;
|
|
7
7
|
saveSnapshotFile(filepath: string, snapshot: string): Promise<void>;
|
|
8
8
|
readSnapshotFile(filepath: string): Promise<string | null>;
|
|
9
9
|
removeSnapshotFile(filepath: string): Promise<void>;
|
package/dist/environment.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { S as SnapshotEnvironment } from './environment-
|
|
1
|
+
import { S as SnapshotEnvironment } from './environment-38cdead3.js';
|
|
2
2
|
|
|
3
3
|
declare class NodeSnapshotEnvironment implements SnapshotEnvironment {
|
|
4
4
|
getVersion(): string;
|
|
5
5
|
getHeader(): string;
|
|
6
6
|
resolveRawPath(testPath: string, rawPath: string): Promise<string>;
|
|
7
7
|
resolvePath(filepath: string): Promise<string>;
|
|
8
|
-
prepareDirectory(
|
|
8
|
+
prepareDirectory(dirPath: string): Promise<void>;
|
|
9
9
|
saveSnapshotFile(filepath: string, snapshot: string): Promise<void>;
|
|
10
10
|
readSnapshotFile(filepath: string): Promise<string | null>;
|
|
11
11
|
removeSnapshotFile(filepath: string): Promise<void>;
|
package/dist/environment.js
CHANGED
|
@@ -20,10 +20,11 @@ class NodeSnapshotEnvironment {
|
|
|
20
20
|
`${basename(filepath)}.snap`
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
|
-
async prepareDirectory(
|
|
24
|
-
await promises.mkdir(
|
|
23
|
+
async prepareDirectory(dirPath) {
|
|
24
|
+
await promises.mkdir(dirPath, { recursive: true });
|
|
25
25
|
}
|
|
26
26
|
async saveSnapshotFile(filepath, snapshot) {
|
|
27
|
+
await promises.mkdir(dirname(filepath), { recursive: true });
|
|
27
28
|
await promises.writeFile(filepath, snapshot, "utf-8");
|
|
28
29
|
}
|
|
29
30
|
async readSnapshotFile(filepath) {
|
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-
|
|
2
|
-
export { c as SnapshotData, e as SnapshotSummary, d as SnapshotUpdateState, U as UncheckedSnapshot } from './index-
|
|
3
|
-
import { S as SnapshotEnvironment } from './environment-
|
|
1
|
+
import { S as SnapshotStateOptions, a as SnapshotMatchOptions, b as SnapshotResult, R as RawSnapshotInfo } from './index-6461367c.js';
|
|
2
|
+
export { c as SnapshotData, e as SnapshotSummary, d as SnapshotUpdateState, U as UncheckedSnapshot } from './index-6461367c.js';
|
|
3
|
+
import { S as SnapshotEnvironment } from './environment-38cdead3.js';
|
|
4
4
|
import { Plugin, Plugins } from 'pretty-format';
|
|
5
5
|
|
|
6
6
|
interface ParsedStack {
|
package/dist/index.js
CHANGED
|
@@ -424,7 +424,7 @@ async function saveSnapshotFile(environment, snapshotData, snapshotPath) {
|
|
|
424
424
|
${snapshots.join("\n\n")}
|
|
425
425
|
`;
|
|
426
426
|
const oldContent = await environment.readSnapshotFile(snapshotPath);
|
|
427
|
-
const skipWriting = oldContent && oldContent === content;
|
|
427
|
+
const skipWriting = oldContent != null && oldContent === content;
|
|
428
428
|
if (skipWriting)
|
|
429
429
|
return;
|
|
430
430
|
await ensureDirectoryExists(environment, snapshotPath);
|
|
@@ -726,6 +726,10 @@ ${JSON.stringify(stacks)}`
|
|
|
726
726
|
let receivedSerialized = rawSnapshot && typeof received === "string" ? received : serialize(received, void 0, this._snapshotFormat);
|
|
727
727
|
if (!rawSnapshot)
|
|
728
728
|
receivedSerialized = addExtraLineBreaks(receivedSerialized);
|
|
729
|
+
if (rawSnapshot) {
|
|
730
|
+
if (rawSnapshot.content && rawSnapshot.content.match(/\r\n/) && !receivedSerialized.match(/\r\n/))
|
|
731
|
+
rawSnapshot.content = normalizeNewlines(rawSnapshot.content);
|
|
732
|
+
}
|
|
729
733
|
const expected = isInline ? inlineSnapshot : rawSnapshot ? rawSnapshot.content : this._snapshotData[key];
|
|
730
734
|
const expectedTrimmed = prepareExpected(expected);
|
|
731
735
|
const pass = expectedTrimmed === prepareExpected(receivedSerialized);
|
package/dist/manager.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SnapshotStateOptions, e as SnapshotSummary, b as SnapshotResult } from './index-
|
|
1
|
+
import { S as SnapshotStateOptions, e as SnapshotSummary, b as SnapshotResult } from './index-6461367c.js';
|
|
2
2
|
import 'pretty-format';
|
|
3
|
-
import './environment-
|
|
3
|
+
import './environment-38cdead3.js';
|
|
4
4
|
|
|
5
5
|
declare class SnapshotManager {
|
|
6
6
|
options: Omit<SnapshotStateOptions, 'snapshotEnvironment'>;
|
package/environment.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/environment.js'
|
package/manager.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/manager.js'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/snapshot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.30.
|
|
4
|
+
"version": "0.30.1",
|
|
5
5
|
"description": "Vitest Snapshot Resolver",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/natural-compare": "^1.4.1",
|
|
42
42
|
"natural-compare": "^1.4.0",
|
|
43
|
-
"@vitest/utils": "0.30.
|
|
43
|
+
"@vitest/utils": "0.30.1"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rimraf dist && rollup -c",
|