-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix/jest module mapping (umijs#8293)
* fix(umi-test): 🐛 fix jest moduleNameMap only do map once * refactor: 🎨 mv jsdom setup to jest setupfiles config * test: ✅ smoke test for import from umi in test * chore: ⬆️ update test-library/react to remove warnings import js-dom expect types * fix: 🐛 add back react wait esbuild to support react-jsx * refactor: 🔥 remove include fields * refactor: 🎨 setup testing-library/js-dom when use testing-library/react * refactor: 🎨 use startsWith to determine alias matches * refactor: 🎨 support dva$ alias config * chore: 🔧 jsx use react due to esbuild is not fully supoort react-jsx * refactor: 🎨 test case remove umi context Co-authored-by: pshu <[email protected]>
- Loading branch information
1 parent
295052b
commit 3c1136b
Showing
11 changed files
with
120 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
export default { | ||
npmClient: 'pnpm', | ||
plugins: ['@umijs/plugins/dist/dva'], | ||
dva: { | ||
immer: { | ||
enableES5: true, | ||
enableAllPlugins: true, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @ts-ignore | ||
import { connect } from 'dva'; | ||
import { useAppData } from 'umi'; | ||
|
||
test('import from umi works', () => { | ||
expect(useAppData).toBeDefined(); | ||
expect(connect).toBeDefined(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '@testing-library/jest-dom'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "./.umi/tsconfig.json", | ||
"compilerOptions": { | ||
"jsx": "react" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { getAliasPathWithKey } from './test'; | ||
|
||
test('simple alias to jest moduleNameMapper', () => { | ||
const p = getAliasPathWithKey( | ||
{ | ||
'react-dom': '/path/to/react-dom', | ||
}, | ||
'react-dom', | ||
); | ||
expect(p).toBe('/path/to/react-dom'); | ||
}); | ||
|
||
test('double alias path', () => { | ||
const p = getAliasPathWithKey( | ||
{ | ||
alias1: 'alias2/lib', | ||
alias2: '/path/to/module', | ||
}, | ||
'alias1', | ||
); | ||
expect(p).toBe('/path/to/module/lib'); | ||
}); | ||
|
||
test('double alias path suffixed $', () => { | ||
const p = getAliasPathWithKey( | ||
{ | ||
endWith$: '/path/to/index.js', | ||
}, | ||
'endWith$', | ||
); | ||
expect(p).toBe('/path/to/index.js'); | ||
}); | ||
|
||
test('overlapped alias paths', () => { | ||
const p = getAliasPathWithKey( | ||
{ | ||
common$: '/path/to/index.js', | ||
'common/lib': '/path/to/lib', | ||
}, | ||
'common/lib', | ||
); | ||
expect(p).toBe('/path/to/lib'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.