GeezerVison is showing github.com — chore: make tests compatible with Jest 24 (#15779) · react/react@e308a03
File treeExpand file treeCollapse file tree Open diff view settings eslint-plugin-react-hooks/__tests__
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -521,7 +521,6 @@ const tests = { | 521 | 521 | // Valid because the ref is captured. | 522 | 522 | code: ` | 523 | 523 | function useMyThing(myRef) { | 524 | | - const myRef = useRef(); | 525 | 524 | useEffect(() => { | 526 | 525 | const handleMove = () => {}; | 527 | 526 | const node = myRef.current; | |
Collapse file Copy file name to clipboardExpand all lines: packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -95,7 +95,7 @@ eslintTester.run('react-hooks', ReactHooksESLintRule, { | 95 | 95 | useHook2 = () => { useState(); }; | 96 | 96 | ({useHook: () => { useState(); }}); | 97 | 97 | ({useHook() { useState(); }}); | 98 | | - const {useHook = () => { useState(); }} = {}; | | 98 | + const {useHook3 = () => { useState(); }} = {}; | 99 | 99 | ({useHook = () => { useState(); }} = {}); | 100 | 100 | `, | 101 | 101 | ` | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -651,7 +651,7 @@ describe('ReactDOMServerIntegration', () => { | 651 | 651 | }); | 652 | 652 | }); | 653 | 653 |
| 654 | | - describe('component hierarchies', async function() { | | 654 | + describe('component hierarchies', function() { | 655 | 655 | itRenders('single child hierarchies of components', async render => { | 656 | 656 | const Component = props => <div>{props.children}</div>; | 657 | 657 | let e = await render( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/events/__tests__/ChangeEventPlugin-test.internal.js -6Lines changed: 0 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,13 +37,7 @@ describe('ChangeEventPlugin', () => { | 37 | 37 | ReactFeatureFlags = require('shared/ReactFeatureFlags'); | 38 | 38 | // TODO pull this into helper method, reduce repetition. | 39 | 39 | // mock the browser APIs which are used in schedule: | 40 | | - // - requestAnimationFrame should pass the DOMHighResTimeStamp argument | 41 | 40 | // - calling 'window.postMessage' should actually fire postmessage handlers | 42 | | - global.requestAnimationFrame = function(cb) { | 43 | | - return setTimeout(() => { | 44 | | - cb(Date.now()); | 45 | | - }); | 46 | | - }; | 47 | 41 | const originalAddEventListener = global.addEventListener; | 48 | 42 | let postMessageCallback; | 49 | 43 | global.addEventListener = function(eventName, callback, useCapture) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react/src/__tests__/ReactCoffeeScriptClass-test.coffee +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -543,3 +543,4 @@ describe 'ReactCoffeeScriptClass', -> | 543 | 543 | node = ReactDOM.findDOMNode(instance) | 544 | 544 | expect(node).toBe container.firstChild | 545 | 545 | undefined | | 546 | + undefined |
Collapse file Copy file name to clipboardExpand all lines: scripts/jest/config.base.js +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,4 +21,11 @@ module.exports = { | 21 | 21 | collectCoverageFrom: ['packages/**/*.js'], | 22 | 22 | timers: 'fake', | 23 | 23 | snapshotSerializers: [require.resolve('jest-snapshot-serializer-raw')], | | 24 | + // Jest changed from `about:blank` to `http://localhost` default in 24.5 (https://github.com/facebook/jest/pull/6792) | | 25 | + // in order to address https://github.com/facebook/jest/issues/6766. If one uses `about:blank` in [email protected] or | | 26 | + // newer, it fails with `SecurityError: localStorage is not available for opaque origins`. However, some of React's | | 27 | + // tests depend on `about:blank` being the domain (for e.g. `url` in `img` tags). So we set `about:blank` here to | | 28 | + // keep the current behavior and make sure to keep the version of JSDOM to version lower than 11.12. This will have | | 29 | + // to be addressed properly when Jest 25 is released, as it will come with a newer version of JSDOM. | | 30 | + testURL: 'about:blank', | 24 | 31 | }; |
Collapse file Copy file name to clipboardExpand all lines: scripts/jest/preprocessor.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -69,7 +69,7 @@ module.exports = { | 69 | 69 | } | 70 | 70 | : {} | 71 | 71 | ) | 72 | | - ).code; | | 72 | + ); | 73 | 73 | } | 74 | 74 | return src; | 75 | 75 | }, | |
Collapse file Copy file name to clipboardExpand all lines: scripts/jest/setupEnvironment.js -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,10 +9,6 @@ global.__PROFILE__ = NODE_ENV === 'development'; | 9 | 9 | global.__UMD__ = false; | 10 | 10 |
| 11 | 11 | if (typeof window !== 'undefined') { | 12 | | - global.requestAnimationFrame = function(callback) { | 13 | | - setTimeout(callback); | 14 | | - }; | 15 | | - | 16 | 12 | global.requestIdleCallback = function(callback) { | 17 | 13 | return setTimeout(() => { | 18 | 14 | callback({ | |
|