Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb37f48d

Browse files
committed
update tests
1 parent7abba69 commitb37f48d

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

‎e2e/native-esm/__tests__/native-esm.test.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,22 @@ test('should have correct import.meta', () => {
2828
expect(typeofrequire).toBe('undefined');
2929
expect(typeofjest).toBe('undefined');
3030
expect(import.meta).toEqual({
31+
dirname:expect.any(String),
32+
filename:expect.any(String),
3133
jest:expect.anything(),
3234
url:expect.any(String),
3335
});
3436
expect(import.meta.jest).toBe(jestObject);
3537
expect(
3638
import.meta.url.endsWith('/e2e/native-esm/__tests__/native-esm.test.js'),
3739
).toBe(true);
40+
expect(
41+
import.meta.filename.endsWith(
42+
'/e2e/native-esm/__tests__/native-esm.test.js',
43+
),
44+
).toBe(true);
45+
expect(import.meta.filename.startsWith('/')).toBe(true);
46+
expect(import.meta.dirname.endsWith('/e2e/native-esm/__tests__')).toBe(true);
3847
});
3948

4049
test('should double stuff',()=>{

‎e2e/runJest.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ function spawnJest(
102102
timeout:options.timeout||0,
103103
};
104104

105+
console.log('ARGS',spawnArgs);
106+
105107
return(spawnAsync ?execa :execa.sync)(
106108
process.execPath,
107109
spawnArgs,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test('inline snapshots',async()=>{
2+
expect(Promise.resolve('success')).resolves.toMatchInlineSnapshot();
3+
expect(Promise.reject('fail')).rejects.toMatchInlineSnapshot();
4+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`handles property matchers with deep properties 1`]=`
4+
{
5+
"user": {
6+
"createdAt":Any<Date>,
7+
"name": "Jest",
8+
},
9+
}
10+
`;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test('handles property matchers with deep properties',()=>{
2+
expect({user:{createdAt:newDate(),name:"Jest"}}).toMatchSnapshot({user:{createdAt:expect.any(Date),name:"Jest"}});
3+
});

‎packages/jest-runtime/src/index.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,10 @@ export default class Runtime {
521521
meta.url=pathToFileURL(modulePath).href;
522522

523523
if(meta.url.startsWith('file://')){
524+
//@ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/node@20.11.0
524525
meta.filename=fileURLToPath(meta.url);
525-
meta.dirname=path.resolve(meta.filename);
526+
//@ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/node@20.11.0
527+
meta.dirname=path.dirname(meta.filename);
526528
}
527529

528530
letjest=this.jestObjectCaches.get(modulePath);
@@ -682,7 +684,7 @@ export default class Runtime {
682684
//@ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/node@20.11.0
683685
meta.filename=fileURLToPath(meta.url);
684686
//@ts-expect-error Jest uses @types/node@16. Will be fixed when updated to @types/node@20.11.0
685-
meta.dirname=path.resolve(meta.filename);
687+
meta.dirname=path.dirname(meta.filename);
686688
}
687689
},
688690
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp