Comments (7)
Thanks @cah-brian-gantzler, I guess I'm confused? The docs have info on Jest and unit testing which I assumed meant it would work in JSDom?
from miragejs.
I am experiencing the same issue, and my JSDOM version is v20.0.3.
My application was set up a year ago and hasn't been touched, except for the miragejs version being updated by the bot.
from miragejs.
@cah-brian-gantzler sorry for the delay in responding, the tutorial walks through using it with Jest: https://miragejs.com/tutorial/part-9/
I do see where it says it is already setup for Jest, although Jest isnt really mentioned til the last tutorial. Looking in the package.json I did not see where the tutorial was actually using jest as its test runner. It was using Craco
"scripts": {
"start": "craco start",
"start:final": "REACT_APP_DEMO=true yarn start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
Looking at Craco it seems to be something specific to react, so not sure if you could use it in your application. Given that react is also a web application, craco must be doing something to make Jest run in the web instead of node. You may need to research Craco more to see what it is actually doing to allow Jest to run the way you would like it to.
Im sorry I dont have any react experience. The only time I have ever used Jest is the mirage tests, but that was established before I started using the MirageJS library. I know how to run them 😄 , but not completely knowledgable in how they actually work or are configured.
from miragejs.
Pretender does not work in node. This makes mirageJS (when using pretender) only available to run in a browser.
You can use try to use mirage-msw
. This is experimental at this time. Pretender will still be included in your builds, as it has not yet been removed from miragejs and made an optional dependency.
If you would like to user mirage-msw
add it to your package.json, then in your server import and add the following (talked about in this issue #1013). Would be interested in any feedback to eventually get this to be part of MirageJS proper.
import { Server } from 'miragejs';
import MswInterceptor from 'mirage-msw';
new Server({
// your config options
interceptor: new MswInterceptor(),
});
from miragejs.
If you read the comparison page is does say that MirageJS only works in the browser. Could you tell me where in the docs it talks about Jest?
The tests for this package does use jest, and Im wondering if that is what you are seeing. The unit tests are testing this package, not using this package in another application. All those tests are running in the browser.
from miragejs.
@cah-brian-gantzler sorry for the delay in responding, the tutorial walks through using it with Jest:
https://miragejs.com/tutorial/part-9/
from miragejs.
@snaptopixel Are you using jsdom, if so, what version?
from miragejs.
Related Issues (20)
- passthrough not really working as expected HOT 9
- 0.1.46 breaks embedded records without `serializeIds: false` HOT 1
- Example using GraphQL and React Native for Testing HOT 2
- How to fix it? my error is: Mirage: Passthrough request for GET /_next/static/development/_devMiddlewareManifest.json
- `timing` setting does not respect `environment: 'test'` without setting `testConfig` HOT 2
- Seeding doesn't load factories HOT 1
- `Response` object is using deprecated `@ember/error` HOT 1
- Can some updates be made so all config elements can be modularized in all environments including development?
- Issues running inside a webpack based NX monorepo React app HOT 3
- `Serializer.normalize()` not called if request body is `FormData`
- How do you include relationships when mixing the JSON API and Rest serializers? HOT 3
- Has anyone managed to get mirage to work with Next.js 13.4? HOT 8
- Argument of type '{ name: string; role: string[]; }' is not assignable to parameter of type 'Partial<ModelInitializ HOT 1
- Change default request handling
- Allow timing to be boolean, default to 'false' due to Pretender handling HOT 6
- Doesn't work with vue3 + fetch + passthrough HOT 2
- Next-pwa throws Failed to execute 'put' on 'Cache': parameter 2 is not of type 'Response' with simple Miraje configuration
- Mirage.js Endpoints Not Found After Navigating and Reloading in Lazy-Loaded Angular App HOT 1
- New Docs Proposal HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miragejs.