forked from vkbansal/react-contextmenu
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate enzyme tests to testing-library (Merge PR #52)
Migrate enzyme tests to testing-library
- Loading branch information
Showing
14 changed files
with
649 additions
and
801 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 |
---|---|---|
@@ -1,6 +1,17 @@ | ||
--- | ||
env: | ||
jest: true | ||
rules: | ||
prefer-arrow-callback: 0 | ||
no-mixed-requires: 0 | ||
plugins: | ||
- jest | ||
- jest-dom | ||
- testing-library | ||
extends: | ||
- plugin:jest/recommended | ||
- plugin:jest-dom/recommended | ||
- plugin:testing-library/react | ||
env: | ||
jest: true | ||
rules: | ||
prefer-arrow-callback: 0 | ||
no-mixed-requires: 0 | ||
# This disallows using direct Node properties (eg: firstChild), but we have | ||
# legitimate uses: | ||
testing-library/no-node-access: 0 |
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,17 +1,8 @@ | ||
const jsdom = require('jsdom'); | ||
// Importing this here makes it work everywhere. | ||
import '@testing-library/jest-dom'; | ||
|
||
const documentHTML = '<!doctype html><html><body><div id="root"></div></body></html>'; | ||
const dom = new jsdom.JSDOM(documentHTML); | ||
global.document = dom.window.document; | ||
global.window = dom.window; | ||
global.window.resizeTo = (width, height) => { | ||
global.window.innerWidth = width || global.window.innerWidth; | ||
global.window.innerHeight = width || global.window.innerHeight; | ||
global.window.dispatchEvent(new Event('resize')); | ||
window.resizeTo = (width, height) => { | ||
window.innerWidth = width || window.innerWidth; | ||
window.innerHeight = width || window.innerHeight; | ||
window.dispatchEvent(new Event('resize')); | ||
}; | ||
global.window.requestAnimationFrame = jest.fn(); | ||
|
||
const Enzyme = require('enzyme'); | ||
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17'); | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); |
Oops, something went wrong.