I found that react-router.js test is broken with latest version of history (currently @ 5.0.0):
$ yarn upgrade history@latest
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ history@5.0.0
info All dependencies
└─ history@5.0.0
✨ Done in 33.73s.
$ yarn test
$ jest
PASS sandbox src/__tests__/react-redux.js (6.666s)
PASS sandbox src/__tests__/portals.js (6.842s)
FAIL sandbox src/__tests__/react-router.js (6.952s)
● full app rendering/navigating
expect(received).toMatch(expected)
Expected substring: "You are on the about page"
Received string: "<div><a href=\"/\">Home</a><a href=\"/about\">About</a><div>No match</div><div data-testid=\"location-display\"></div></div>"
52 | fireEvent.click(screen.getByText(/about/i), leftClick)
53 | // normally I'd use a data-testid, but just wanted to show this is also possible
> 54 | expect(container.innerHTML).toMatch('You are on the about page')
| ^
55 | })
56 |
57 | test('landing on a bad page', () => {
at Object.<anonymous> (../src/__tests__/react-router.js:54:31)
PASS local src/__local_tests__/mock.react-router.js
PASS local src/__local_tests__/async-with-mock.js
PASS local src/__local_tests__/component-did-catch.js
PASS sandbox src/__tests__/i18next.js
PASS sandbox src/__tests__/async.js
PASS sandbox src/__tests__/on-change.js
PASS local src/__local_tests__/shallow.react-transition-group.js
PASS local src/__local_tests__/mock.react-transition-group.js
PASS sandbox src/__tests__/window-resize.js
PASS sandbox src/__tests__/react-lazy-and-suspense.js
PASS sandbox src/__tests__/upload-file.js
PASS sandbox src/__tests__/update-props.js
PASS sandbox src/__tests__/react-context.js
Test Suites: 1 failed, 1 skipped, 15 passed, 16 of 17 total
Tests: 1 failed, 1 skipped, 25 passed, 27 total
Snapshots: 0 total
Time: 19.537s
Ran all test suites in 2 projects.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I found that
react-router.js
test is broken with latest version ofhistory
(currently @5.0.0
):