App.test "renders learn react link" fails
Describe the bug Using the main branch, App.test.js fails with the following message.
Also, the test name, "renders learn react link," no longer matches what the test actually asserts (that the screen contains the string "Shell".)
FAIL src/App.test.js
✕ renders learn react link (63 ms)
● renders learn react link
TypeError: Cannot read properties of undefined (reading 'matches')
13 | return savedTheme;
14 | }
> 15 | return window.matchMedia("(prefers-color-scheme: dark)").matches
| ^
16 | ? dark
17 | : light;
18 | };
To Reproduce
Run npm run test and type a when prompted.
Possible Solution Choose what you actually want to test. If only testing that the App page is displaying, assert the presence of text that isn't buried within a dropdown. If testing the contents of the dropdown, the test may need to click on the language dropdown for the string "Shell" to be displayed.
@version0chiro , I'd be willing to work on this ticket. However, there have been other people in this Issues list volunteering to work on tests.
Hi, I’d like to work on this . Please assign it to me. Thanks!
I like to work on this issue . PLease assign it to me if it exists ..
Hello! I’m interested in contributing to this feature. If this issue is not currently being worked on, I would be happy to help implement it. Please let me know if I can take it.
In src/Context/themeContext.js, prevent crashes by adding a null check: const matchMedia = window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null; return matchMedia && matchMedia.matches ? dark : light;
In src/App.test.js, rename the test to 'renders App component successfully' and assert on an element that actually exists: const linkElement = screen.getByPlaceholderText(/Search/i);
/assign