Questions tagged [miragejs]

50 questions
2
votes
1 answer

mirage.js will not work with sub url paths (only with root path) in angular

Mirage does match defined routes when the backend calls are performed through the root url (localhost:4200/), but when we perform a backend call on a sub page, e.a.: localhost:4200/process, it will not work. When debugging the mirage code it will…
edbras
  • 4,145
  • 9
  • 41
  • 78
2
votes
0 answers

Detox with Mirage.js [Mock API Call] React-Native

I'm working on some tests using Detox for my React-Native application, one of those test is a flow where I need to check that the user's session is secured. If not, I'm sending an SMS Verification Code. Test : Success to mock the POST API Call…
Mayoul
  • 626
  • 10
  • 24
2
votes
1 answer

Is there a way to show related model ids without sideloading or embedding data

My understanding is that using serializeIds: 'always' will give me this data, but it does not. Here's what I'm expecting: { id="1" title="some title" customerId="2" } Instead the output I'm receiving is: { id="1" title="some title" } My…
1
vote
0 answers

Is it possible to see the response of a API call from Mirage JS in browser without calling it from code?

Here is the server creation : import { createServer } from "miragejs" export default function () { createServer({ routes() { this.get("/api/reminders", () => ({ reminders: [ { id: 1, text: "Walk the dog" }, …
Sultan
  • 72
  • 8
1
vote
2 answers

Mirage/Pretender causes errors in Vitest

I'm working on migrating from Jest to Vitest (alongside CRA > Vite migration), and I think I've got everything working, except that using Mirage causes errors. Setting the vite config test environment between happy-dom and 'jsdom' both give…
Jonathan Tuzman
  • 11,568
  • 18
  • 69
  • 129
1
vote
1 answer

MirageJS Error response not causing an error

Following the docs I've set up this handler inside routes(): this.put( '/admin/features/error/environment/test', // @ts-ignore () => new Response(500, {}, { errors: ['The database went on vacation'] }), ); Mirage does receive what I've set,…
Jonathan Tuzman
  • 11,568
  • 18
  • 69
  • 129
1
vote
0 answers

Redux Toolkit RTK fetchBasedQuery.prepareHeaders not working on the first call

I have this apiSlice: export const apiSlice = createApi({ baseQuery: fetchBaseQuery({ baseUrl: `${baseUrl}${apiBasePath}`, prepareHeaders: prepHeaders, }), endpoints: (builder) => ({ getPersonById: builder.query({ query:…
Carlos Jaime C. De Leon
  • 2,476
  • 2
  • 37
  • 53
1
vote
1 answer

How to handle FormData in Miragejs?

Miragejs handles json out-of-the-box but seems to be unable to handle FormData. When I post FormData and log the received request in mirage endpoint, request.requestBody is empty. Simplified code examples: POSTing FormData: const testFile = new…
Juuso Ohtonen
  • 8,826
  • 9
  • 65
  • 98
1
vote
1 answer

How to expand a single cell of a table to show additional JSON data in React

On my app I have a table that lists the names of employees, and I am currently able to click an "EXPAND ALL" button to display additional info for every employee at once. I am trying to implement a button that will expand and show that same info,…
Casey MacLeod
  • 31
  • 1
  • 6
1
vote
1 answer

How to change id field in miragejs db

I am wondering how I could change the default, generated id column for a mirage db from 'id' to something like 'userId' as my front end expects. Thanks!
nolanxiii
  • 41
  • 4
1
vote
0 answers

Mirage JS add pagination data to response

I have a problem with mocking backend by mirage JS. How to add pagination data to response after creatList? My server js returns JSON https://miragejs.com/repl/v2/6563736c78 { "users": [ { "title": "test title", "id": "1" }, …
Petro
  • 21
  • 1
1
vote
0 answers

How should I embed 2 models with a many-to-many relationship?

I have two models with a many-to-many relationship: Blog Tag So each blog has a tags property, and each tag has a blogs property. I also have two API endpoints: /blogs and /tags My problem is, if I include and embed the models in the serializer, I…
KDani
  • 358
  • 4
  • 19
1
vote
1 answer

How can I embed child data with many-to-many relationships?

I have two Models in MirageJs: blog tag Each blog could have more tags and vice versa. I made a many-to-many relationship with a join table called blog_tag. My problem is, when I get the response from the server, the tags only contains the id…
KDani
  • 358
  • 4
  • 19
1
vote
0 answers

MirageJS not persisting POST created data

I'm building this VueJS app with MirageJS to mock an API and I came up with this issue. I have a /users endpoint where it handles GET and POST requests. If data is created by a factory, it returns this data. If data is created by a POST request, in…
Gabriel Silva
  • 69
  • 1
  • 9
0
votes
0 answers

Getting 404s when trying to mock with mirageJs in a NextJs with App Router

My issue here most likely happens since I am not instantiating the mock server in the correct place in my app. The mirageJs docs are still catered to the old 'pages router', where it says: Open your Next.js app's initialization file…