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

docs: extend testing documentation #2445

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,45 @@ Run `yarn lint --fix` to fix any automatically fixable lint issues and report th

## Running tests

To run unit tests, run `yarn test`.
To run unit tests, run `yarn test`. This will run the full test suite with client side rendering
and server side rendering with and without hydration.
During development it is preferable to run `yarn test:csr`, which will just run the client side
rendering.

### Debugging with Visual Studio Code

It is possible to debug tests and/or run them in isolation with Visual Studio Code.
The following code snippet can be placed in `.vscode/launch.json`.
Replace `test:csr` with either `test:ssr:hydrated` or `test:ssr:non-hydrated` to test SSR.
kyubisation marked this conversation as resolved.
Show resolved Hide resolved
Add the `--debug` param to enable breakpoint debugging and the detailed test report.

```json
...
{
"name": "Test",
"request": "launch",
"runtimeArgs": ["test:csr", "${relativeFile}", "--watch"],
kyubisation marked this conversation as resolved.
Show resolved Hide resolved
"runtimeExecutable": "yarn",
"skipFiles": ["<node_internals>/**"],
"type": "node",
"console": "integratedTerminal"
},
...
kyubisation marked this conversation as resolved.
Show resolved Hide resolved
```

### Debugging with IntelliJ

It is possible to debug tests and/or run them in isolation also with Intellij IDEA.
From the title bar, open the 'Run' menu, then select 'Edit configuration'.
Create and save a new `npm` configuration with the following parameters,
possibly replacing `test:csr` with either `test:ssr:hydrated` or `test:ssr:non-hydrated` to test SSR:

- Command: `run`
- Scripts: `test:csr`
- Arguments: `**/$FileName$ --watch`

Finally, open the file you want to test and run the script.
Add the `--debug` param to enable breakpoint debugging and the detailed test report.

## Starting showcase

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"start": "storybook dev -p 6006",
"test": "wtr --coverage",
"test:snapshot": "yarn test --ci --update-snapshots",
"test:csr": "wtr --group default",
"test:ssr:hydrated": "wtr --group e2e-ssr-hydrated",
"test:ssr:non-hydrated": "wtr --group e2e-ssr-non-hydrated",
"prepare": "husky install"
Expand Down
Loading