Skip to content

Instantly share code, notes, and snippets.

@alessbell
Last active April 17, 2019 21:52
Show Gist options
  • Save alessbell/5808249820338a67eabba79a15f9cea1 to your computer and use it in GitHub Desktop.
Save alessbell/5808249820338a67eabba79a15f9cea1 to your computer and use it in GitHub Desktop.

React Testing Library notes

Queries

Assertions and custom matchers

Appearance and disappearance 👻

Firing events

Developer workflow

  • While developing, run npm run test -- -f ${componentName} --watch
    • Tests re-run on save = instant feedback
  • When we want to view more in-depth coverage reports, run npm run test (need to overwrite partial coverage that's generated when watching a single file)
    • .artifacts > coverage > lcov-report > index.html > right click file > "View in Finder" > drag file to open browser window That will give you a view like this: If you click into an individual component like Button > index.js, you can see exactly which branches are being tested
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment