Skip to content

Commit 65cc7aa

Browse files
committed
fix: remove cwd from snapshots
1 parent 008f9a6 commit 65cc7aa

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

test/__snapshots__/modules-option.test.js.snap

+28-28
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ Array [
11861186
"replacementName": "___CSS_LOADER_ICSS_IMPORT_1_REPLACEMENT_1___",
11871187
},
11881188
],
1189-
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/source.css",
1189+
"resourcePath": "/test/fixtures/modules/getJSON/source.css",
11901190
},
11911191
],
11921192
Array [
@@ -1209,7 +1209,7 @@ Array [
12091209
},
12101210
],
12111211
"replacements": Array [],
1212-
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/composeSourceB.css",
1212+
"resourcePath": "/test/fixtures/modules/getJSON/composeSourceB.css",
12131213
},
12141214
],
12151215
Array [
@@ -1236,7 +1236,7 @@ Array [
12361236
},
12371237
],
12381238
"replacements": Array [],
1239-
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/composeSourceC.css",
1239+
"resourcePath": "/test/fixtures/modules/getJSON/composeSourceC.css",
12401240
},
12411241
],
12421242
]
@@ -1344,29 +1344,6 @@ exports[`"modules" option should invoke the custom getJSON function with getJSON
13441344

13451345
exports[`"modules" option should invoke the custom getJSON function with getJSON as an asynchronous function: args 1`] = `
13461346
Array [
1347-
Array [
1348-
Object {
1349-
"exports": Array [
1350-
Object {
1351-
"name": "composedB",
1352-
"value": "gFdUXtR3F_6oyBd_qgU8",
1353-
},
1354-
],
1355-
"imports": Array [
1356-
Object {
1357-
"importName": "___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___",
1358-
"url": "\\"../../../../src/runtime/noSourceMaps.js\\"",
1359-
},
1360-
Object {
1361-
"importName": "___CSS_LOADER_API_IMPORT___",
1362-
"type": "api_import",
1363-
"url": "\\"../../../../src/runtime/api.js\\"",
1364-
},
1365-
],
1366-
"replacements": Array [],
1367-
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/composeSourceB.css",
1368-
},
1369-
],
13701347
Array [
13711348
Object {
13721349
"exports": Array [
@@ -1429,7 +1406,30 @@ Array [
14291406
"replacementName": "___CSS_LOADER_ICSS_IMPORT_1_REPLACEMENT_1___",
14301407
},
14311408
],
1432-
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/source.css",
1409+
"resourcePath": "/test/fixtures/modules/getJSON/source.css",
1410+
},
1411+
],
1412+
Array [
1413+
Object {
1414+
"exports": Array [
1415+
Object {
1416+
"name": "composedB",
1417+
"value": "gFdUXtR3F_6oyBd_qgU8",
1418+
},
1419+
],
1420+
"imports": Array [
1421+
Object {
1422+
"importName": "___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___",
1423+
"url": "\\"../../../../src/runtime/noSourceMaps.js\\"",
1424+
},
1425+
Object {
1426+
"importName": "___CSS_LOADER_API_IMPORT___",
1427+
"type": "api_import",
1428+
"url": "\\"../../../../src/runtime/api.js\\"",
1429+
},
1430+
],
1431+
"replacements": Array [],
1432+
"resourcePath": "/test/fixtures/modules/getJSON/composeSourceB.css",
14331433
},
14341434
],
14351435
Array [
@@ -1456,7 +1456,7 @@ Array [
14561456
},
14571457
],
14581458
"replacements": Array [],
1459-
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/composeSourceC.css",
1459+
"resourcePath": "/test/fixtures/modules/getJSON/composeSourceC.css",
14601460
},
14611461
],
14621462
]

test/helpers/normalizeErrors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import stripAnsi from "strip-ansi";
22

3-
function removeCWD(str) {
3+
export function removeCWD(str) {
44
const isWin = process.platform === "win32";
55
let cwd = process.cwd();
66

test/modules-option.test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
getWarnings,
1313
readAsset,
1414
} from "./helpers/index";
15+
import { removeCWD } from "./helpers/normalizeErrors";
1516

1617
const modulesFixturesPath = path.join(__dirname, "fixtures/modules");
1718
const testCasesPath = path.join(modulesFixturesPath, "tests-cases");
@@ -2432,7 +2433,7 @@ describe('"modules" option', () => {
24322433
const args = getJSONSpy.mock.calls.map((arg) => [
24332434
{
24342435
...arg[0],
2435-
resourcePath: arg[0].resourcePath.replace(process.cwd(), "<ROOT_DIR>"),
2436+
resourcePath: removeCWD(arg[0].resourcePath),
24362437
},
24372438
]);
24382439
expect(args).toMatchSnapshot("args");
@@ -2460,7 +2461,7 @@ describe('"modules" option', () => {
24602461
const args = getJSONSpy.mock.calls.map((arg) => [
24612462
{
24622463
...arg[0],
2463-
resourcePath: arg[0].resourcePath.replace(process.cwd(), "<ROOT_DIR>"),
2464+
resourcePath: removeCWD(arg[0].resourcePath),
24642465
},
24652466
]);
24662467
expect(args).toMatchSnapshot("args");

0 commit comments

Comments
 (0)