Skip to content

node-XMLHttpRequest + axios + MockRequests: Cannot read property 'headers' of undefined #190

Open
@d9k

Description

@d9k

D-Pow/mock-requests#15

global.fetch = require('node-fetch');
global.Headers = fetch.Headers;
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
MR = require('mock-requests');
global.axios = require('axios');

MR.setMockUrlResponse('http://localhost:1111/t', {
  mockExample: 1
});

axios.get('http://localhost:1111/t').then(resp => console.log(resp));
// Error "Cannot read property 'headers' of undefined"
// at exports.XMLHttpRequest.getAllResponseHeaders at node_modules/xmlhttprequest/lib/XMLHttpRequest.js:239`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions