Questions tagged [pretender.js]

pretender.js is a mock server library.

Pretender is a mock server library in the style of Sinon (but built from microlibs. Because JavaScript) that comes with an express/sinatra style syntax for defining routes and their handlers.

Pretender will temporarily replace the native XMLHttpRequest object, intercept all requests, and direct them to little pretend service you've defined.

Github Link: https://github.com/pretenderjs/pretender

8 questions
4
votes
0 answers

Pretender intercepted GET ... but no handler was defined for this type of request for an external request

I use Stripe in an Ember app. Stripe makes request to this address : https://checkout.stripe.com/api/outer/manhattan?key=... In my acceptance test, I have this message : Pretender intercepted GET…
Dougui
  • 7,142
  • 7
  • 52
  • 87
3
votes
1 answer

Is it possible to intercept a non-ajax request in browser?

Is it possible to intercept HTTP requests in browser with JavaScript which aren't done through XMLHttpRequest object (ajax)? I'm mocking an API server with ember-cli-mirage, which is using pretender. I need to add file upload (images) to the app.…
jelhan
  • 6,149
  • 1
  • 19
  • 35
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

ember-cli-mirage error: Nothing returned by handler, but handler exists

In the app I'm working with, we have a GET route that validates a user's email address. If the email is invalid, the server responds with: a 200 status code response headers with Content-Type:application/json; charset=utf-8 and the response data…
Tom Netzband
  • 1,110
  • 1
  • 6
  • 13
1
vote
1 answer

How to pass through `ember-cli-mirage` request to a specific API and Host

I am trying to use passthrough feature of ember-cli-mirage to allow my app to request to different API and Host. export default function() { //window.server = this; //this.namespace = 'api'; this.passthrough('locales/en/translation.json'); …
amesh
  • 1,311
  • 3
  • 21
  • 51
1
vote
0 answers

passthru real request with pretender.js

I am trying to pass through to a real webservice in an acceptance test in my project. Pretender intercepts all xhr request so i'm trying to tell it to pass through for example.com according to the docs i should be able to do this. var server = new…
David Chan
  • 7,347
  • 1
  • 28
  • 49
0
votes
0 answers

Qunit serializer test is returning “Cannot read property ‘push’ of null”

Ember serializer test below is failing with “Cannot read property ‘push’ of null”. I am using Pretender mock server library. The test is failing when I'm calling a store.findRecord() Note how there are no relationships in the assignment…
0
votes
2 answers

ember-cli-mirage in legacy app

We have application that used Pretender to provide fixtures for tests. Now we're trying to migrate to ember-cli-mirage. We cannot migrate all the fixtures at once. So what is basically happening there is that we are starting our own Pretender server…
Michal Bryxí
  • 1,166
  • 1
  • 11
  • 18