You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-29Lines changed: 6 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ If you using Jest we recommend using [solid-jest](https://github.com/solidjs/sol
56
56
57
57
## Integration with Vite
58
58
59
-
A working Vite template setup with `solid-testing-library` and TypeScript support can be found [here](https://github.com/solidjs/solid-start/tree/main/examples/with-vitest).
59
+
A working Vite template setup with `solid-testing-library` and TypeScript support can be found [for classic solid](https://github.com/solidjs/templates/tree/main/ts-vitest) and [for solid-start](https://github.com/solidjs/solid-start/tree/main/examples/with-vitest).
60
60
61
61
62
62
## Docs
@@ -98,7 +98,7 @@ it('uses params', async () => {
98
98
99
99
It uses `@solidjs/router`, so if you want to use a different router, you should consider the `wrapper` option instead. If you attempt to use this without having the package installed, you will receive an error message.
100
100
101
-
⚠️ Solid.js external reactive state does not require any DOM elements to run in, so our `renderHook` call has no `container`, `baseElement` or queries in its options or return value. Instead, it has an `owner` to be used with [`runWithOwner`](https://www.solidjs.com/docs/latest/api#runwithowner) if required. It also exposes a `cleanup` function, though this is already automatically called after the test is finished.
101
+
⚠️ Solid.js external reactive state does not require any DOM elements to run in, so our `renderHook` call to test hooks in the context of a component (if your hook does not require the context of a component, `createRoot` should suffice to test the reactive behavior; for convenience, we also have `createEffect`, which is described later) has no `container`, `baseElement` or queries in its options or return value. Instead, it has an `owner` to be used with [`runWithOwner`](https://www.solidjs.com/docs/latest/api#runwithowner) if required. It also exposes a `cleanup` function, though this is already automatically called after the test is finished.
102
102
103
103
```ts
104
104
function renderHook<Argsextendsany[], Result>(
@@ -181,45 +181,22 @@ It allows running the effect inside a defined owner that is received as an optio
181
181
182
182
## Issues
183
183
184
-
If you find any issues, please [check on the issues page](https://github.com/solidjs/solid-testing-library/issues) if they are already known. If not, opening an issue will be much appreciated, even more so if it contains a
184
+
If you find any issues*with this library*, please [check on the issues page](https://github.com/solidjs/solid-testing-library/issues) if they are already known. If not, opening an issue will be much appreciated, even more so if it contains a
185
185
186
186
- short description
187
187
- minimal reproduction code
188
188
- list of possible workarounds, if there are any
189
189
190
190
If you think you can fix an issue yourself, feel free to [open a pull-request](https://github.com/solidjs/solid-testing-library/pulls). If functionality changes, please don't forget to add or adapt tests.
191
191
192
+
Please keep in mind that not all issues related to testing Solid.js code are directly related to this library. In some cases, the culprit might be [Solid's vite plugin](https://github.com/solidjs/vite-plugin-solid) or [Vitest](https://github.com/vitest-dev/vitest) instead. Posting the issue to the correct project will speed up fixing it; if in doubt, you can ask [on our discord](https://discord.com/invite/solidjs).
193
+
192
194
193
195
### Known issues
194
196
195
197
If you are using [`vitest`](https://vitest.dev/), then tests might fail, because the packages `solid-js`, and `@solidjs/router` (if used) need to be loaded only once, and they could be loaded both through the internal `vite` server and through node. Typical bugs that happen because of this is that dispose is supposedly undefined, or the router could not be loaded.
196
198
197
-
There are three ways you could attempt to work around this problem. If they work depends on your version of `vitest`, which version of `node-js` and what package manager you use (some of them change the way node resolves modules):
198
-
199
-
```ts
200
-
// this is inside your vite(st) config:
201
-
{
202
-
test: {
203
-
deps: {
204
-
// 1nd way: remove the @solidjs/router part if you do not use it:
At the moment of writing this, the 1st way seems to be the most reliable for the default solid template. Solid-start's vite plugin might need a different configuration.
222
-
199
+
Since version 2.8.2, our vite plugin has gained the capability to configure everything for testing, so you should only need extra configuration for globals, coverage, etc.
0 commit comments