Questions tagged [miragejs]
50 questions
9
votes
2 answers
MirageJs: cannot use axios if I call api with passthrough
I have an app in react with a slice and a thunk.
I use @reduxjs/toolkit and I created slice with "createSlice" api and thunk with "createAsyncThunk".
My thunk:
export const loginThunk = createAsyncThunk('login/local', async (loginData: LoginData) =>…

foralobo
- 3,947
- 5
- 18
- 17
4
votes
2 answers
Using the LocalStorage API to persist the Miragejs db
While reading the docs for miragejs, on this page, it says:
Mirage resets its state on every browser reload, which can be a double-edged sword but is often what you want for development and testing. (You can use localStorage if you'd like to add…

Anthony
- 47
- 1
- 5
4
votes
3 answers
Convert all MirageJS ids to integers
MirageJS provides all model ids as strings. Our backend uses integers, which are convenient for sorting and so on. After reading around MirageJS does not support integer IDs out of the box. From the conversations I've read the best solution would be…

Francois Carstens
- 477
- 3
- 13
3
votes
0 answers
Typescript error on afterCreate in miragejs
I have the following code for my factory, omitting some properties for brevity.
export const propsPlayerDetailFactory = Factory.extend({
sportId: () => getFakeSportId(),
playerId: i => `${i}`,
playerName: () => faker.name.findName(),
…

Jonathan Tuzman
- 11,568
- 18
- 69
- 129
3
votes
0 answers
Add meta data to ember js mirage data
I am working in an ember-cli project which has Mirage already set up for testing. It may be an older version, miragejs: ^0.1.44 and ember-cli-mirage: ^2.4.0
I have added a feature that relies on data in the meta object, and now all the affected…

UXCODA
- 1,118
- 2
- 18
- 33
3
votes
1 answer
How make request to MirajeJS js only when I need it
I have a fake server created with mirajeJs. All my requests are trying to contact him, how can I make a request for mirajeJs only in cases when I need it while making the rest of the requests to the real server

ask_question_alex alex
- 65
- 1
- 7
3
votes
1 answer
Miragejs: Unable to load the ionic icons - data:image/svg+xml
Getting below error in the browser console and the icons are not getting rendered.
Object { description: "Mirage: undefined", fileName: "http://localhost:8100/js/chunk-vendors.js line 2021 > eval", lineNumber: 806,
message: "Mirage: Your app tried…

Shyam
- 31
- 1
3
votes
1 answer
Miragejs seeds function not called
I'm trying to set-up a miragejs server, but for some reason, the seeds function is not called. The other server function, routes, is called and the routes are mapped correctly.
export default function makeServer({ environment = 'test' } = {}) {
…

mccuna
- 471
- 7
- 11
2
votes
0 answers
MirageJS - How Do You Add "blob://http://localhost" To Whitelist / Passthrough?
I have functionality that takes a local base64 URL for an image and converts it to actual base64 data. To do this, I have to call fetch(), followed by an initialization of new FileReader().
When the browser tries to fetch the local base64 URL (ie.…

Lloyd Banks
- 35,740
- 58
- 156
- 248
2
votes
0 answers
MirageJS - Whitelist / Pass Through All XHR Endpoints By Default
Out of the box, you have to specifically tell MirageJS which endpoints to mock out and which endpoints to pass through. If your app calls an endpoint that isn't targeted in Mirage's createServer() function, MirageJS will throw an error.
Is there a…

Lloyd Banks
- 35,740
- 58
- 156
- 248
2
votes
0 answers
Using MirageJS with NextJS API route
I want to call an external API from the api folder from Next.js. I want to call it on server side because the client should not see what URL is called. In the dev environment I use a Mirage server to mock the external API.
Is it possible to catch…

Simon
- 51
- 3
2
votes
1 answer
How to intentionally make all Mirage JS request return 500?
Trying to make MULTIPLE mocked service response 500 for testing any suggestions?

adB
- 41
- 4
2
votes
0 answers
Mocking APIs in End to End Testing with Detox and React-Native
Has anyone been able to mock APIs in React-Native when doing end to end testing with Detox.
I tried using MirageJs. I am able to mock the APIs after creating a server with MirageJs and initializing it on App.js. The request is successfully mocked…

Mike Ng
- 21
- 2
2
votes
1 answer
mirage.js multiple wildcard passthrough
Background
We are using miragejs to mock server apis.
Our server / backend, follows microservice architecture, and each microservice is versioned separately, and as a result and our api paths have
{base_version} - server / release version, changes…

Swapnil Luktuke
- 10,385
- 2
- 35
- 58
2
votes
2 answers
How to seed models with polymorphic one to one relationship in mirage js?
this is just an example, I understand that you would normally have multiple comments, but for the sake of this example, lets assume that we have
following models:
models: {
blogPost: Model.extend({
comment: belongsTo(),
}),
…

J Doe
- 132
- 7