-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
1,572 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { cleanup, fireEvent, render } from '@testing-library/react'; | ||
import App from './App'; | ||
import { Cookies } from 'react-cookie'; | ||
|
||
afterEach(cleanup); | ||
|
||
test('Changing the name change the cookie value', () => { | ||
const cookies = new Cookies(); | ||
const utils = render(<App />); | ||
const input = utils.getByPlaceholderText('Enter your name'); | ||
fireEvent.change(input, { target: { value: 'Ben Solo' } }); | ||
expect(input.value).toBe('Ben Solo'); | ||
expect(cookies.get('name')).toBe('Ben Solo'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Just a thought... I would recommend adding something in the documentation about how this lib now deals with the JSDom environment. After updating to v4.0.3 I ran in to an issue with some tests failing (used server-side)... and after a lot of digging through this lib code changes (for what I thought would be a regression) I came across this commit.
The net is that anyone using the lib server-side and using Jest for unit tests will run in to false-failures unless they set explicitly set
@jest-environment node
in their tests (which I suspect a lot of people do not do)