Skip to content

Commit 0a608b3

Browse files
committed
feat: make all ESM module locked as dynamic import
1 parent 1ac68e5 commit 0a608b3

39 files changed

+900
-598
lines changed

biome.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
},
1010
"files": {
1111
"ignoreUnknown": true,
12-
"includes": ["**", "!**/*.vue", "!**/dist", "!**/dist-types"]
12+
"includes": [
13+
"**",
14+
"!**/*.vue",
15+
"!**/dist/**",
16+
"!**/dist-types/**",
17+
"!tests/mock/tests/mockHoist.test.ts"
18+
]
1319
},
1420
"formatter": {
1521
"indentStyle": "space"

e2e/__mocks__/is-url.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const { rs } = require('@rstest/core');
2+
3+
module.exports = () => 'is-url mock';
4+
module.exports.fn = rs.fn();

e2e/__mocks__/redux-cjs.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { rs } = require('@rstest/core');
2+
3+
module.exports = {
4+
isAction: rs.fn(),
5+
mocked: 'redux_yes',
6+
};

e2e/lifecycle/timeout.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('test timeout', () => {
3434
),
3535
).toBeTruthy();
3636
expect(
37-
logs.find((log) => log.includes('timeout.test.ts:4:10')),
37+
logs.find((log) => log.includes('timeout.test.ts:4:1')),
3838
).toBeTruthy();
3939
expect(
4040
logs.find((log) => log.includes('Test Files 1 failed')),

e2e/mock/fixtures/unmock/rstest.setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { rs } from '@rstest/core';
1+
// import { rs } from '@rstest/core';
22

33
process.env.NODE_ENV = 'rstest:production';
44

e2e/mock/src/bar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const bar = 'bar';

e2e/mock/src/foo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const foo = 'foo'

e2e/mock/src/readSomeFile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { readFileSync } from 'node:fs';
1+
import * as fs from 'node:fs';
22

33
export function readSomeFile(path: string) {
4-
return readFileSync(path, 'utf-8');
4+
return fs?.readFileSync?.(path, 'utf-8');
55
}

e2e/mock/src/sum.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import * as fooMod from './foo.js';
2+
3+
export const sum = fooMod?.foo + '1';

e2e/mock/tests/barrel.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { expect, it, rs } from '@rstest/core';
2+
import * as barMod from '../src/bar';
3+
import { sum } from '../src/sum';
4+
5+
rs.mock('../src/foo', async () => {
6+
return { foo: barMod.bar };
7+
});
8+
9+
it('sum', () => {
10+
expect(sum).toBe('bar1');
11+
});

0 commit comments

Comments
 (0)