Skip to content

Commit 489e604

Browse files
avoid mocking node:path
1 parent 0783709 commit 489e604

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

apps/site/next-data/generators/__tests__/blogData.test.mjs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1+
import { normalize } from 'node:path';
12
import { Readable } from 'node:stream';
23

34
import generateBlogData from '@/next-data/generators/blogData.mjs';
45

56
let files = [];
67

7-
jest.mock('node:path', () => ({
8-
...jest.requireActual('node:path'),
9-
join: jest.fn((_base, filePath) => filePath),
10-
}));
11-
128
jest.mock('node:fs', () => {
139
const originalFs = jest.requireActual('node:fs');
1410
return {
1511
...originalFs,
1612
createReadStream: jest.fn(filename => {
1713
const readable = new Readable();
18-
const file = files.find(f => f.path === filename);
14+
const file = files.find(f => filename.endsWith(normalize(f.path)));
1915
readable.push(`---\n`);
2016
file.frontMatterContent.forEach(line => readable.push(`${line}\n`));
2117
readable.push(`---\n`);

0 commit comments

Comments
 (0)