Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nknapp/msw-solid-testing-library-bug-reproduction
https://github.com/nknapp/msw-solid-testing-library-bug-reproduction
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nknapp/msw-solid-testing-library-bug-reproduction
- Owner: nknapp
- Created: 2024-03-16T21:32:04.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-23T20:06:21.000Z (8 months ago)
- Last Synced: 2024-10-06T03:41:38.883Z (about 1 month ago)
- Language: JavaScript
- Size: 115 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Reproduction repo for msw issue
mock-service-worker does not work with vitest and solid-js.
The reason is that `vite-plugin-solid` sets the vite config option `resolve.conditions` to `['browser']`,If it would not do that, solid-js would load the server-version of its code, providing an empty "render" function.
But because it does this, the `msw/node` package cannot be loaded in the test, because in its package.json,
it says under `exports````
"exports": {
"./node": {
"browser": null,
-----------------^
"types": "./lib/node/index.d.ts",
"require": "./lib/node/index.js",
"import": "./lib/node/index.mjs",
"default": "./lib/node/index.mjs"
}
}
```# Patching msw
This repo runs a [postinstall-script](./scripts/patch-msw-libs.mjs) that modifies the exports object like this:
```
"exports": {
"./node": {
"types": "./lib/node/index.d.ts",
"node": {
"require": "./lib/node/index.js",
"import": "./lib/node/index.mjs"
},
"browser": null,
"default": "./lib/node/index.mjs"
},
}
```and a similar change for `@mswjs/interceptors`.
With this change, `vitest` can be executed and `vite build` will fail when
trying to import `msw/node`.