Skip to content

Commit

Permalink
fix: remove cwd from snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenkao committed Apr 4, 2024
1 parent 008f9a6 commit 65cc7aa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
56 changes: 28 additions & 28 deletions test/__snapshots__/modules-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ Array [
"replacementName": "___CSS_LOADER_ICSS_IMPORT_1_REPLACEMENT_1___",
},
],
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/source.css",
"resourcePath": "/test/fixtures/modules/getJSON/source.css",
},
],
Array [
Expand All @@ -1209,7 +1209,7 @@ Array [
},
],
"replacements": Array [],
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/composeSourceB.css",
"resourcePath": "/test/fixtures/modules/getJSON/composeSourceB.css",
},
],
Array [
Expand All @@ -1236,7 +1236,7 @@ Array [
},
],
"replacements": Array [],
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/composeSourceC.css",
"resourcePath": "/test/fixtures/modules/getJSON/composeSourceC.css",
},
],
]
Expand Down Expand Up @@ -1344,29 +1344,6 @@ exports[`"modules" option should invoke the custom getJSON function with getJSON

exports[`"modules" option should invoke the custom getJSON function with getJSON as an asynchronous function: args 1`] = `
Array [
Array [
Object {
"exports": Array [
Object {
"name": "composedB",
"value": "gFdUXtR3F_6oyBd_qgU8",
},
],
"imports": Array [
Object {
"importName": "___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___",
"url": "\\"../../../../src/runtime/noSourceMaps.js\\"",
},
Object {
"importName": "___CSS_LOADER_API_IMPORT___",
"type": "api_import",
"url": "\\"../../../../src/runtime/api.js\\"",
},
],
"replacements": Array [],
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/composeSourceB.css",
},
],
Array [
Object {
"exports": Array [
Expand Down Expand Up @@ -1429,7 +1406,30 @@ Array [
"replacementName": "___CSS_LOADER_ICSS_IMPORT_1_REPLACEMENT_1___",
},
],
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/source.css",
"resourcePath": "/test/fixtures/modules/getJSON/source.css",
},
],
Array [
Object {
"exports": Array [
Object {
"name": "composedB",
"value": "gFdUXtR3F_6oyBd_qgU8",
},
],
"imports": Array [
Object {
"importName": "___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___",
"url": "\\"../../../../src/runtime/noSourceMaps.js\\"",
},
Object {
"importName": "___CSS_LOADER_API_IMPORT___",
"type": "api_import",
"url": "\\"../../../../src/runtime/api.js\\"",
},
],
"replacements": Array [],
"resourcePath": "/test/fixtures/modules/getJSON/composeSourceB.css",
},
],
Array [
Expand All @@ -1456,7 +1456,7 @@ Array [
},
],
"replacements": Array [],
"resourcePath": "<ROOT_DIR>/test/fixtures/modules/getJSON/composeSourceC.css",
"resourcePath": "/test/fixtures/modules/getJSON/composeSourceC.css",
},
],
]
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/normalizeErrors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import stripAnsi from "strip-ansi";

function removeCWD(str) {
export function removeCWD(str) {
const isWin = process.platform === "win32";
let cwd = process.cwd();

Expand Down
5 changes: 3 additions & 2 deletions test/modules-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getWarnings,
readAsset,
} from "./helpers/index";
import { removeCWD } from "./helpers/normalizeErrors";

const modulesFixturesPath = path.join(__dirname, "fixtures/modules");
const testCasesPath = path.join(modulesFixturesPath, "tests-cases");
Expand Down Expand Up @@ -2432,7 +2433,7 @@ describe('"modules" option', () => {
const args = getJSONSpy.mock.calls.map((arg) => [
{
...arg[0],
resourcePath: arg[0].resourcePath.replace(process.cwd(), "<ROOT_DIR>"),
resourcePath: removeCWD(arg[0].resourcePath),
},
]);
expect(args).toMatchSnapshot("args");
Expand Down Expand Up @@ -2460,7 +2461,7 @@ describe('"modules" option', () => {
const args = getJSONSpy.mock.calls.map((arg) => [
{
...arg[0],
resourcePath: arg[0].resourcePath.replace(process.cwd(), "<ROOT_DIR>"),
resourcePath: removeCWD(arg[0].resourcePath),
},
]);
expect(args).toMatchSnapshot("args");
Expand Down

0 comments on commit 65cc7aa

Please sign in to comment.