Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App test snapshot is redundant #59

Open
readysetagile opened this issue Aug 8, 2023 · 3 comments
Open

App test snapshot is redundant #59

readysetagile opened this issue Aug 8, 2023 · 3 comments
Labels
refactoring this is a refactoring issue. usually does not have a user story since functionality does not change

Comments

@readysetagile
Copy link
Collaborator

App.test.js.snap is redundant since we have tests for each component. It is unnecessary for test snapshots to be updated in multiple places when components are modified

We will need to refactor App.test.js to eliminate the need for App.test.js.snap

App.test.js is still needed to test the order of the components on the page

@readysetagile readysetagile changed the title [App test snapshot](src/test/__snapshots__/App.test.js.snap) is redundant App test snapshot is redundant Aug 8, 2023
@readysetagile readysetagile moved this to Ready for development in FreeCodeCamp Columbus Website Aug 8, 2023
@readysetagile readysetagile added the refactoring this is a refactoring issue. usually does not have a user story since functionality does not change label Aug 8, 2023
@jduffey
Copy link
Collaborator

jduffey commented Aug 8, 2023

The App snapshot verifies that the App component is in fact rendering what we want it to render. If for example we were to comment out the invocation of the Splash component in the App.js file, then when App is rendered it would no longer display the Splash component even though nothing has been modified in the Splash component itself and the Splash snapshot is not failing. In other words, unless we have a snapshot test telling us that App isn't rendering how we want it to, there's no indication that something is "wrong" other than a person manually looking at the page.

What types of tests are you anticipating writing for App? It contains no logic or branch conditions and is really just a file that organizes the order in which the components should be rendered -- basically exactly what a snapshot test is for.

This is just my quick take so let me know if I'm overlooking something!

Okay... so I've never done much React testing beyond the basic snapshot tests, and I'm now reading up on a concept called "shallow rendering", where basically it verifies that child components are called but doesn't bother to actually render them. Today I Learned™️

I'll look into how to implement this hopefully by the weekend or so. Always happy to dig into a new skill!

@readysetagile
Copy link
Collaborator Author

"shallow rendering"

would it be possible with just a few jest.mock() calls in the proper order? see part 4

@readysetagile
Copy link
Collaborator Author

"shallow rendering"

would it be possible with just a few jest.mock() calls in the proper order? see part 4

I think this StackOverflow answer describes what I was thinking...

@mmcbride2929 mmcbride2929 moved this from Ready for development to Code Review in FreeCodeCamp Columbus Website Aug 17, 2023
@mmcbride2929 mmcbride2929 self-assigned this Aug 17, 2023
@mmcbride2929 mmcbride2929 moved this from Code Review to Ready for Deployment in FreeCodeCamp Columbus Website Aug 28, 2023
@readysetagile readysetagile moved this from Ready for Deployment to Done! in FreeCodeCamp Columbus Website Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring this is a refactoring issue. usually does not have a user story since functionality does not change
Projects
Development

No branches or pull requests

3 participants