diff --git a/.eslintrc.js b/.eslintrc.js index ec20e2196e94b..01d91a150bce1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,7 +12,7 @@ const WARNING = 1; const ERROR = 2; module.exports = { - extends: ['prettier'], + extends: ['prettier', 'plugin:jest/recommended'], // Stop ESLint from looking for a configuration file in parent folders root: true, @@ -376,16 +376,49 @@ module.exports = { files: ['**/__tests__/*.js'], rules: { // https://github.com/jest-community/eslint-plugin-jest - 'jest/no-focused-tests': ERROR, - 'jest/valid-expect': ERROR, - 'jest/valid-expect-in-promise': ERROR, + // Meh, who cares. + 'jest/consistent-test-it': OFF, + // Meh, we have a lot of these, who cares. + 'jest/no-alias-methods': OFF, + // We do conditions based on feature flags. + 'jest/no-conditional-expect': OFF, + // We have our own assertion helpers. + 'jest/expect-expect': OFF, + // Lame rule that fires in itRender helpers or in render methods. + 'jest/no-standalone-expect': OFF, }, }, { - // disable no focused tests for test setup helper files even if they are inside __tests__ directory - files: ['**/setupTests.js'], + // Rules specific to test setup helper files. + files: [ + '**/setupTests.js', + '**/setupEnv.js', + '**/jest/TestFlags.js', + '**/dom-event-testing-library/testHelpers.js', + '**/utils/ReactDOMServerIntegrationTestUtils.js', + '**/babel/transform-react-version-pragma.js', + '**/babel/transform-test-gate-pragma.js', + ], rules: { + // Some helpers intentionally focus tests. 'jest/no-focused-tests': OFF, + // Test fn helpers don't use static text names. + 'jest/valid-title': OFF, + // We have our own assertion helpers. + 'jest/expect-expect': OFF, + // Some helpers intentionally disable tests. + 'jest/no-disabled-tests': OFF, + // Helpers export text function helpers. + 'jest/no-export': OFF, + // The examples in comments trigger false errors. + 'jest/no-commented-out-tests': OFF, + }, + }, + { + files: ['**/jest/TestFlags.js'], + rules: { + // The examples in comments trigger false errors. + 'jest/no-commented-out-tests': OFF, }, }, { diff --git a/package.json b/package.json index a6dc255bce689..fc482724ee7a0 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "eslint-plugin-babel": "^5.3.0", "eslint-plugin-eslint-plugin": "^3.5.3", "eslint-plugin-ft-flow": "^2.0.3", - "eslint-plugin-jest": "^22.15.0", + "eslint-plugin-jest": "28.4.0", "eslint-plugin-no-for-of-loops": "^1.0.0", "eslint-plugin-no-function-declare-after-return": "^1.0.0", "eslint-plugin-react": "^6.7.1", diff --git a/packages/dom-event-testing-library/__tests__/index-test.internal.js b/packages/dom-event-testing-library/__tests__/index-test.internal.js index 3883d9a9ba8c1..2b6323d9300e0 100644 --- a/packages/dom-event-testing-library/__tests__/index-test.internal.js +++ b/packages/dom-event-testing-library/__tests__/index-test.internal.js @@ -45,7 +45,7 @@ describe('createEventTarget', () => { resetActivePointers(); }); - test('returns expected API', () => { + it('returns expected API', () => { const target = createEventTarget(node); expect(target.node).toEqual(node); expect(Object.keys(target)).toMatchInlineSnapshot(` @@ -77,7 +77,7 @@ describe('createEventTarget', () => { */ describe('.blur()', () => { - test('default', () => { + it('default', () => { const target = createEventTarget(node); node.addEventListener('blur', e => { expect(e.relatedTarget).toMatchInlineSnapshot(`null`); @@ -85,7 +85,7 @@ describe('createEventTarget', () => { target.blur(); }); - test('custom payload', () => { + it('custom payload', () => { const target = createEventTarget(node); node.addEventListener('blur', e => { expect(e.relatedTarget).toMatchInlineSnapshot(`null`); @@ -95,7 +95,7 @@ describe('createEventTarget', () => { }); describe('.click()', () => { - test('default', () => { + it('default', () => { const target = createEventTarget(node); node.addEventListener('click', e => { expect(e.altKey).toEqual(false); @@ -122,7 +122,7 @@ describe('createEventTarget', () => { target.click(); }); - test('custom payload', () => { + it('custom payload', () => { const target = createEventTarget(node); node.addEventListener('click', e => { expect(e.altKey).toEqual(true); @@ -162,7 +162,7 @@ describe('createEventTarget', () => { }); describe('.focus()', () => { - test('default', () => { + it('default', () => { const target = createEventTarget(node); node.addEventListener('focus', e => { expect(e.relatedTarget).toMatchInlineSnapshot(`null`); @@ -170,7 +170,7 @@ describe('createEventTarget', () => { target.blur(); }); - test('custom payload', () => { + it('custom payload', () => { const target = createEventTarget(node); node.addEventListener('focus', e => { expect(e.relatedTarget).toMatchInlineSnapshot(`null`); @@ -180,7 +180,7 @@ describe('createEventTarget', () => { }); describe('.keydown()', () => { - test('default', () => { + it('default', () => { const target = createEventTarget(node); node.addEventListener('keydown', e => { expect(e.altKey).toEqual(false); @@ -195,7 +195,7 @@ describe('createEventTarget', () => { target.keydown(); }); - test('custom payload', () => { + it('custom payload', () => { const target = createEventTarget(node); node.addEventListener('keydown', e => { expect(e.altKey).toEqual(true); @@ -217,7 +217,7 @@ describe('createEventTarget', () => { }); describe('.keyup()', () => { - test('default', () => { + it('default', () => { const target = createEventTarget(node); node.addEventListener('keyup', e => { expect(e.altKey).toEqual(false); @@ -232,7 +232,7 @@ describe('createEventTarget', () => { target.keydown(); }); - test('custom payload', () => { + it('custom payload', () => { const target = createEventTarget(node); node.addEventListener('keyup', e => { expect(e.altKey).toEqual(true); @@ -254,7 +254,7 @@ describe('createEventTarget', () => { }); describe('.scroll()', () => { - test('default', () => { + it('default', () => { const target = createEventTarget(node); node.addEventListener('scroll', e => { expect(e.type).toEqual('scroll'); @@ -264,7 +264,7 @@ describe('createEventTarget', () => { }); describe('.virtualclick()', () => { - test('default', () => { + it('default', () => { const target = createEventTarget(node); node.addEventListener('click', e => { expect(e.altKey).toEqual(false); @@ -291,7 +291,7 @@ describe('createEventTarget', () => { target.virtualclick(); }); - test('custom payload', () => { + it('custom payload', () => { const target = createEventTarget(node); node.addEventListener('click', e => { // expect most of the custom payload to be ignored @@ -334,7 +334,7 @@ describe('createEventTarget', () => { * Other APIs */ - test('.setBoundingClientRect()', () => { + it('.setBoundingClientRect()', () => { const target = createEventTarget(node); expect(node.getBoundingClientRect()).toMatchInlineSnapshot(` { diff --git a/packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js b/packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js index db0066582e69c..e2a8f34cc9e34 100644 --- a/packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js +++ b/packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js @@ -36,7 +36,7 @@ const { } = require('../ReactInternalTestUtils'); describe('ReactInternalTestUtils', () => { - test('waitFor', async () => { + it('waitFor', async () => { const Yield = ({id}) => { Scheduler.log(id); return id; @@ -61,7 +61,7 @@ describe('ReactInternalTestUtils', () => { expect(root).toMatchRenderedOutput(
foobarbaz
); }); - test('waitForAll', async () => { + it('waitForAll', async () => { const Yield = ({id}) => { Scheduler.log(id); return id; @@ -82,7 +82,7 @@ describe('ReactInternalTestUtils', () => { expect(root).toMatchRenderedOutput(
foobarbaz
); }); - test('waitForThrow', async () => { + it('waitForThrow', async () => { const Yield = ({id}) => { Scheduler.log(id); return id; @@ -117,7 +117,7 @@ describe('ReactInternalTestUtils', () => { ]); }); - test('waitForPaint', async () => { + it('waitForPaint', async () => { function App({prop}) { const deferred = useDeferredValue(prop); const text = `Urgent: ${prop}, Deferred: ${deferred}`; @@ -143,7 +143,7 @@ describe('ReactInternalTestUtils', () => { expect(root).toMatchRenderedOutput('Urgent: B, Deferred: B'); }); - test('assertLog', async () => { + it('assertLog', async () => { const Yield = ({id}) => { Scheduler.log(id); React.useEffect(() => { @@ -732,7 +732,7 @@ describe('ReactInternalTestUtils console assertions', () => { await waitForAll(['foo', 'bar', 'baz']); }); - test('should fail if waitForThrow is called before asserting', async () => { + it('should fail if waitForThrow is called before asserting', async () => { const Yield = ({id}) => { Scheduler.log(id); return id; @@ -774,7 +774,7 @@ describe('ReactInternalTestUtils console assertions', () => { await waitForAll(['A', 'B', 'A', 'B']); }); - test('should fail if waitForPaint is called before asserting', async () => { + it('should fail if waitForPaint is called before asserting', async () => { function App({prop}) { const deferred = useDeferredValue(prop); const text = `Urgent: ${prop}, Deferred: ${deferred}`; @@ -1664,7 +1664,7 @@ describe('ReactInternalTestUtils console assertions', () => { await waitForAll(['foo', 'bar', 'baz']); }); - test('should fail if waitForThrow is called before asserting', async () => { + it('should fail if waitForThrow is called before asserting', async () => { const Yield = ({id}) => { Scheduler.log(id); return id; @@ -1706,7 +1706,7 @@ describe('ReactInternalTestUtils console assertions', () => { await waitForAll(['A', 'B', 'A', 'B']); }); - test('should fail if waitForPaint is called before asserting', async () => { + it('should fail if waitForPaint is called before asserting', async () => { function App({prop}) { const deferred = useDeferredValue(prop); const text = `Urgent: ${prop}, Deferred: ${deferred}`; @@ -2640,7 +2640,7 @@ describe('ReactInternalTestUtils console assertions', () => { await waitForAll(['foo', 'bar', 'baz']); }); - test('should fail if waitForThrow is called before asserting', async () => { + it('should fail if waitForThrow is called before asserting', async () => { const Yield = ({id}) => { Scheduler.log(id); return id; @@ -2682,7 +2682,7 @@ describe('ReactInternalTestUtils console assertions', () => { await waitForAll(['A', 'B', 'A', 'B']); }); - test('should fail if waitForPaint is called before asserting', async () => { + it('should fail if waitForPaint is called before asserting', async () => { function App({prop}) { const deferred = useDeferredValue(prop); const text = `Urgent: ${prop}, Deferred: ${deferred}`; diff --git a/packages/react-devtools-inline/__tests__/__e2e__/utils.js b/packages/react-devtools-inline/__tests__/__e2e__/utils.js index 5f0505b71e070..1e0efabb15466 100644 --- a/packages/react-devtools-inline/__tests__/__e2e__/utils.js +++ b/packages/react-devtools-inline/__tests__/__e2e__/utils.js @@ -7,6 +7,7 @@ const config = require('../../playwright.config'); const {test} = require('@playwright/test'); function runOnlyForReactRange(range) { + // eslint-disable-next-line jest/no-disabled-tests test.skip( !semver.satisfies(config.use.react_version, range), `This test requires a React version of ${range} to run. ` + diff --git a/packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js b/packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js index acffea6a42c45..59d383e3a5088 100644 --- a/packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js +++ b/packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js @@ -141,7 +141,8 @@ describe('Timeline profiler', () => { // TODO(hoxyq): investigate why running this test with React 18 fails // @reactVersion <= 18.2 // @reactVersion >= 18.0 - xit('should mark sync render with suspense that resolves', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should mark sync render with suspense that resolves', async () => { const fakeSuspensePromise = Promise.resolve(true); function Example() { throw fakeSuspensePromise; @@ -186,7 +187,8 @@ describe('Timeline profiler', () => { // TODO(hoxyq): investigate why running this test with React 18 fails // @reactVersion <= 18.2 // @reactVersion >= 18.0 - xit('should mark sync render with suspense that rejects', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should mark sync render with suspense that rejects', async () => { const fakeSuspensePromise = Promise.reject(new Error('error')); function Example() { throw fakeSuspensePromise; @@ -1528,7 +1530,7 @@ describe('Timeline profiler', () => { `); }); - it('should mark concurrent render without suspends or state updates', () => { + it('should mark concurrent render without suspends with state updates', () => { let updaterFn; function Example() { diff --git a/packages/react-devtools-shared/src/__tests__/__serializers__/dehydratedValueSerializer.js b/packages/react-devtools-shared/src/__tests__/__serializers__/dehydratedValueSerializer.js index 9825f4a2ac82c..b3797f6e66b4f 100644 --- a/packages/react-devtools-shared/src/__tests__/__serializers__/dehydratedValueSerializer.js +++ b/packages/react-devtools-shared/src/__tests__/__serializers__/dehydratedValueSerializer.js @@ -7,7 +7,7 @@ * @flow */ -// test() is part of Jest's serializer API +// `test` is part of Jest's serializer API export function test(maybeDehydratedValue) { const {meta} = require('react-devtools-shared/src/hydration'); diff --git a/packages/react-devtools-shared/src/__tests__/__serializers__/hookSerializer.js b/packages/react-devtools-shared/src/__tests__/__serializers__/hookSerializer.js index 20a5425b1ab62..cd27eac57362c 100644 --- a/packages/react-devtools-shared/src/__tests__/__serializers__/hookSerializer.js +++ b/packages/react-devtools-shared/src/__tests__/__serializers__/hookSerializer.js @@ -34,7 +34,7 @@ function serializeHook(hook) { }; } -// test() is part of Jest's serializer API +// `test` is part of Jest's serializer API export function test(maybeHook) { if (maybeHook === null || typeof maybeHook !== 'object') { return false; diff --git a/packages/react-devtools-shared/src/__tests__/__serializers__/inspectedElementSerializer.js b/packages/react-devtools-shared/src/__tests__/__serializers__/inspectedElementSerializer.js index 0c249ca5b939a..870ad35e4b03c 100644 --- a/packages/react-devtools-shared/src/__tests__/__serializers__/inspectedElementSerializer.js +++ b/packages/react-devtools-shared/src/__tests__/__serializers__/inspectedElementSerializer.js @@ -1,4 +1,4 @@ -// test() is part of Jest's serializer API +// `test` is part of Jest's serializer API export function test(maybeInspectedElement) { if ( maybeInspectedElement === null || diff --git a/packages/react-devtools-shared/src/__tests__/__serializers__/numberToFixedSerializer.js b/packages/react-devtools-shared/src/__tests__/__serializers__/numberToFixedSerializer.js index 2b0fc1f07e78a..d9e513d2490bb 100644 --- a/packages/react-devtools-shared/src/__tests__/__serializers__/numberToFixedSerializer.js +++ b/packages/react-devtools-shared/src/__tests__/__serializers__/numberToFixedSerializer.js @@ -1,6 +1,6 @@ const MAX_DECIMAL_PLACES = 3; -// test() is part of Jest's serializer API +// `test` is part of Jest's serializer API export function test(maybeNumber) { return ( typeof maybeNumber === 'number' && diff --git a/packages/react-devtools-shared/src/__tests__/__serializers__/profilingSerializer.js b/packages/react-devtools-shared/src/__tests__/__serializers__/profilingSerializer.js index be988e22b2263..bfe6b9ecc1154 100644 --- a/packages/react-devtools-shared/src/__tests__/__serializers__/profilingSerializer.js +++ b/packages/react-devtools-shared/src/__tests__/__serializers__/profilingSerializer.js @@ -2,7 +2,7 @@ import hasOwnProperty from 'shared/hasOwnProperty'; const FILTERED_VERSION_STRING = ''; -// test() is part of Jest's serializer API +// `test` is part of Jest's serializer API export function test(maybeProfile) { if ( maybeProfile != null && diff --git a/packages/react-devtools-shared/src/__tests__/__serializers__/storeSerializer.js b/packages/react-devtools-shared/src/__tests__/__serializers__/storeSerializer.js index 947c449a89a58..ea5a402bdc235 100644 --- a/packages/react-devtools-shared/src/__tests__/__serializers__/storeSerializer.js +++ b/packages/react-devtools-shared/src/__tests__/__serializers__/storeSerializer.js @@ -1,6 +1,6 @@ import {printStore} from 'react-devtools-shared/src/devtools/utils'; -// test() is part of Jest's serializer API +// `test` is part of Jest's serializer API export function test(maybeStore) { // It's important to lazy-require the Store rather than imported at the head of the module. // Because we reset modules between tests, different Store implementations will be used for each test. diff --git a/packages/react-devtools-shared/src/__tests__/__serializers__/timelineDataSerializer.js b/packages/react-devtools-shared/src/__tests__/__serializers__/timelineDataSerializer.js index 1ece2010eec02..fc406ca4d6791 100644 --- a/packages/react-devtools-shared/src/__tests__/__serializers__/timelineDataSerializer.js +++ b/packages/react-devtools-shared/src/__tests__/__serializers__/timelineDataSerializer.js @@ -6,7 +6,7 @@ function formatLanes(laneArray) { return '0b' + lanes.toString(2).padStart(31, '0'); } -// test() is part of Jest's serializer API +// `test` is part of Jest's serializer API export function test(maybeTimelineData) { if ( maybeTimelineData != null && diff --git a/packages/react-devtools-shared/src/__tests__/__serializers__/treeContextStateSerializer.js b/packages/react-devtools-shared/src/__tests__/__serializers__/treeContextStateSerializer.js index f434cd66b5a4c..e5797fda3cc64 100644 --- a/packages/react-devtools-shared/src/__tests__/__serializers__/treeContextStateSerializer.js +++ b/packages/react-devtools-shared/src/__tests__/__serializers__/treeContextStateSerializer.js @@ -1,6 +1,6 @@ import {printStore} from 'react-devtools-shared/src/devtools/utils'; -// test() is part of Jest's serializer API +// `test` is part of Jest's serializer API export function test(maybeState) { if (maybeState === null || typeof maybeState !== 'object') { return false; diff --git a/packages/react-devtools-shared/src/__tests__/componentStacks-test.js b/packages/react-devtools-shared/src/__tests__/componentStacks-test.js index 02e2ad6802f61..f32e0d097e8de 100644 --- a/packages/react-devtools-shared/src/__tests__/componentStacks-test.js +++ b/packages/react-devtools-shared/src/__tests__/componentStacks-test.js @@ -65,7 +65,8 @@ describe('component stack', () => { // but didn't because both DevTools and ReactDOM are running in the same memory space, // so the case we're testing against (DevTools prod build and React DEV build) doesn't exist. // It would be nice to figure out a way to test this combination at some point... - xit('should disable the current dispatcher before shallow rendering so no effects get scheduled', () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should disable the current dispatcher before shallow rendering so no effects get scheduled', () => { let useEffectCount = 0; const Example = props => { diff --git a/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js b/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js index 08ff85c9ac87f..3072cc2397622 100644 --- a/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js +++ b/packages/react-devtools-shared/src/__tests__/inspectedElement-test.js @@ -181,7 +181,8 @@ describe('InspectedElement', () => { // TODO(hoxyq): Enable this test for versions ~18, currently broken // @reactVersion <= 18.2 - xit('should inspect the currently selected element (legacy render)', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should inspect the currently selected element (legacy render)', async () => { const Example = () => { const [count] = React.useState(1); return count; @@ -1653,7 +1654,8 @@ describe('InspectedElement', () => { // TODO(hoxyq): Enable this test for versions ~18, currently broken // @reactVersion <= 18.2 - xit('should inspect hooks for components that only use context (legacy render)', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should inspect hooks for components that only use context (legacy render)', async () => { const Context = React.createContext(true); const Example = () => { const value = React.useContext(Context); @@ -2031,7 +2033,8 @@ describe('InspectedElement', () => { // TODO(hoxyq): Enable this test for versions ~18, currently broken // Regression test for github.com/facebook/react/issues/22099 // @reactVersion <= 18.2 - xit('should not error when an unchanged component is re-inspected after component filters changed (legacy render)', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should not error when an unchanged component is re-inspected after component filters changed (legacy render)', async () => { const Example = () =>
; await utils.actAsync(() => legacyRender()); @@ -2152,7 +2155,8 @@ describe('InspectedElement', () => { // TODO(hoxyq): Enable this test for versions ~18, currently broken // @reactVersion <= 18.2 - xit('should display the root type for ReactDOM.hydrate', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should display the root type for ReactDOM.hydrate', async () => { const Example = () =>
; await utils.actAsync(() => { @@ -2172,7 +2176,8 @@ describe('InspectedElement', () => { // TODO(hoxyq): Enable this test for versions ~18, currently broken // @reactVersion <= 18.2 - xit('should display the root type for ReactDOM.render', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should display the root type for ReactDOM.render', async () => { const Example = () =>
; await utils.actAsync(() => { @@ -2789,7 +2794,8 @@ describe('InspectedElement', () => { // TODO(hoxyq): Enable this test for versions ~18, currently broken // @reactVersion <= 18.2 - xit('inspecting nested renderers should not throw (legacy render)', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('inspecting nested renderers should not throw (legacy render)', async () => { // Ignoring react art warnings jest.spyOn(console, 'error').mockImplementation(() => {}); const ReactArt = require('react-art'); diff --git a/packages/react-devtools-shared/src/__tests__/preprocessData-test.js b/packages/react-devtools-shared/src/__tests__/preprocessData-test.js index f3e29a23cffd8..6e2f2522ec8da 100644 --- a/packages/react-devtools-shared/src/__tests__/preprocessData-test.js +++ b/packages/react-devtools-shared/src/__tests__/preprocessData-test.js @@ -1499,6 +1499,7 @@ describe('Timeline profiler', () => { // This is temporarily disabled because the warning doesn't work // with useDeferredValue + // eslint-disable-next-line jest/no-disabled-tests it.skip('should warn about long nested (state) updates during layout effects', async () => { function Component() { const [didMount, setDidMount] = React.useState(false); @@ -1556,6 +1557,7 @@ describe('Timeline profiler', () => { // This is temporarily disabled because the warning doesn't work // with useDeferredValue + // eslint-disable-next-line jest/no-disabled-tests it.skip('should warn about long nested (forced) updates during layout effects', async () => { class Component extends React.Component { _didMount: boolean = false; @@ -1685,6 +1687,7 @@ describe('Timeline profiler', () => { // This is temporarily disabled because the warning doesn't work // with useDeferredValue + // eslint-disable-next-line jest/no-disabled-tests it.skip('should not warn about deferred value updates scheduled during commit phase', async () => { function Component() { const [value, setValue] = React.useState(0); diff --git a/packages/react-devtools-shared/src/__tests__/profilerStore-test.js b/packages/react-devtools-shared/src/__tests__/profilerStore-test.js index 8a73b7ae4ad6a..cead054d3183c 100644 --- a/packages/react-devtools-shared/src/__tests__/profilerStore-test.js +++ b/packages/react-devtools-shared/src/__tests__/profilerStore-test.js @@ -184,7 +184,7 @@ describe('ProfilerStore', () => { }); // @reactVersion >= 16.9 - it('should not throw if state contains a property hasOwnProperty ', () => { + it('should not throw if state contains a property hasOwnProperty', () => { let setStateCallback; const ControlledInput = () => { const [state, setState] = React.useState({hasOwnProperty: true}); diff --git a/packages/react-devtools-shared/src/__tests__/storeComponentFilters-test.js b/packages/react-devtools-shared/src/__tests__/storeComponentFilters-test.js index 895c9d521a361..432fb1771b6ff 100644 --- a/packages/react-devtools-shared/src/__tests__/storeComponentFilters-test.js +++ b/packages/react-devtools-shared/src/__tests__/storeComponentFilters-test.js @@ -226,7 +226,8 @@ describe('Store component filters', () => { // Disabled: filtering by path was removed, source is now determined lazily, including symbolication if applicable // @reactVersion >= 16.0 - xit('should filter by path', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should filter by path', async () => { // This component should use props object in order to throw for component stack generation // See ReactComponentStackFrame:155 or DevToolsComponentStackFrame:147 const Component = props => { diff --git a/packages/react-devtools-shared/src/__tests__/transform-react-version-pragma-test.js b/packages/react-devtools-shared/src/__tests__/transform-react-version-pragma-test.js index 49a9f96117cca..fd84deb29b672 100644 --- a/packages/react-devtools-shared/src/__tests__/transform-react-version-pragma-test.js +++ b/packages/react-devtools-shared/src/__tests__/transform-react-version-pragma-test.js @@ -44,93 +44,93 @@ describe('transform-react-version-pragma', () => { }); // @reactVersion >= 17.9 - test('reactVersion flag is on >=', () => { + it('reactVersion flag is on >=', () => { expect(shouldPass).toBe(true); }); // @reactVersion >= 18.1 - test('reactVersion flag is off >=', () => { + it('reactVersion flag is off >=', () => { expect(shouldPass).toBe(false); }); // @reactVersion <= 18.1 - test('reactVersion flag is on <=', () => { + it('reactVersion flag is on <=', () => { expect(shouldPass).toBe(true); }); // @reactVersion <= 17.9 - test('reactVersion flag is off <=', () => { + it('reactVersion flag is off <=', () => { expect(shouldPass).toBe(false); }); // @reactVersion > 17.9 - test('reactVersion flag is on >', () => { + it('reactVersion flag is on >', () => { expect(shouldPass).toBe(true); }); // @reactVersion > 18.1 - test('reactVersion flag is off >', () => { + it('reactVersion flag is off >', () => { expect(shouldPass).toBe(false); }); // @reactVersion < 18.1 - test('reactVersion flag is on <', () => { + it('reactVersion flag is on <', () => { expect(shouldPass).toBe(true); }); // @reactVersion < 17.0.0 - test('reactVersion flag is off <', () => { + it('reactVersion flag is off <', () => { expect(shouldPass).toBe(false); }); // @reactVersion = 18.0 - test('reactVersion flag is on =', () => { + it('reactVersion flag is on =', () => { expect(shouldPass).toBe(true); }); // @reactVersion = 18.1 - test('reactVersion flag is off =', () => { + it('reactVersion flag is off =', () => { expect(shouldPass).toBe(false); }); /* eslint-disable jest/no-focused-tests */ // @reactVersion >= 18.1 - fit('reactVersion fit', () => { + it.only('reactVersion fit', () => { expect(shouldPass).toBe(false); expect(isFocused).toBe(true); }); // @reactVersion <= 18.1 - test.only('reactVersion test.only', () => { + it.only('reactVersion test.only', () => { expect(shouldPass).toBe(true); expect(isFocused).toBe(true); }); // @reactVersion <= 18.1 // @reactVersion <= 17.1 - test('reactVersion multiple pragmas fail', () => { + it('reactVersion multiple pragmas fail', () => { expect(shouldPass).toBe(false); expect(isFocused).toBe(false); }); // @reactVersion <= 18.1 // @reactVersion >= 17.1 - test('reactVersion multiple pragmas pass', () => { + it('reactVersion multiple pragmas pass', () => { expect(shouldPass).toBe(true); expect(isFocused).toBe(false); }); // @reactVersion <= 18.1 // @reactVersion <= 17.1 - test.only('reactVersion focused multiple pragmas fail', () => { + it.only('reactVersion focused multiple pragmas fail', () => { expect(shouldPass).toBe(false); expect(isFocused).toBe(true); }); // @reactVersion <= 18.1 // @reactVersion >= 17.1 - test.only('reactVersion focused multiple pragmas pass', () => { + it.only('reactVersion focused multiple pragmas pass', () => { expect(shouldPass).toBe(true); expect(isFocused).toBe(true); }); diff --git a/packages/react-devtools-shared/src/__tests__/treeContext-test.js b/packages/react-devtools-shared/src/__tests__/treeContext-test.js index bbe9d9a17acb6..8bd5a8e17fa0b 100644 --- a/packages/react-devtools-shared/src/__tests__/treeContext-test.js +++ b/packages/react-devtools-shared/src/__tests__/treeContext-test.js @@ -2549,7 +2549,7 @@ describe('TreeListContext', () => { }); describe('error boundaries', () => { - it('should properly handle errors/warnings from components that dont mount because of an error', () => { + it('should properly handle errors from components that dont mount because of an error', () => { class ErrorBoundary extends React.Component { state = {error: null}; static getDerivedStateFromError(error) { @@ -2604,7 +2604,7 @@ describe('TreeListContext', () => { expect(state).toMatchInlineSnapshot(``); }); - it('should properly handle errors/warnings from components that dont mount because of an error', () => { + it('should properly handle warnings from components that dont mount because of an error', () => { class ErrorBoundary extends React.Component { state = {error: null}; static getDerivedStateFromError(error) { diff --git a/packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js b/packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js index be45a386e834c..f197a25fa5d82 100644 --- a/packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js +++ b/packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js @@ -195,7 +195,7 @@ describe('parseHookNames', () => { describe('inline, external and bundle source maps', () => { it('should work for simple components', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -203,17 +203,17 @@ describe('parseHookNames', () => { ]); } - await test('./__source__/Example'); // original source (uncompiled) - await test('./__source__/__compiled__/inline/Example'); // inline source map - await test('./__source__/__compiled__/external/Example'); // external source map - await test('./__source__/__compiled__/inline/index-map/Example'); // inline index map source map - await test('./__source__/__compiled__/external/index-map/Example'); // external index map source map - await test('./__source__/__compiled__/bundle/index', 'Example'); // bundle source map - await test('./__source__/__compiled__/no-columns/Example'); // simulated Webpack 'cheap-module-source-map' + await testFor('./__source__/Example'); // original source (uncompiled) + await testFor('./__source__/__compiled__/inline/Example'); // inline source map + await testFor('./__source__/__compiled__/external/Example'); // external source map + await testFor('./__source__/__compiled__/inline/index-map/Example'); // inline index map source map + await testFor('./__source__/__compiled__/external/index-map/Example'); // external index map source map + await testFor('./__source__/__compiled__/bundle/index', 'Example'); // bundle source map + await testFor('./__source__/__compiled__/no-columns/Example'); // simulated Webpack 'cheap-module-source-map' }); it('should work with more complex files and components', async () => { - async function test(path, name = undefined) { + async function testFor(path, name = undefined) { const components = name != null ? require(path)[name] : require(path); let hookNames = await getHookNamesForComponent(components.List); @@ -237,17 +237,17 @@ describe('parseHookNames', () => { ]); } - await test('./__source__/ToDoList'); // original source (uncompiled) - await test('./__source__/__compiled__/inline/ToDoList'); // inline source map - await test('./__source__/__compiled__/external/ToDoList'); // external source map - await test('./__source__/__compiled__/inline/index-map/ToDoList'); // inline index map source map - await test('./__source__/__compiled__/external/index-map/ToDoList'); // external index map source map - await test('./__source__/__compiled__/bundle', 'ToDoList'); // bundle source map - await test('./__source__/__compiled__/no-columns/ToDoList'); // simulated Webpack 'cheap-module-source-map' + await testFor('./__source__/ToDoList'); // original source (uncompiled) + await testFor('./__source__/__compiled__/inline/ToDoList'); // inline source map + await testFor('./__source__/__compiled__/external/ToDoList'); // external source map + await testFor('./__source__/__compiled__/inline/index-map/ToDoList'); // inline index map source map + await testFor('./__source__/__compiled__/external/index-map/ToDoList'); // external index map source map + await testFor('./__source__/__compiled__/bundle', 'ToDoList'); // bundle source map + await testFor('./__source__/__compiled__/no-columns/ToDoList'); // simulated Webpack 'cheap-module-source-map' }); it('should work for custom hook', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -258,23 +258,28 @@ describe('parseHookNames', () => { ]); } - await test('./__source__/ComponentWithCustomHook'); // original source (uncompiled) - await test('./__source__/__compiled__/inline/ComponentWithCustomHook'); // inline source map - await test('./__source__/__compiled__/external/ComponentWithCustomHook'); // external source map - await test( + await testFor('./__source__/ComponentWithCustomHook'); // original source (uncompiled) + await testFor('./__source__/__compiled__/inline/ComponentWithCustomHook'); // inline source map + await testFor( + './__source__/__compiled__/external/ComponentWithCustomHook', + ); // external source map + await testFor( './__source__/__compiled__/inline/index-map/ComponentWithCustomHook', ); // inline index map source map - await test( + await testFor( './__source__/__compiled__/external/index-map/ComponentWithCustomHook', ); // external index map source map - await test('./__source__/__compiled__/bundle', 'ComponentWithCustomHook'); // bundle source map - await test( + await testFor( + './__source__/__compiled__/bundle', + 'ComponentWithCustomHook', + ); // bundle source map + await testFor( './__source__/__compiled__/no-columns/ComponentWithCustomHook', ); // simulated Webpack 'cheap-module-source-map' }); it('should work when code is using hooks indirectly', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -284,29 +289,29 @@ describe('parseHookNames', () => { ]); } - await test( + await testFor( './__source__/__compiled__/inline/ComponentUsingHooksIndirectly', ); // inline source map - await test( + await testFor( './__source__/__compiled__/external/ComponentUsingHooksIndirectly', ); // external source map - await test( + await testFor( './__source__/__compiled__/inline/index-map/ComponentUsingHooksIndirectly', ); // inline index map source map - await test( + await testFor( './__source__/__compiled__/external/index-map/ComponentUsingHooksIndirectly', ); // external index map source map - await test( + await testFor( './__source__/__compiled__/bundle', 'ComponentUsingHooksIndirectly', ); // bundle source map - await test( + await testFor( './__source__/__compiled__/no-columns/ComponentUsingHooksIndirectly', ); // simulated Webpack 'cheap-module-source-map' }); it('should work when code is using nested hooks', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; let InnerComponent; const hookNames = await getHookNamesForComponent(Component, { @@ -323,25 +328,29 @@ describe('parseHookNames', () => { ]); } - await test('./__source__/__compiled__/inline/ComponentWithNestedHooks'); // inline source map - await test('./__source__/__compiled__/external/ComponentWithNestedHooks'); // external source map - await test( + await testFor( + './__source__/__compiled__/inline/ComponentWithNestedHooks', + ); // inline source map + await testFor( + './__source__/__compiled__/external/ComponentWithNestedHooks', + ); // external source map + await testFor( './__source__/__compiled__/inline/index-map/ComponentWithNestedHooks', ); // inline index map source map - await test( + await testFor( './__source__/__compiled__/external/index-map/ComponentWithNestedHooks', ); // external index map source map - await test( + await testFor( './__source__/__compiled__/bundle', 'ComponentWithNestedHooks', ); // bundle source map - await test( + await testFor( './__source__/__compiled__/no-columns/ComponentWithNestedHooks', ); // simulated Webpack 'cheap-module-source-map' }); it('should work for external hooks', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -353,29 +362,29 @@ describe('parseHookNames', () => { // We can't test the uncompiled source here, because it either needs to get transformed, // which would break the source mapping, or the import statements will fail. - await test( + await testFor( './__source__/__compiled__/inline/ComponentWithExternalCustomHooks', ); // inline source map - await test( + await testFor( './__source__/__compiled__/external/ComponentWithExternalCustomHooks', ); // external source map - await test( + await testFor( './__source__/__compiled__/inline/index-map/ComponentWithExternalCustomHooks', ); // inline index map source map - await test( + await testFor( './__source__/__compiled__/external/index-map/ComponentWithExternalCustomHooks', ); // external index map source map - await test( + await testFor( './__source__/__compiled__/bundle', 'ComponentWithExternalCustomHooks', ); // bundle source map - await test( + await testFor( './__source__/__compiled__/no-columns/ComponentWithExternalCustomHooks', ); // simulated Webpack 'cheap-module-source-map' }); it('should work when multiple hooks are on a line', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -386,24 +395,24 @@ describe('parseHookNames', () => { ]); } - await test( + await testFor( './__source__/__compiled__/inline/ComponentWithMultipleHooksPerLine', ); // inline source map - await test( + await testFor( './__source__/__compiled__/external/ComponentWithMultipleHooksPerLine', ); // external source map - await test( + await testFor( './__source__/__compiled__/inline/index-map/ComponentWithMultipleHooksPerLine', ); // inline index map source map - await test( + await testFor( './__source__/__compiled__/external/index-map/ComponentWithMultipleHooksPerLine', ); // external index map source map - await test( + await testFor( './__source__/__compiled__/bundle', 'ComponentWithMultipleHooksPerLine', ); // bundle source map - async function noColumnTest(path, name = 'Component') { + async function noColumntest(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -417,7 +426,7 @@ describe('parseHookNames', () => { // Note that this test is expected to only match the first two hooks // because the 3rd and 4th hook are on the same line, // and this type of source map doesn't have column numbers. - await noColumnTest( + await noColumntest( './__source__/__compiled__/no-columns/ComponentWithMultipleHooksPerLine', ); // simulated Webpack 'cheap-module-source-map' }); @@ -425,8 +434,9 @@ describe('parseHookNames', () => { // TODO Inline require (e.g. require("react").useState()) isn't supported yet. // Maybe this isn't an important use case to support, // since inline requires are most likely to exist in compiled source (if at all). - xit('should work for inline requires', async () => { - async function test(path, name = 'Component') { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should work for inline requires', async () => { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -434,17 +444,19 @@ describe('parseHookNames', () => { ]); } - await test('./__source__/InlineRequire'); // original source (uncompiled) - await test('./__source__/__compiled__/inline/InlineRequire'); // inline source map - await test('./__source__/__compiled__/external/InlineRequire'); // external source map - await test('./__source__/__compiled__/inline/index-map/InlineRequire'); // inline index map source map - await test('./__source__/__compiled__/external/index-map/InlineRequire'); // external index map source map - await test('./__source__/__compiled__/bundle', 'InlineRequire'); // bundle source map - await test('./__source__/__compiled__/no-columns/InlineRequire'); // simulated Webpack 'cheap-module-source-map' + await testFor('./__source__/InlineRequire'); // original source (uncompiled) + await testFor('./__source__/__compiled__/inline/InlineRequire'); // inline source map + await testFor('./__source__/__compiled__/external/InlineRequire'); // external source map + await testFor('./__source__/__compiled__/inline/index-map/InlineRequire'); // inline index map source map + await testFor( + './__source__/__compiled__/external/index-map/InlineRequire', + ); // external index map source map + await testFor('./__source__/__compiled__/bundle', 'InlineRequire'); // bundle source map + await testFor('./__source__/__compiled__/no-columns/InlineRequire'); // simulated Webpack 'cheap-module-source-map' }); it('should support sources that contain the string "sourceMappingURL="', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -455,24 +467,24 @@ describe('parseHookNames', () => { // We expect the inline sourceMappingURL to be invalid in this case; mute the warning. console.warn = () => {}; - await test('./__source__/ContainingStringSourceMappingURL'); // original source (uncompiled) - await test( + await testFor('./__source__/ContainingStringSourceMappingURL'); // original source (uncompiled) + await testFor( './__source__/__compiled__/inline/ContainingStringSourceMappingURL', ); // inline source map - await test( + await testFor( './__source__/__compiled__/external/ContainingStringSourceMappingURL', ); // external source map - await test( + await testFor( './__source__/__compiled__/inline/index-map/ContainingStringSourceMappingURL', ); // inline index map source map - await test( + await testFor( './__source__/__compiled__/external/index-map/ContainingStringSourceMappingURL', ); // external index map source map - await test( + await testFor( './__source__/__compiled__/bundle', 'ContainingStringSourceMappingURL', ); // bundle source map - await test( + await testFor( './__source__/__compiled__/no-columns/ContainingStringSourceMappingURL', ); // simulated Webpack 'cheap-module-source-map' }); @@ -487,7 +499,7 @@ describe('parseHookNames', () => { }); it('should work for simple components', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -497,30 +509,30 @@ describe('parseHookNames', () => { expect(require('../generateHookMap').decodeHookMap).toHaveBeenCalled(); } - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/Example', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/Example', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/Example', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/Example', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/Example', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/Example', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/Example', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/Example', ); // x_react_sources extended external index map source map @@ -528,7 +540,7 @@ describe('parseHookNames', () => { }); it('should work with more complex files and components', async () => { - async function test(path, name = undefined) { + async function testFor(path, name = undefined) { const components = name != null ? require(path)[name] : require(path); let hookNames = await getHookNamesForComponent(components.List); @@ -555,30 +567,30 @@ describe('parseHookNames', () => { expect(require('../generateHookMap').decodeHookMap).toHaveBeenCalled(); } - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/ToDoList', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/ToDoList', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/ToDoList', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/ToDoList', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/ToDoList', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/ToDoList', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/ToDoList', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/ToDoList', ); // x_react_sources extended external index map source map @@ -586,7 +598,7 @@ describe('parseHookNames', () => { }); it('should work for custom hook', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -599,30 +611,30 @@ describe('parseHookNames', () => { expect(require('../generateHookMap').decodeHookMap).toHaveBeenCalled(); } - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/ComponentWithCustomHook', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/ComponentWithCustomHook', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/ComponentWithCustomHook', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/ComponentWithCustomHook', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/ComponentWithCustomHook', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/ComponentWithCustomHook', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/ComponentWithCustomHook', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/ComponentWithCustomHook', ); // x_react_sources extended external index map source map @@ -630,7 +642,7 @@ describe('parseHookNames', () => { }); it('should work when code is using hooks indirectly', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -642,30 +654,30 @@ describe('parseHookNames', () => { expect(require('../generateHookMap').decodeHookMap).toHaveBeenCalled(); } - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/ComponentUsingHooksIndirectly', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/ComponentUsingHooksIndirectly', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/ComponentUsingHooksIndirectly', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/ComponentUsingHooksIndirectly', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/ComponentUsingHooksIndirectly', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/ComponentUsingHooksIndirectly', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/ComponentUsingHooksIndirectly', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/ComponentUsingHooksIndirectly', ); // x_react_sources extended external index map source map @@ -673,7 +685,7 @@ describe('parseHookNames', () => { }); it('should work when code is using nested hooks', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; let InnerComponent; const hookNames = await getHookNamesForComponent(Component, { @@ -692,30 +704,30 @@ describe('parseHookNames', () => { expect(require('../generateHookMap').decodeHookMap).toHaveBeenCalled(); } - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/ComponentWithNestedHooks', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/ComponentWithNestedHooks', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/ComponentWithNestedHooks', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/ComponentWithNestedHooks', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/ComponentWithNestedHooks', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/ComponentWithNestedHooks', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/ComponentWithNestedHooks', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/ComponentWithNestedHooks', ); // x_react_sources extended external index map source map @@ -723,7 +735,7 @@ describe('parseHookNames', () => { }); it('should work for external hooks', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -737,30 +749,30 @@ describe('parseHookNames', () => { // We can't test the uncompiled source here, because it either needs to get transformed, // which would break the source mapping, or the import statements will fail. - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/ComponentWithExternalCustomHooks', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/ComponentWithExternalCustomHooks', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/ComponentWithExternalCustomHooks', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/ComponentWithExternalCustomHooks', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/ComponentWithExternalCustomHooks', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/ComponentWithExternalCustomHooks', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/ComponentWithExternalCustomHooks', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/ComponentWithExternalCustomHooks', ); // x_react_sources extended external index map source map @@ -768,7 +780,7 @@ describe('parseHookNames', () => { }); it('should work when multiple hooks are on a line', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -781,30 +793,30 @@ describe('parseHookNames', () => { expect(require('../generateHookMap').decodeHookMap).toHaveBeenCalled(); } - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/ComponentWithMultipleHooksPerLine', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/ComponentWithMultipleHooksPerLine', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/ComponentWithMultipleHooksPerLine', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/ComponentWithMultipleHooksPerLine', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/ComponentWithMultipleHooksPerLine', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/ComponentWithMultipleHooksPerLine', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/ComponentWithMultipleHooksPerLine', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/ComponentWithMultipleHooksPerLine', ); // x_react_sources extended external index map source map @@ -814,8 +826,9 @@ describe('parseHookNames', () => { // TODO Inline require (e.g. require("react").useState()) isn't supported yet. // Maybe this isn't an important use case to support, // since inline requires are most likely to exist in compiled source (if at all). - xit('should work for inline requires', async () => { - async function test(path, name = 'Component') { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should work for inline requires', async () => { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -825,30 +838,30 @@ describe('parseHookNames', () => { expect(require('../generateHookMap').decodeHookMap).toHaveBeenCalled(); } - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/InlineRequire', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/InlineRequire', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/InlineRequire', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/InlineRequire', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/InlineRequire', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/InlineRequire', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/InlineRequire', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/InlineRequire', ); // x_react_sources extended external index map source map @@ -856,7 +869,7 @@ describe('parseHookNames', () => { }); it('should support sources that contain the string "sourceMappingURL="', async () => { - async function test(path, name = 'Component') { + async function testFor(path, name = 'Component') { const Component = require(path)[name]; const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, [ @@ -869,30 +882,30 @@ describe('parseHookNames', () => { // We expect the inline sourceMappingURL to be invalid in this case; mute the warning. console.warn = () => {}; - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/ContainingStringSourceMappingURL', ); // x_facebook_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/ContainingStringSourceMappingURL', ); // x_facebook_sources extended external source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/ContainingStringSourceMappingURL', ); // x_react_sources extended inline source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/ContainingStringSourceMappingURL', ); // x_react_sources extended external source map // Using index map format for source maps - await test( + await testFor( './__source__/__compiled__/inline/fb-sources-extended/index-map/ContainingStringSourceMappingURL', ); // x_facebook_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/fb-sources-extended/index-map/ContainingStringSourceMappingURL', ); // x_facebook_sources extended external index map source map - await test( + await testFor( './__source__/__compiled__/inline/react-sources-extended/index-map/ContainingStringSourceMappingURL', ); // x_react_sources extended inline index map source map - await test( + await testFor( './__source__/__compiled__/external/react-sources-extended/index-map/ContainingStringSourceMappingURL', ); // x_react_sources extended external index map source map diff --git a/packages/react-devtools-timeline/src/content-views/utils/__tests__/colors-test.js b/packages/react-devtools-timeline/src/content-views/utils/__tests__/colors-test.js index 517cd3b66fee8..c8ba8d4849962 100644 --- a/packages/react-devtools-timeline/src/content-views/utils/__tests__/colors-test.js +++ b/packages/react-devtools-timeline/src/content-views/utils/__tests__/colors-test.js @@ -9,7 +9,7 @@ import {hslaColorToString, dimmedColor, ColorGenerator} from '../colors'; -describe(hslaColorToString, () => { +describe('hslaColorToString', () => { it('should transform colors to strings', () => { expect(hslaColorToString({h: 1, s: 2, l: 3, a: 4})).toEqual( 'hsl(1deg 2% 3% / 4)', @@ -20,7 +20,7 @@ describe(hslaColorToString, () => { }); }); -describe(dimmedColor, () => { +describe('dimmedColor', () => { it('should dim luminosity using delta', () => { expect(dimmedColor({h: 1, s: 2, l: 3, a: 4}, 3)).toEqual({ h: 1, @@ -37,8 +37,8 @@ describe(dimmedColor, () => { }); }); -describe(ColorGenerator, () => { - describe(ColorGenerator.prototype.colorForID, () => { +describe('ColorGenerator', () => { + describe('colorForID', () => { it('should generate a color for an ID', () => { expect(new ColorGenerator().colorForID('123')).toMatchInlineSnapshot(` { diff --git a/packages/react-devtools-timeline/src/view-base/__tests__/geometry-test.js b/packages/react-devtools-timeline/src/view-base/__tests__/geometry-test.js index 6a55ceb1265d6..f49d634c8e5e8 100644 --- a/packages/react-devtools-timeline/src/view-base/__tests__/geometry-test.js +++ b/packages/react-devtools-timeline/src/view-base/__tests__/geometry-test.js @@ -19,7 +19,7 @@ import { unionOfRects, } from '../geometry'; -describe(pointEqualToPoint, () => { +describe('pointEqualToPoint', () => { it('should return true when 2 points have the same values', () => { expect(pointEqualToPoint({x: 1, y: 1}, {x: 1, y: 1})).toBe(true); expect(pointEqualToPoint({x: -1, y: 2}, {x: -1, y: 2})).toBe(true); @@ -37,7 +37,7 @@ describe(pointEqualToPoint, () => { }); }); -describe(sizeEqualToSize, () => { +describe('sizeEqualToSize', () => { it('should return true when 2 sizes have the same values', () => { expect(sizeEqualToSize({width: 1, height: 1}, {width: 1, height: 1})).toBe( true, @@ -69,7 +69,7 @@ describe(sizeEqualToSize, () => { }); }); -describe(rectEqualToRect, () => { +describe('rectEqualToRect', () => { it('should return true when 2 rects have the same values', () => { expect( rectEqualToRect( @@ -101,7 +101,7 @@ describe(rectEqualToRect, () => { }); }); -describe(sizeIsValid, () => { +describe('sizeIsValid', () => { it('should return true when the size has non-negative width and height', () => { expect(sizeIsValid({width: 1, height: 1})).toBe(true); expect(sizeIsValid({width: 0, height: 0})).toBe(true); @@ -114,7 +114,7 @@ describe(sizeIsValid, () => { }); }); -describe(sizeIsEmpty, () => { +describe('sizeIsEmpty', () => { it('should return true when the size has negative area', () => { expect(sizeIsEmpty({width: 1, height: -1})).toBe(true); expect(sizeIsEmpty({width: -1, height: -1})).toBe(true); @@ -132,7 +132,7 @@ describe(sizeIsEmpty, () => { }); }); -describe(rectIntersectsRect, () => { +describe('rectIntersectsRect', () => { it('should return true when 2 rects intersect', () => { // Rects touch expect( @@ -175,7 +175,7 @@ describe(rectIntersectsRect, () => { }); }); -describe(intersectionOfRects, () => { +describe('intersectionOfRects', () => { // NOTE: Undefined behavior if rects do not intersect it('should return intersection when 2 rects intersect', () => { @@ -205,7 +205,7 @@ describe(intersectionOfRects, () => { }); }); -describe(rectContainsPoint, () => { +describe('rectContainsPoint', () => { it("should return true if point is on the rect's edge", () => { expect( rectContainsPoint( @@ -246,7 +246,7 @@ describe(rectContainsPoint, () => { }); }); -describe(unionOfRects, () => { +describe('unionOfRects', () => { it('should return zero rect if no rects are provided', () => { expect(unionOfRects()).toEqual({ origin: {x: 0, y: 0}, diff --git a/packages/react-devtools-timeline/src/view-base/utils/__tests__/clamp-test.js b/packages/react-devtools-timeline/src/view-base/utils/__tests__/clamp-test.js index ec727b7347da5..c8bcb84903b9d 100644 --- a/packages/react-devtools-timeline/src/view-base/utils/__tests__/clamp-test.js +++ b/packages/react-devtools-timeline/src/view-base/utils/__tests__/clamp-test.js @@ -9,7 +9,7 @@ import {clamp} from '../clamp'; -describe(clamp, () => { +describe('clamp', () => { it('should return min if value < min', () => { expect(clamp(0, 1, -1)).toBe(0); expect(clamp(0.1, 1.1, 0.05)).toBe(0.1); diff --git a/packages/react-devtools-timeline/src/view-base/utils/__tests__/scrollState-test.js b/packages/react-devtools-timeline/src/view-base/utils/__tests__/scrollState-test.js index 0241ea3f14a5f..8129ea5d4afd5 100644 --- a/packages/react-devtools-timeline/src/view-base/utils/__tests__/scrollState-test.js +++ b/packages/react-devtools-timeline/src/view-base/utils/__tests__/scrollState-test.js @@ -15,7 +15,7 @@ import { zoomState, } from '../scrollState'; -describe(clampState, () => { +describe('clampState', () => { it('should passthrough offset if state fits within container', () => { expect( clampState({ @@ -137,7 +137,7 @@ describe(clampState, () => { }); }); -describe(translateState, () => { +describe('translateState', () => { it('should translate state by delta and leave length unchanged', () => { expect( translateState({ @@ -166,7 +166,7 @@ describe(translateState, () => { }); }); -describe(zoomState, () => { +describe('zoomState', () => { it('should scale width by multiplier', () => { expect( zoomState({ @@ -218,7 +218,7 @@ describe(zoomState, () => { }); }); -describe(moveStateToRange, () => { +describe('moveStateToRange', () => { it('should set [rangeStart, rangeEnd] = container', () => { const movedState = moveStateToRange({ state: {offset: -20, length: 100}, @@ -240,7 +240,7 @@ describe(moveStateToRange, () => { }); }); -describe(areScrollStatesEqual, () => { +describe('areScrollStatesEqual', () => { it('should return true if equal', () => { expect( areScrollStatesEqual({offset: 0, length: 0}, {offset: 0, length: 0}), diff --git a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js index 3108793c87dcf..8a2c6af5cae50 100644 --- a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js +++ b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js @@ -131,7 +131,7 @@ describe('ReactComponentLifeCycle', () => { * If a state update triggers rerendering that in turn fires an onDOMReady, * that second onDOMReady should not fail. */ - it('it should fire onDOMReady when already in onDOMReady', async () => { + it('should fire onDOMReady when already in onDOMReady', async () => { const _testJournal = []; class Child extends React.Component { diff --git a/packages/react-dom/src/__tests__/ReactCompositeComponentDOMMinimalism-test.js b/packages/react-dom/src/__tests__/ReactCompositeComponentDOMMinimalism-test.js index 84de6278bad95..ba51921ef3cec 100644 --- a/packages/react-dom/src/__tests__/ReactCompositeComponentDOMMinimalism-test.js +++ b/packages/react-dom/src/__tests__/ReactCompositeComponentDOMMinimalism-test.js @@ -54,7 +54,7 @@ describe('ReactCompositeComponentDOMMinimalism', () => { expect(instance.children.length).toBe(0); }); - it('should not render extra nodes for non-interpolated text', async () => { + it('should not render extra nodes for interpolated text', async () => { const container = document.createElement('div'); const root = ReactDOMClient.createRoot(container); await act(() => { @@ -70,7 +70,7 @@ describe('ReactCompositeComponentDOMMinimalism', () => { expect(instance.children.length).toBe(0); }); - it('should not render extra nodes for non-interpolated text', async () => { + it('should not render extra nodes for interpolated text children', async () => { const container = document.createElement('div'); const root = ReactDOMClient.createRoot(container); await act(() => { diff --git a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js index b72b3da8ced02..54401f54fe23b 100644 --- a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js @@ -1838,7 +1838,7 @@ describe('ReactDOMComponent', () => { }).toErrorDev('Directly setting property `innerHTML` is not permitted. '); }); - it('should validate use of dangerouslySetInnerHTML', async () => { + it('should validate use of dangerouslySetInnerHTM with JSX', async () => { await expect(async () => { await mountComponent({dangerouslySetInnerHTML: 'Hi Jim!'}); }).rejects.toThrowError( @@ -1847,7 +1847,7 @@ describe('ReactDOMComponent', () => { ); }); - it('should validate use of dangerouslySetInnerHTML', async () => { + it('should validate use of dangerouslySetInnerHTML with object', async () => { await expect(async () => { await mountComponent({dangerouslySetInnerHTML: {foo: 'bar'}}); }).rejects.toThrowError( diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js index 698809c678b52..ba7bf62c163ea 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js @@ -5338,7 +5338,7 @@ describe('ReactDOMFizzServer', () => { }); } - it('it only includes separators between adjacent text nodes', async () => { + it('only includes separators between adjacent text nodes', async () => { function App({name}) { return (
@@ -5370,7 +5370,7 @@ describe('ReactDOMFizzServer', () => { ); }); - it('it does not insert text separators even when adjacent text is in a delayed segment', async () => { + it('does not insert text separators even when adjacent text is in a delayed segment', async () => { function App({name}) { return ( @@ -5433,7 +5433,7 @@ describe('ReactDOMFizzServer', () => { ); }); - it('it works with multiple adjacent segments', async () => { + it('works with multiple adjacent segments', async () => { function App() { return ( @@ -5481,7 +5481,7 @@ describe('ReactDOMFizzServer', () => { ); }); - it('it works when some segments are flushed and others are patched', async () => { + it('works when some segments are flushed and others are patched', async () => { function App() { return ( @@ -5529,7 +5529,7 @@ describe('ReactDOMFizzServer', () => { ); }); - it('it does not prepend a text separators if the segment follows a non-Text Node', async () => { + it('does not prepend a text separators if the segment follows a non-Text Node', async () => { function App() { return ( @@ -5569,7 +5569,7 @@ describe('ReactDOMFizzServer', () => { ); }); - it('it does not prepend a text separators if the segments first emission is a non-Text Node', async () => { + it('does not prepend a text separators if the segments first emission is a non-Text Node', async () => { function App() { return ( diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js index cfeade2ff614a..4022f227a8abe 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js @@ -412,7 +412,10 @@ describe('ReactDOMFizzServerBrowser', () => { let result; result = await readResult(stream); + expect(result).toMatchInlineSnapshot( + // TODO: remove interpolation because it prevents snapshot updates. + // eslint-disable-next-line jest/no-interpolation-in-snapshots `"
${str492}
${str492}
"`, ); @@ -428,6 +431,8 @@ describe('ReactDOMFizzServerBrowser', () => { ); result = await readResult(stream); + // TODO: remove interpolation because it prevents snapshot updates. + // eslint-disable-next-line jest/no-interpolation-in-snapshots expect(result).toMatchInlineSnapshot(`"
${str2049}
"`); }); @@ -540,6 +545,8 @@ describe('ReactDOMFizzServerBrowser', () => { ); const result = await readResult(stream); expect(result).toMatchInlineSnapshot( + // TODO: remove interpolation because it prevents snapshot updates. + // eslint-disable-next-line jest/no-interpolation-in-snapshots `"
hello world
"`, ); }); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js index 999fbd9f7190d..5cafd83fdd243 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js @@ -167,7 +167,7 @@ describe('ReactDOMFizzShellHydration', () => { textCache = new Map(); } - test('suspending in the shell during hydration', async () => { + it('suspending in the shell during hydration', async () => { const div = React.createRef(null); function App() { @@ -207,7 +207,7 @@ describe('ReactDOMFizzShellHydration', () => { expect(container.textContent).toBe('Shell'); }); - test('suspending in the shell during a normal client render', async () => { + it('suspending in the shell during a normal client render', async () => { // Same as previous test but during a normal client render, no hydration function App() { return ; @@ -226,7 +226,7 @@ describe('ReactDOMFizzShellHydration', () => { expect(container.textContent).toBe('Shell'); }); - test( + it( 'updating the root at lower priority than initial hydration does not ' + 'force a client render', async () => { @@ -255,7 +255,7 @@ describe('ReactDOMFizzShellHydration', () => { }, ); - test('updating the root while the shell is suspended forces a client render', async () => { + it('updating the root while the shell is suspended forces a client render', async () => { function App() { return ; } @@ -293,7 +293,7 @@ describe('ReactDOMFizzShellHydration', () => { expect(container.textContent).toBe('New screen'); }); - test('TODO: A large component stack causes SSR to stack overflow', async () => { + it('TODO: A large component stack causes SSR to stack overflow', async () => { spyOnDevAndProd(console, 'error').mockImplementation(() => {}); function NestedComponent({depth}: {depth: number}) { diff --git a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js index 01a6d6f13727f..e69183ebabe8e 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js @@ -2951,7 +2951,8 @@ body { ); }); - xit('can delay commit until css resources error', async () => { + // eslint-disable-next-line jest/no-disabled-tests + it.skip('can delay commit until css resources error', async () => { // TODO: This test fails and crashes jest. need to figure out why before unskipping. const root = ReactDOMClient.createRoot(container); expect(getMeaningfulChildren(container)).toBe(undefined); @@ -6191,7 +6192,7 @@ body { ); }); - it('creates a stylesheet resource in the ownerDocument when ReactDOM.preinit(..., {as: "style" }) is called outside of render on the client', async () => { + it('creates a stylesheet resource in the ownerDocument when ReactDOM.preinit(..., {as: "style" }) is called in shadowRoot', async () => { // This is testing behavior, but it shows that it is not a good idea to preinit inside a shadowRoot. The point is we are asserting a behavior // you would want to avoid in a real app. const shadow = document.body.attachShadow({mode: 'open'}); diff --git a/packages/react-dom/src/__tests__/ReactDOMForm-test.js b/packages/react-dom/src/__tests__/ReactDOMForm-test.js index fbae2805bad88..513a25d1542b4 100644 --- a/packages/react-dom/src/__tests__/ReactDOMForm-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMForm-test.js @@ -989,7 +989,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test('useActionState updates state asynchronously and queues multiple actions', async () => { + it('useActionState updates state asynchronously and queues multiple actions', async () => { let actionCounter = 0; async function action(state, type) { actionCounter++; @@ -1049,7 +1049,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test('useActionState supports inline actions', async () => { + it('useActionState supports inline actions', async () => { let increment; function App({stepSize}) { const [state, dispatch, isPending] = useActionState(async prevState => { @@ -1081,7 +1081,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test('useActionState: dispatch throws if called during render', async () => { + it('useActionState: dispatch throws if called during render', async () => { function App() { const [state, dispatch, isPending] = useActionState(async () => {}, 0); dispatch(); @@ -1097,7 +1097,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test('useActionState: queues multiple actions and runs them in order', async () => { + it('useActionState: queues multiple actions and runs them in order', async () => { let action; function App() { const [state, dispatch, isPending] = useActionState( @@ -1129,7 +1129,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test( + it( 'useActionState: when calling a queued action, uses the implementation ' + 'that was current at the time it was dispatched, not the most recent one', async () => { @@ -1176,7 +1176,7 @@ describe('ReactDOMForm', () => { ); // @gate enableAsyncActions - test('useActionState: works if action is sync', async () => { + it('useActionState: works if action is sync', async () => { let increment; function App({stepSize}) { const [state, dispatch, isPending] = useActionState(prevState => { @@ -1208,7 +1208,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test('useActionState: can mix sync and async actions', async () => { + it('useActionState: can mix sync and async actions', async () => { let action; function App() { const [state, dispatch, isPending] = useActionState((s, a) => a, 'A'); @@ -1236,7 +1236,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test('useActionState: error handling (sync action)', async () => { + it('useActionState: error handling (sync action)', async () => { class ErrorBoundary extends React.Component { state = {error: null}; static getDerivedStateFromError(error) { @@ -1285,7 +1285,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test('useActionState: error handling (async action)', async () => { + it('useActionState: error handling (async action)', async () => { class ErrorBoundary extends React.Component { state = {error: null}; static getDerivedStateFromError(error) { @@ -1331,7 +1331,7 @@ describe('ReactDOMForm', () => { expect(container.textContent).toBe('Caught an error: Oops!'); }); - test('useActionState: when an action errors, subsequent actions are canceled', async () => { + it('useActionState: when an action errors, subsequent actions are canceled', async () => { class ErrorBoundary extends React.Component { state = {error: null}; static getDerivedStateFromError(error) { @@ -1391,7 +1391,7 @@ describe('ReactDOMForm', () => { }); // @gate enableAsyncActions - test('useActionState works in StrictMode', async () => { + it('useActionState works in StrictMode', async () => { let actionCounter = 0; async function action(state, type) { actionCounter++; @@ -1437,7 +1437,7 @@ describe('ReactDOMForm', () => { expect(container.textContent).toBe('1'); }); - test('useActionState does not wrap action in a transition unless dispatch is in a transition', async () => { + it('useActionState does not wrap action in a transition unless dispatch is in a transition', async () => { let dispatch; function App() { const [state, _dispatch] = useActionState(() => { @@ -1479,7 +1479,7 @@ describe('ReactDOMForm', () => { expect(container.textContent).toBe('Count: 2'); }); - test('useActionState warns if async action is dispatched outside of a transition', async () => { + it('useActionState warns if async action is dispatched outside of a transition', async () => { let dispatch; function App() { const [state, _dispatch] = useActionState(async () => { @@ -1508,7 +1508,7 @@ describe('ReactDOMForm', () => { expect(container.textContent).toBe('Count: 0'); }); - test('uncontrolled form inputs are reset after the action completes', async () => { + it('uncontrolled form inputs are reset after the action completes', async () => { const formRef = React.createRef(); const inputRef = React.createRef(); const divRef = React.createRef(); @@ -1586,7 +1586,7 @@ describe('ReactDOMForm', () => { expect(divRef.current.textContent).toEqual('Current username: acdlite'); }); - test('requestFormReset schedules a form reset after transition completes', async () => { + it('requestFormReset schedules a form reset after transition completes', async () => { // This is the same as the previous test, except the form is updated with // a userspace action instead of a built-in form action. @@ -1671,7 +1671,7 @@ describe('ReactDOMForm', () => { expect(divRef.current.textContent).toEqual('Current username: acdlite'); }); - test( + it( 'requestFormReset works with inputs that are not descendants ' + 'of the form element', async () => { @@ -1764,7 +1764,7 @@ describe('ReactDOMForm', () => { }, ); - test('reset multiple forms in the same transition', async () => { + it('reset multiple forms in the same transition', async () => { const formRefA = React.createRef(); const formRefB = React.createRef(); @@ -1853,7 +1853,7 @@ describe('ReactDOMForm', () => { expect(formRefB.current.elements.inputName.value).toBe('B2'); }); - test('requestFormReset throws if the form is not managed by React', async () => { + it('requestFormReset throws if the form is not managed by React', async () => { container.innerHTML = `
@@ -1874,7 +1874,7 @@ describe('ReactDOMForm', () => { expect(input.value).toBe(''); }); - test('requestFormReset throws on a non-form DOM element', async () => { + it('requestFormReset throws on a non-form DOM element', async () => { const root = ReactDOMClient.createRoot(container); const ref = React.createRef(); await act(() => root.render(
Hi
)); @@ -1884,7 +1884,7 @@ describe('ReactDOMForm', () => { expect(() => requestFormReset(div)).toThrow('Invalid form element.'); }); - test('warns if requestFormReset is called outside of a transition', async () => { + it('warns if requestFormReset is called outside of a transition', async () => { const formRef = React.createRef(); const inputRef = React.createRef(); @@ -1933,7 +1933,7 @@ describe('ReactDOMForm', () => { expect(inputRef.current.value).toBe('Initial'); }); - test("regression: submitter's formAction prop is coerced correctly before checking if it exists", async () => { + it("regression: submitter's formAction prop is coerced correctly before checking if it exists", async () => { function App({submitterAction}) { return ( Scheduler.log('Form action')}> @@ -1977,7 +1977,7 @@ describe('ReactDOMForm', () => { ); }); - test( + it( 'useFormStatus is activated if startTransition is called ' + 'inside preventDefault-ed submit event', async () => { @@ -2045,7 +2045,7 @@ describe('ReactDOMForm', () => { }, ); - test('useFormStatus is not activated if startTransition is not called', async () => { + it('useFormStatus is not activated if startTransition is not called', async () => { function Output({value}) { const {pending} = useFormStatus(); @@ -2116,7 +2116,7 @@ describe('ReactDOMForm', () => { expect(inputRef.current.value).toBe('Updated again after submission'); }); - test('useFormStatus is not activated if event is not preventDefault-ed ', async () => { + it('useFormStatus is not activated if event is not preventDefault-ed', async () => { function Output({value}) { const {pending} = useFormStatus(); return ; @@ -2171,7 +2171,7 @@ describe('ReactDOMForm', () => { expect(outputRef.current.textContent).toBe('Initial'); }); - test('useFormStatus coerces the value of the "action" prop', async () => { + it('useFormStatus coerces the value of the "action" prop', async () => { function Status() { const {pending, action} = useFormStatus(); diff --git a/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js b/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js index 147a84207947c..bfc4303a14470 100644 --- a/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js @@ -685,7 +685,7 @@ describe('ReactDOMServerHydration', () => { }); // @gate __DEV__ - it('warns when client renders an extra text node in the beginning', () => { + it('warns when client renders an extra text node in the middle', () => { function Mismatch({isClient}) { return (
diff --git a/packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js index 7e38923991fae..89518d7f498a3 100644 --- a/packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js @@ -259,7 +259,7 @@ describe('ReactDOMImageLoad', () => { expect(onLoadSpy).toHaveBeenCalledTimes(1); }); - it('it replays the last load event when more than one fire before the end of the layout phase completes', async function () { + it('replays the last load event when more than one fire before the end of the layout phase completes', async function () { const container = document.createElement('div'); const root = ReactDOMClient.createRoot(container); @@ -436,6 +436,7 @@ describe('ReactDOMImageLoad', () => { expect(onLoadSpy).not.toHaveBeenCalled(); }); + // eslint-disable-next-line jest/no-commented-out-tests // it('captures the load event if it happens in a suspended subtree and replays it between layout and passive effects on resumption', async function() { // function SuspendingWithImage() { // Scheduler.log('SuspendingWithImage'); diff --git a/packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js b/packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js index f7b0db175e5f6..49be40397107d 100644 --- a/packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js @@ -29,7 +29,7 @@ describe('ReactDOMNestedEvents', () => { assertLog = InternalTestUtils.assertLog; }); - test('nested event dispatches should not cause updates to flush', async () => { + it('nested event dispatches should not cause updates to flush', async () => { const buttonRef = React.createRef(null); function App() { const [isClicked, setIsClicked] = useState(false); diff --git a/packages/react-dom/src/__tests__/ReactDOMRoot-test.js b/packages/react-dom/src/__tests__/ReactDOMRoot-test.js index 993e6e5a641fa..5ab8e4e90294d 100644 --- a/packages/react-dom/src/__tests__/ReactDOMRoot-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMRoot-test.js @@ -59,7 +59,7 @@ describe('ReactDOMRoot', () => { expect(callback).not.toHaveBeenCalled(); }); - it('warn if a container is passed to root.render(...)', async () => { + it('warn if a object is passed to root.render(...)', async () => { function App() { return 'Child'; } diff --git a/packages/react-dom/src/__tests__/ReactDOMSelect-test.js b/packages/react-dom/src/__tests__/ReactDOMSelect-test.js index eac858697f572..1f11786771933 100644 --- a/packages/react-dom/src/__tests__/ReactDOMSelect-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMSelect-test.js @@ -1515,7 +1515,7 @@ describe('ReactDOMSelect', () => { ]); }); - it('throws when given a Temporal.PlainDate-like value (both)', async () => { + it('throws when given a Temporal.PlainDate-like defaultValue (both)', async () => { const container = document.createElement('div'); const root = ReactDOMClient.createRoot(container); await expect(async () => { diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js index 017217511fce9..af2d7a7ef921a 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js @@ -48,7 +48,7 @@ describe('ReactDOMServerIntegration', () => { // The `itRenders` test abstraction doesn't work with @gate so we have // to do this instead. if (gate(flags => flags.disableLegacyContext)) { - test('empty test to stop Jest from being a complainy complainer', () => {}); + it('empty test to stop Jest from being a complainy complainer', () => {}); return; } diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js index 8d06e2d8ea857..1cae7f15b0b4b 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js @@ -326,12 +326,14 @@ describe('ReactDOMServerIntegrationUserInteraction', () => { // skipping this test because React 15 does the wrong thing. it blows // away the user's typing in the textarea. - xit('should not blow away user-entered text on successful reconnect to an uncontrolled textarea', () => + // eslint-disable-next-line jest/no-disabled-tests + it.skip('should not blow away user-entered text on successful reconnect to an uncontrolled textarea', () => testUserInteractionBeforeClientRender(