Skip to content

Commit 3f206ce

Browse files
test: build the generator fixtures under a real path
`os.tmpdir()` is a symlink on macOS, and webpack resolves a module through the real path, so a module under a symlinked context is not named relative to it — `./image.jpg` came back as `../<realdir>/image.jpg` and the lookup found nothing. Latent until now: both tests return early unless `processResult` can be awaited, which webpack 5.111.0 shipped today, so this is the first run in which they execute at all.
1 parent d4b3096 commit 3f206ce

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎test/generate-option.test.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,12 @@ describe("generate option in watch mode", () => {
12551255

12561256
beforeEach(() => {
12571257
toWebp.calls = 0;
1258-
context = fs.mkdtempSync(path.join(os.tmpdir(), "minimizer-watch-"));
1258+
// Through `realpathSync`: `os.tmpdir()` is a symlink on macOS, and webpack
1259+
// resolves a module through the real path, so a module under a symlinked
1260+
// context is not named relative to it.
1261+
context = fs.realpathSync(
1262+
fs.mkdtempSync(path.join(os.tmpdir(), "minimizer-watch-")),
1263+
);
12591264

12601265
fs.writeFileSync(
12611266
path.join(context, "index.js"),
@@ -1393,7 +1398,9 @@ describe("generate option with the filesystem cache", () => {
13931398
beforeEach(() => {
13941399
toWebp.calls = 0;
13951400
toAvif.calls = 0;
1396-
context = fs.mkdtempSync(path.join(os.tmpdir(), "minimizer-fs-cache-"));
1401+
context = fs.realpathSync(
1402+
fs.mkdtempSync(path.join(os.tmpdir(), "minimizer-fs-cache-")),
1403+
);
13971404
cacheDirectory = path.join(context, "cache");
13981405

13991406
fs.writeFileSync(

0 commit comments

Comments
 (0)