From 872bd6a52809c00f82640248e188bceb467d8c03 Mon Sep 17 00:00:00 2001 From: Braden Lee <2dubbing@gmail.com> Date: Mon, 15 Jun 2020 21:51:17 +0900 Subject: [PATCH] docs: Add window.localStorage.remove('token') statement to afterEach() in __tests__/login.js file (#709) Due to the first test suite, I need to remove the token value generated from local storage. The second test suite will fail if the token value is not removed. --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 784241a3..92f9a7e1 100644 --- a/README.md +++ b/README.md @@ -101,9 +101,11 @@ should be installed as one of your project's `devDependencies`: ``` npm install --save-dev @testing-library/react ``` + or for installation via [yarn](https://classic.yarnpkg.com/en/) + ``` yarn add --dev @testing-library/react ``` @@ -283,11 +285,14 @@ import Login from '../login' const server = setupServer( rest.post('/api/login', (req, res, ctx) => { return res(ctx.json({token: 'fake_user_token'})) - }) + }), ) beforeAll(() => server.listen()) -afterEach(() => server.resetHandlers()) +afterEach(() => { + server.resetHandlers() + window.localStorage.removeItem('token') +}) afterAll(() => server.close()) test('allows the user to login successfully', async () => { @@ -318,11 +323,8 @@ test('handles server exceptions', async () => { // mock the server error response for this test suite only. server.use( rest.post('/', (req, res, ctx) => { - return res( - ctx.status(500), - ctx.json({message: 'Internal server error'}), - ) - }) + return res(ctx.status(500), ctx.json({message: 'Internal server error'})) + }), ) render() @@ -591,6 +593,7 @@ Thanks goes to these people ([emoji key][emojis]): + This project follows the [all-contributors][all-contributors] specification.