Skip to content

Commit e6864e4

Browse files
author
Steven Hargrove
committed
support windows for snapshot
1 parent 82b7428 commit e6864e4

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

test/Errors.test.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fs = require("fs");
66
const webpack = require("..");
77
const prettyFormat = require("pretty-format");
88

9-
const CWD_PATTERN = new RegExp(`${process.cwd()}`.replace(/\/|\\/, "/"), "gm");
9+
const CWD_PATTERN = new RegExp(process.cwd().replace(/\\/g, "/"), "gm");
1010
const ERROR_STACK_PATTERN = /(?:\n\s+at[^()]+\(?.*\)?)+/gm;
1111

1212
function cleanError(err) {
@@ -63,17 +63,13 @@ const prettyFormatOptions = {
6363
return typeof val === "string";
6464
},
6565
print(val) {
66-
return `"${val.replace(/\n/gm, "\\n").replace(/"/gm, '\\"')}"`;
66+
return `"${val
67+
.replace(/\\/gm, "/")
68+
.replace(/"/gm, '\\"')
69+
.replace(/\n/gm, "\\n")
70+
}"`;
6771
}
68-
},
69-
// {
70-
// test(val) {
71-
// return typeof val === "object" && typeof val.loc !== "undefined";
72-
// },
73-
// print(val) {
74-
// return `"${val.replace(/\n/gm, "\\n").replace(/"/gm, '\\"')}"`;
75-
// }
76-
// }
72+
}
7773
]
7874
};
7975

@@ -100,7 +96,7 @@ expect.addSnapshotSerializer({
10096

10197
const defaults = {
10298
options: {
103-
context: path.resolve(__dirname, "fixtures/errors"),
99+
context: path.resolve(__dirname, "fixtures", "errors"),
104100
mode: "none",
105101
devtool: false,
106102
optimization: {
@@ -242,7 +238,7 @@ Object {
242238
});
243239

244240
const isCasePreservedFilesystem = fs.existsSync(
245-
path.resolve(__dirname, "fixtures/errors/FILE.js")
241+
path.resolve(__dirname, "fixtures", "errors", "FILE.js")
246242
);
247243
if (isCasePreservedFilesystem) {
248244
it("should emit warning for case-preserved disk", async () => {

0 commit comments

Comments
 (0)