Installing/Uninstalling like the README states doesn't mock requests properly

This issue has been tracked since 2017-01-29.

I've tried to follow the documentation but for some reason can't get this ti work properly. If relevant, I'm using TypeScript, React and Jest with Enzyme.

I have something like this on my app:

public componentWillMount(): void {
        .then((response) => {
        .catch((error) => {

And this is my simple test spec:

import * as React from "react";
import * as Moxios from "moxios";

import { shallow } from "enzyme";

import Application from "components/Application";

describe("Application", () => {

    beforeEach(() => {

    describe("#render", () => {

        test("application renders correctly", () => {
            Moxios.stubRequest("https://hostname/token", {
                status: 200,
                responseText: {}

            expect(shallow(<Application />)).toMatchSnapshot();


    afterEach(() => {


I should be getting output from the console.log(response); but I don't. I can only get this working if I remove the Moxios.uninstall() line from afterEach. I've also tried other variations like beforeAll / afterAll but to no avail.

For now, since I can't call Moxios.uninstall() on my tests, I've just removed beforeEach / afterEach completely and I'm calling Moxios.install() inside the first describe. But this doesn't fell right.

What might I be doing wrong?

What am I doing wrong?

vidhill wrote this answer on 2017-03-28

Experiencing similar issue..

However, I'm running uninstall in a before() and after() not afterEach

More Details About Repo
Owner Name axios
Repo Name moxios
Full Name axios/moxios
Language JavaScript
Created Date 2016-05-25
Updated Date 2022-12-05
Star Count 1386
Watcher Count 20
Fork Count 85
Issue Count 19


Issue Title Created Date Updated Date