Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update test environment to React18 (#891)
test in React17 and React18
- Loading branch information
1 parent
886780c
commit 810c0d8
Showing
7 changed files
with
45 additions
and
102 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
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,5 @@ | ||
/** | ||
* @jest-environment ./tests/react/_env/react17.js | ||
*/ | ||
|
||
import './index' |
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,9 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
const jsdomEnv = require('jest-environment-jsdom') | ||
|
||
module.exports = class React17 extends jsdomEnv { | ||
async setup() { | ||
await super.setup() | ||
this.global.REACT_VERSION = 17 | ||
} | ||
} |
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,12 @@ | ||
if (global.REACT_VERSION) { | ||
jest.mock('@testing-library/react', () => | ||
jest.requireActual(`reactTesting${global.REACT_VERSION}`), | ||
) | ||
jest.mock('react', () => jest.requireActual(`react${global.REACT_VERSION}`)) | ||
jest.mock('react-dom', () => | ||
jest.requireActual(`reactDom${global.REACT_VERSION}`), | ||
) | ||
jest.mock('react-is', () => | ||
jest.requireActual(`reactIs${global.REACT_VERSION}`), | ||
) | ||
} |
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