diff --git a/examples/__tests__/mock.react-transition-group.js b/examples/__tests__/mock.react-transition-group.js index f2547195..2f161a4c 100644 --- a/examples/__tests__/mock.react-transition-group.js +++ b/examples/__tests__/mock.react-transition-group.js @@ -38,7 +38,7 @@ jest.mock('react-transition-group', () => { test('you can mock things with jest.mock', () => { const {getByText, queryByText} = render() - expect(getByText('Hello World')).toBeTruthy() // we just care it exists + expect(getByText('Hello world')).toBeTruthy() // we just care it exists // hide the message Simulate.click(getByText('Toggle')) // in the real world, the CSSTransition component would take some time diff --git a/examples/__tests__/react-context.js b/examples/__tests__/react-context.js index 00d47b58..9cc8ef8f 100644 --- a/examples/__tests__/react-context.js +++ b/examples/__tests__/react-context.js @@ -9,7 +9,7 @@ import {NameContext, NameProvider, NameConsumer} from '../react-context' */ test('NameConsumer shows default value', () => { const {getByText} = render() - expect(getByText('My Name Is:')).toHaveTextContent('My Name Is: Unknown') + expect(getByText(/^My Name Is:/)).toHaveTextContent('My Name Is: Unknown') }) /** @@ -23,7 +23,7 @@ test('NameConsumer shows value from provider', () => { ) const {getByText} = render(tree) - expect(getByText('My Name Is:')).toHaveTextContent('My Name Is: C3P0') + expect(getByText(/^My Name Is:/)).toHaveTextContent('My Name Is: C3P0') }) /** @@ -39,7 +39,7 @@ test('NameProvider composes full name from first, last', () => { ) const {getByText} = render(tree) - expect(getByText('Received:').textContent).toBe('Received: Boba Fett') + expect(getByText(/^Received:/).textContent).toBe('Received: Boba Fett') }) /** @@ -52,5 +52,5 @@ test('NameProvider/Consumer shows name of character', () => { ) const {getByText} = render(tree) - expect(getByText('My Name Is:').textContent).toBe('My Name Is: Leia Organa') + expect(getByText(/^My Name Is:/).textContent).toBe('My Name Is: Leia Organa') }) diff --git a/examples/__tests__/react-router.js b/examples/__tests__/react-router.js index 2021771f..f21bb967 100644 --- a/examples/__tests__/react-router.js +++ b/examples/__tests__/react-router.js @@ -49,7 +49,7 @@ test('full app rendering/navigating', () => { // normally I'd use a data-testid, but just wanted to show this is also possible expect(container.innerHTML).toMatch('You are home') const leftClick = {button: 0} - Simulate.click(getByText('about'), leftClick) + Simulate.click(getByText(/about/i), leftClick) // normally I'd use a data-testid, but just wanted to show this is also possible expect(container.innerHTML).toMatch('You are on the about page') }) diff --git a/examples/__tests__/shallow.react-transition-group.js b/examples/__tests__/shallow.react-transition-group.js index b922a30b..3124ef37 100644 --- a/examples/__tests__/shallow.react-transition-group.js +++ b/examples/__tests__/shallow.react-transition-group.js @@ -41,7 +41,7 @@ test('you can mock things with jest.mock', () => { {in: true, ...defaultProps}, context, ) - Simulate.click(getByText('toggle')) + Simulate.click(getByText(/toggle/i)) expect(CSSTransition).toHaveBeenCalledWith( {in: true, ...defaultProps}, expect.any(Object), diff --git a/src/__tests__/forms.js b/src/__tests__/forms.js index a0a3ed06..4371f005 100644 --- a/src/__tests__/forms.js +++ b/src/__tests__/forms.js @@ -36,10 +36,10 @@ test('login form submits', () => { , ) - const usernameNode = getByLabelText('username') - const passwordNode = getByLabelText('password') + const usernameNode = getByLabelText(/username/i) + const passwordNode = getByLabelText(/password/i) const formNode = container.querySelector('form') - const submitButtonNode = getByText('submit') + const submitButtonNode = getByText(/submit/i) // Act usernameNode.value = fakeUser.username diff --git a/src/__tests__/stopwatch.js b/src/__tests__/stopwatch.js index 2e6dbf57..1dab173a 100644 --- a/src/__tests__/stopwatch.js +++ b/src/__tests__/stopwatch.js @@ -42,7 +42,7 @@ const wait = time => new Promise(resolve => setTimeout(resolve, time)) test('unmounts a component', async () => { jest.spyOn(console, 'error').mockImplementation(() => {}) const {unmount, getByText, container} = render() - Simulate.click(getByText('start')) + Simulate.click(getByText('Start')) unmount() // hey there reader! You don't need to have an assertion like this one // this is just me making sure that the unmount function works.