From eb8d275738f06296a1ef5be100b24f2a37dbe0d1 Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Tue, 19 Nov 2019 16:55:11 -0500 Subject: [PATCH 01/14] feat: add "cleanup" function --- src/render.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/render.js b/src/render.js index cb46f726..e0cc4c4d 100644 --- a/src/render.js +++ b/src/render.js @@ -8,6 +8,7 @@ import { queryByAPI } from './helpers/queryByAPI'; import a11yAPI from './helpers/a11yAPI'; import debugShallow from './helpers/debugShallow'; import debugDeep from './helpers/debugDeep'; +import cleanup from './cleanup'; type Options = { wrapper?: React.ComponentType, From 42cd20eac4de178d45401928735df1a9bf2e00fe Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Tue, 19 Nov 2019 16:55:24 -0500 Subject: [PATCH 02/14] docs: add "cleanup" section --- src/render.js | 1 - website/docs/API.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/render.js b/src/render.js index e0cc4c4d..cb46f726 100644 --- a/src/render.js +++ b/src/render.js @@ -8,7 +8,6 @@ import { queryByAPI } from './helpers/queryByAPI'; import a11yAPI from './helpers/a11yAPI'; import debugShallow from './helpers/debugShallow'; import debugDeep from './helpers/debugDeep'; -import cleanup from './cleanup'; type Options = { wrapper?: React.ComponentType, diff --git a/website/docs/API.md b/website/docs/API.md index f3037d77..38d19288 100644 --- a/website/docs/API.md +++ b/website/docs/API.md @@ -351,7 +351,7 @@ Defined as: function within(instance: ReactTestInstance): Queries ``` -Perform [queries](./Queries.md) scoped to given element. +Perform [queries](./Queries.md) scoped to given element. :::note Please note that additional `render` specific operations like `update`, `unmount`, `debug`, `toJSON` are _not_ included. From 20969cb51870b5f087e6b6d4707e2cc25c12fa64 Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Tue, 19 Nov 2019 17:23:59 -0500 Subject: [PATCH 03/14] feat: automatically call "cleanup" after each test ...if an "afterEach" global function is defined, and process.env.RTL_SKIP_AUTO_CLEANUP is falsy. Taken from: https://github.com/testing-library/react-testing-library/blob/14670debd45236d2c5d0a61a83dadc72af1bef7c/src/index.js --- src/index.js | 32 ++++++++++++++------------------ src/pure.js | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 src/pure.js diff --git a/src/index.js b/src/index.js index 2e7ac9f2..084719a6 100644 --- a/src/index.js +++ b/src/index.js @@ -1,20 +1,16 @@ -// @flow -import act from './act'; -import cleanup from './cleanup'; -import debug from './debug'; -import fireEvent from './fireEvent'; import flushMicrotasksQueue from './flushMicrotasksQueue'; -import render from './render'; -import shallow from './shallow'; -import waitForElement from './waitForElement'; -import within from './within'; +import { cleanup } from './pure'; -export { act }; -export { cleanup }; -export { debug }; -export { fireEvent }; -export { flushMicrotasksQueue }; -export { render }; -export { shallow }; -export { waitForElement }; -export { within }; +// if we're running in a test runner that supports afterEach +// then we'll automatically run cleanup afterEach test +// this ensures that tests run in isolation from each other +// if you don't like this then either import the `pure` module +// or set the RTL_SKIP_AUTO_CLEANUP env variable to 'true'. +if (typeof afterEach === 'function' && !process.env.RTL_SKIP_AUTO_CLEANUP) { + afterEach(async () => { + await flushMicrotasksQueue(); + cleanup(); + }); +} + +export * from './pure'; diff --git a/src/pure.js b/src/pure.js new file mode 100644 index 00000000..f4263745 --- /dev/null +++ b/src/pure.js @@ -0,0 +1,18 @@ +// @flow +import act from './act'; +import cleanup from './cleanup'; +import debug from './debug'; +import fireEvent from './fireEvent'; +import flushMicrotasksQueue from './flushMicrotasksQueue'; +import render from './render'; +import shallow from './shallow'; +import waitForElement from './waitForElement'; + +export { act }; +export { cleanup }; +export { debug }; +export { fireEvent }; +export { flushMicrotasksQueue }; +export { render }; +export { shallow }; +export { waitForElement }; From 74d63bff25236506949115589263193f5aef9f66 Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Tue, 19 Nov 2019 17:27:55 -0500 Subject: [PATCH 04/14] docs: mention automatic cleanup --- website/docs/API.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/API.md b/website/docs/API.md index 38d19288..0b837c69 100644 --- a/website/docs/API.md +++ b/website/docs/API.md @@ -123,6 +123,8 @@ const cleanup: () => void; Unmounts React trees that were mounted with `render`. +> Please note that this is done automatically if the testing framework you're using supports the `afterEach` global (like mocha, Jest, and Jasmine). If not, you will need to do manual cleanups after each test. + For example, if you're using the `jest` testing framework, then you would need to use the `afterEach` hook like so: ```jsx From 70fbaffcfd7e0dbca898548001fd030d0e618322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 14 May 2020 22:13:04 +0200 Subject: [PATCH 05/14] add within --- src/pure.js | 2 ++ yarn.lock | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pure.js b/src/pure.js index f4263745..2e7ac9f2 100644 --- a/src/pure.js +++ b/src/pure.js @@ -7,6 +7,7 @@ import flushMicrotasksQueue from './flushMicrotasksQueue'; import render from './render'; import shallow from './shallow'; import waitForElement from './waitForElement'; +import within from './within'; export { act }; export { cleanup }; @@ -16,3 +17,4 @@ export { flushMicrotasksQueue }; export { render }; export { shallow }; export { waitForElement }; +export { within }; diff --git a/yarn.lock b/yarn.lock index 03b191a5..2c2f3a23 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8992,7 +8992,7 @@ uuid@7.0.1: resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.1.tgz#95ed6ff3d8c881cbf85f0f05cc3915ef994818ef" integrity sha512-yqjRXZzSJm9Dbl84H2VDHpM3zMjzSJQ+hn6C4zqd5ilW+7P4ZmLEEqwho9LjP+tGuZlF4xrHQXT0h9QZUS/pWA== -uuid@7.0.3: +uuid@7.0.3, uuid@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b" integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg== @@ -9112,7 +9112,7 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= -which@^1.2.9, which@^1.3.1: +which@^1.2.9: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== From eac99b2c670d9770206ea8b21a10b349cb49ecc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 14 May 2020 22:13:41 +0200 Subject: [PATCH 06/14] fix lint --- src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.js b/src/index.js index 084719a6..5c96ed1b 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,7 @@ import { cleanup } from './pure'; // if you don't like this then either import the `pure` module // or set the RTL_SKIP_AUTO_CLEANUP env variable to 'true'. if (typeof afterEach === 'function' && !process.env.RTL_SKIP_AUTO_CLEANUP) { + // eslint-disable-next-line no-undef afterEach(async () => { await flushMicrotasksQueue(); cleanup(); From 561022ffabf37d440b547d73902b6be441d52022 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Wed, 20 May 2020 10:35:21 +0200 Subject: [PATCH 07/14] Updated tests, added auto-cleanup test --- src/__tests__/auto-cleanup.js | 34 ++++++++++++++++++++++++++++++++++ src/__tests__/cleanup.test.js | 2 +- src/__tests__/waitFor.test.js | 2 ++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/__tests__/auto-cleanup.js diff --git a/src/__tests__/auto-cleanup.js b/src/__tests__/auto-cleanup.js new file mode 100644 index 00000000..7cf06dc5 --- /dev/null +++ b/src/__tests__/auto-cleanup.js @@ -0,0 +1,34 @@ +import React from 'react'; +import { View } from 'react-native'; +import { render } from '..'; + +let isMounted = false; + +class Test extends React.Component<*> { + componentDidMount() { + isMounted = true; + } + + componentWillUnmount() { + isMounted = false; + if (this.props.onUnmount) { + this.props.onUnmount(); + } + } + render() { + return ; + } +} + +// This just verifies that by importing RNTL in an +// environment which supports afterEach (like jest) +// we'll get automatic cleanup between tests. +test('first', () => { + const fn = jest.fn(); + render(); + expect(fn).not.toHaveBeenCalled(); +}); + +test('second', () => { + expect(isMounted).toEqual(false); +}); diff --git a/src/__tests__/cleanup.test.js b/src/__tests__/cleanup.test.js index 7ce5bfc4..1ccb752b 100644 --- a/src/__tests__/cleanup.test.js +++ b/src/__tests__/cleanup.test.js @@ -2,7 +2,7 @@ /* eslint-disable react/no-multi-comp */ import React from 'react'; import { View } from 'react-native'; -import { cleanup, render } from '..'; +import { cleanup, render } from '../pure'; class Test extends React.Component<*> { componentWillUnmount() { diff --git a/src/__tests__/waitFor.test.js b/src/__tests__/waitFor.test.js index 891c8457..e0460810 100644 --- a/src/__tests__/waitFor.test.js +++ b/src/__tests__/waitFor.test.js @@ -55,6 +55,8 @@ test('waits for element until timeout is met', async () => { await expect( waitFor(() => getByText('Fresh'), { timeout: 100 }) ).rejects.toThrow(); + + await waitFor(() => getByText('Fresh')); }); test('waits for element with custom interval', async () => { From b8f96a942364b614543a6c2703435b5cacd6f8d7 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Wed, 20 May 2020 12:06:31 +0200 Subject: [PATCH 08/14] Added ways to prevent auto cleanup --- dont-cleanup-after-each.js | 1 + pure.js | 2 ++ src/__tests__/auto-cleanup-skip.js | 40 ++++++++++++++++++++++++++++++ website/docs/API.md | 6 ++++- website/docs/Migration20.md | 24 ++++++++++++++++++ 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 dont-cleanup-after-each.js create mode 100644 pure.js create mode 100644 src/__tests__/auto-cleanup-skip.js diff --git a/dont-cleanup-after-each.js b/dont-cleanup-after-each.js new file mode 100644 index 00000000..d9a79f17 --- /dev/null +++ b/dont-cleanup-after-each.js @@ -0,0 +1 @@ +process.env.RNTL_SKIP_AUTO_CLEANUP = true; diff --git a/pure.js b/pure.js new file mode 100644 index 00000000..bced0b75 --- /dev/null +++ b/pure.js @@ -0,0 +1,2 @@ +// makes it so people can import from 'react-native-testing-library/pure' +module.exports = require('./build/pure'); diff --git a/src/__tests__/auto-cleanup-skip.js b/src/__tests__/auto-cleanup-skip.js new file mode 100644 index 00000000..0ef377b3 --- /dev/null +++ b/src/__tests__/auto-cleanup-skip.js @@ -0,0 +1,40 @@ +import React from 'react'; +import { View } from 'react-native'; + +let render; +beforeAll(() => { + process.env.RTL_SKIP_AUTO_CLEANUP = 'true'; + const rtl = require('../'); + render = rtl.render; +}); + +let isMounted = false; + +class Test extends React.Component<*> { + componentDidMount() { + isMounted = true; + } + + componentWillUnmount() { + isMounted = false; + if (this.props.onUnmount) { + this.props.onUnmount(); + } + } + render() { + return ; + } +} + +// This just verifies that by importing RNTL in an +// environment which supports afterEach (like jest) +// we'll get automatic cleanup between tests. +test('first', () => { + const fn = jest.fn(); + render(); + expect(fn).not.toHaveBeenCalled(); +}); + +test('second', () => { + expect(isMounted).toEqual(true); +}); diff --git a/website/docs/API.md b/website/docs/API.md index 932945c7..8a691f53 100644 --- a/website/docs/API.md +++ b/website/docs/API.md @@ -74,7 +74,11 @@ Re-render the in-memory tree with a new root element. This simulates a React upd unmount(): void ``` -Unmount the in-memory tree, triggering the appropriate lifecycle events +Unmount the in-memory tree, triggering the appropriate lifecycle events. + +:::note +Usually you should not need to call `unmount` as it is done automatically if your test runner supports `afterEach` hook (like Jest, mocha, Jasmine). +::: ### `debug` diff --git a/website/docs/Migration20.md b/website/docs/Migration20.md index cdf4ecd8..935af648 100644 --- a/website/docs/Migration20.md +++ b/website/docs/Migration20.md @@ -9,6 +9,30 @@ This guides describes major steps involved in migrating your testing code from u Node 8 reached its EOL more than 5 months ago, so it's about time to target the library to Node 10. If you used lower version, you'll have to upgrade to v10, but we suggest using the latest LTS version. +## Auto Cleanup + +`cleanup()` function is now called automatically after every test, if your testing framework supports `afterEach` hook (like Jest, mocha, and Jasmine). + +You should be able to safely remove all `afterEach(cleanup)` calls in your code. + +This change might break your code, if you tests are not isolated, i.e. you call `render` outside `test` block. Generally, you should [keep your tests isolated](https://kentcdodds.com/blog/test-isolation-with-react), but if you can't or don't want to do this right away you can prevent this behavior using any of the foloowing ways: + +1. by importing `'react-native-testing-library/pure'` instead of `'react-native-testing-library'` + +2. by importing `'react-native-testing-library/dont-cleanup-after-each'` before importing `'react-native-testing-library'`. You can do it in a global way by using Jest's `setupFiles` like this: + +```js +{ + setupFiles: ['react-native-testing-library/dont-cleanup-after-each']; +} +``` + +3. by setting `RTNL_SKIP_AUTO_CLEANUP` env variable to `true`. You can do this with `cross-evn` like this: + +```sh +cross-env RNTL_SKIP_AUTO_CLEANUP=true jest +``` + ## WaitFor API changes `waitForElement` function has been renamed to `waitFor` for consistency with React Testing Library. Additionally the signature has slightly changed from: From b0b7b5832c5d06f08647132298c612487b1de7fc Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Wed, 20 May 2020 12:11:24 +0200 Subject: [PATCH 09/14] Small fix --- src/__tests__/auto-cleanup-skip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/auto-cleanup-skip.js b/src/__tests__/auto-cleanup-skip.js index 0ef377b3..2daaecaf 100644 --- a/src/__tests__/auto-cleanup-skip.js +++ b/src/__tests__/auto-cleanup-skip.js @@ -3,7 +3,7 @@ import { View } from 'react-native'; let render; beforeAll(() => { - process.env.RTL_SKIP_AUTO_CLEANUP = 'true'; + process.env.RNTL_SKIP_AUTO_CLEANUP = 'true'; const rtl = require('../'); render = rtl.render; }); From c358d72c2e46c2e32c49607ee31ccffb48b7c83d Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Wed, 20 May 2020 13:12:33 +0200 Subject: [PATCH 10/14] Code review changes --- src/__tests__/auto-cleanup-skip.js | 9 ++++----- src/__tests__/auto-cleanup.js | 7 +++---- src/__tests__/waitFor.test.js | 2 ++ src/index.js | 1 + 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/__tests__/auto-cleanup-skip.js b/src/__tests__/auto-cleanup-skip.js index 2daaecaf..eece886a 100644 --- a/src/__tests__/auto-cleanup-skip.js +++ b/src/__tests__/auto-cleanup-skip.js @@ -26,15 +26,14 @@ class Test extends React.Component<*> { } } -// This just verifies that by importing RNTL in an -// environment which supports afterEach (like jest) -// we'll get automatic cleanup between tests. -test('first', () => { +// This just verifies that by importing RNTL in pure mode in an environment which supports +// afterEach (like jest) we won't get automatic cleanup between tests. +test('component is mounted, but not umounted before test ends', () => { const fn = jest.fn(); render(); expect(fn).not.toHaveBeenCalled(); }); -test('second', () => { +test('component is NOT automatically umounted after first test ends', () => { expect(isMounted).toEqual(true); }); diff --git a/src/__tests__/auto-cleanup.js b/src/__tests__/auto-cleanup.js index 7cf06dc5..5a26d7c8 100644 --- a/src/__tests__/auto-cleanup.js +++ b/src/__tests__/auto-cleanup.js @@ -20,15 +20,14 @@ class Test extends React.Component<*> { } } -// This just verifies that by importing RNTL in an -// environment which supports afterEach (like jest) +// This just verifies that by importing RNTL in an environment which supports afterEach (like jest) // we'll get automatic cleanup between tests. -test('first', () => { +test('component is mounted, but not umounted before test ends', () => { const fn = jest.fn(); render(); expect(fn).not.toHaveBeenCalled(); }); -test('second', () => { +test('component is automatically umounted after first test ends', () => { expect(isMounted).toEqual(false); }); diff --git a/src/__tests__/waitFor.test.js b/src/__tests__/waitFor.test.js index e0460810..e38f05c4 100644 --- a/src/__tests__/waitFor.test.js +++ b/src/__tests__/waitFor.test.js @@ -56,6 +56,8 @@ test('waits for element until timeout is met', async () => { waitFor(() => getByText('Fresh'), { timeout: 100 }) ).rejects.toThrow(); + // Async action ends after 300ms and we only waited 100ms, so we need to wait + // for the remaining async actions to finish await waitFor(() => getByText('Fresh')); }); diff --git a/src/index.js b/src/index.js index daf982bd..fa21651f 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,4 @@ +// @flow import flushMicrotasksQueue from './flushMicrotasksQueue'; import { cleanup } from './pure'; From 57a6f6c0ad55934ee4f4162e00491202dc381991 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Wed, 20 May 2020 13:16:31 +0200 Subject: [PATCH 11/14] Update website/docs/API.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Pierzchała --- website/docs/API.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/docs/API.md b/website/docs/API.md index 8a691f53..8b1caf4f 100644 --- a/website/docs/API.md +++ b/website/docs/API.md @@ -127,7 +127,9 @@ const cleanup: () => void; Unmounts React trees that were mounted with `render`. -> Please note that this is done automatically if the testing framework you're using supports the `afterEach` global (like mocha, Jest, and Jasmine). If not, you will need to do manual cleanups after each test. +:::info +Please note that this is done automatically if the testing framework you're using supports the `afterEach` global (like mocha, Jest, and Jasmine). If not, you will need to do manual cleanups after each test. +::: For example, if you're using the `jest` testing framework, then you would need to use the `afterEach` hook like so: From 8dec70486e22fc847b0a7294e87d8526c40e2471 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Wed, 20 May 2020 13:18:09 +0200 Subject: [PATCH 12/14] More changes --- website/docs/API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/API.md b/website/docs/API.md index 8b1caf4f..629fd922 100644 --- a/website/docs/API.md +++ b/website/docs/API.md @@ -134,7 +134,7 @@ Please note that this is done automatically if the testing framework you're usin For example, if you're using the `jest` testing framework, then you would need to use the `afterEach` hook like so: ```jsx -import { cleanup, render } from 'react-native-testing-library'; +import { cleanup, render } from 'react-native-testing-library/pure'; import { View } from 'react-native'; afterEach(cleanup); From 08127800b7881caa2fd2abbe95d24dc4cbb5672e Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Wed, 20 May 2020 13:20:24 +0200 Subject: [PATCH 13/14] Removed afterEach(cleanup) calls in examples --- examples/redux/components/AddTodo.test.js | 4 +--- examples/redux/components/TodoList.test.js | 4 +--- website/docs/ReactNavigation.md | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/redux/components/AddTodo.test.js b/examples/redux/components/AddTodo.test.js index c90344cf..edbbcc16 100644 --- a/examples/redux/components/AddTodo.test.js +++ b/examples/redux/components/AddTodo.test.js @@ -1,12 +1,10 @@ import React from 'react'; import { Provider } from 'react-redux'; -import { cleanup, fireEvent, render } from 'react-native-testing-library'; +import { fireEvent, render } from 'react-native-testing-library'; import configureStore from '../store'; import AddTodo from './AddTodo'; describe('Application test', () => { - afterEach(cleanup); - test('adds a new test when entry has been included', () => { const store = configureStore(); diff --git a/examples/redux/components/TodoList.test.js b/examples/redux/components/TodoList.test.js index 80b27f05..595fcea2 100644 --- a/examples/redux/components/TodoList.test.js +++ b/examples/redux/components/TodoList.test.js @@ -1,12 +1,10 @@ import React from 'react'; import { Provider } from 'react-redux'; -import { cleanup, fireEvent, render } from 'react-native-testing-library'; +import { fireEvent, render } from 'react-native-testing-library'; import configureStore from '../store'; import TodoList from './TodoList'; describe('Application test', () => { - afterEach(cleanup); - test('it should execute with a store with 4 elements', () => { const initialState = { todos: [ diff --git a/website/docs/ReactNavigation.md b/website/docs/ReactNavigation.md index 0d4ced38..bdf57418 100644 --- a/website/docs/ReactNavigation.md +++ b/website/docs/ReactNavigation.md @@ -54,7 +54,7 @@ export default function HomeScreen({ navigation }) { new Array(20).fill(null).map((_, idx) => idx + 1) ); - const onOpacityPress = item => navigation.navigate('Details', item); + const onOpacityPress = (item) => navigation.navigate('Details', item); return ( @@ -162,8 +162,6 @@ import AppNavigator from '../AppNavigator'; jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper'); describe('Testing react navigation', () => { - afterEach(cleanup); - test('page contains the header and 10 items', () => { const component = ( From 349c1f56b09664b3b86807ffc5d604b9e771e320 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Wed, 20 May 2020 13:24:05 +0200 Subject: [PATCH 14/14] Code cleanup --- examples/reactnavigation/src/__tests__/AppNavigator.test.js | 4 +--- examples/redux/reducers/todoReducer.js | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/reactnavigation/src/__tests__/AppNavigator.test.js b/examples/reactnavigation/src/__tests__/AppNavigator.test.js index b2f4a85c..f9731215 100644 --- a/examples/reactnavigation/src/__tests__/AppNavigator.test.js +++ b/examples/reactnavigation/src/__tests__/AppNavigator.test.js @@ -1,6 +1,6 @@ import React from 'react'; import { NavigationContainer } from '@react-navigation/native'; -import { render, fireEvent, cleanup } from 'react-native-testing-library'; +import { render, fireEvent } from 'react-native-testing-library'; import AppNavigator from '../AppNavigator'; @@ -8,8 +8,6 @@ import AppNavigator from '../AppNavigator'; jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper'); describe('Testing react navigation', () => { - afterEach(cleanup); - test('page contains the header and 10 items', () => { const component = ( diff --git a/examples/redux/reducers/todoReducer.js b/examples/redux/reducers/todoReducer.js index f55d4c3e..f1e20731 100644 --- a/examples/redux/reducers/todoReducer.js +++ b/examples/redux/reducers/todoReducer.js @@ -6,7 +6,6 @@ export default function todoReducer(state = [], action) { return state.concat(action.payload); case actions.REMOVE: - console.log(action); return state.filter((todo) => todo.id !== action.payload.id); case actions.MODIFY: