Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alesmenzel committed Jan 15, 2024
1 parent 7abba69 commit d04fb81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions e2e/native-esm/__tests__/native-esm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,22 @@ test('should have correct import.meta', () => {
expect(typeof require).toBe('undefined');
expect(typeof jest).toBe('undefined');
expect(import.meta).toEqual({
dirname: expect.any(String),
filename: expect.any(String),
jest: expect.anything(),
url: expect.any(String),
});
expect(import.meta.jest).toBe(jestObject);
expect(
import.meta.url.endsWith('/e2e/native-esm/__tests__/native-esm.test.js'),
).toBe(true);
expect(
import.meta.filename.endsWith(
'/e2e/native-esm/__tests__/native-esm.test.js',
),
).toBe(true);
expect(import.meta.filename.startsWith('/')).toBe(true);
expect(import.meta.dirname.endsWith('/e2e/native-esm/__tests__')).toBe(true);
});

test('should double stuff', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/jest-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,10 @@ export default class Runtime {
meta.url = pathToFileURL(modulePath).href;

if (meta.url.startsWith('file://')) {
// @ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/[email protected]
meta.filename = fileURLToPath(meta.url);
meta.dirname = path.resolve(meta.filename);
// @ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/[email protected]
meta.dirname = path.dirname(meta.filename);
}

let jest = this.jestObjectCaches.get(modulePath);
Expand Down Expand Up @@ -682,7 +684,7 @@ export default class Runtime {
// @ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/[email protected]
meta.filename = fileURLToPath(meta.url);
// @ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/[email protected]
meta.dirname = path.resolve(meta.filename);
meta.dirname = path.dirname(meta.filename);
}
},
});
Expand Down

0 comments on commit d04fb81

Please sign in to comment.