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

Add jest for javascript testing #2138

Open
wants to merge 14 commits into
base: legacy
Choose a base branch
from

Conversation

jaltekruse
Copy link
Contributor

@jaltekruse jaltekruse commented May 16, 2023

  • Jest is a framework for writing javascript unit tests
  • This adds jest as well as the react-testing-library, which allows rendering react components, interacting with and inspecting parts of the render tree. These tests can run faster than cypress tests as they don't communicate with the PHP server, and they also don't require a full browser, they render into a lightweight virtual DOM.
  • To run tests, inside the devcontainer run: npx jest
  • To debug an individual test, this PR also adds a VSCode Jest extension that allows you to run and debug individual tests
  • This includes a sample test that can mock data coming from the server and it renders a component that is embedded as a child route and expects some outletContext data as input

… together

- current error - TypeError: Cannot read properties of undefined (reading 'subscribe')
- I forgot to stage the right file last commit, so I didn't save my in-progress state, but I did end up copying it to start with the simpler version and fix it
- was a minor fix to get the code to run from a unit test, will
  worry about this later when I finish that test and fix the bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant