Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
dedicated browser export
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Jan 19, 2020
1 parent dd32cd0 commit 82f3664
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion __tests__/jest-built-ins.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*global jest, beforeAll, afterAll */
jest.mock('node-fetch', () => require('../fetch-mock-jest').sandbox());
jest.mock('node-fetch', () => require('../server').sandbox());
const fetch = require('node-fetch');
describe('jest built-ins', () => {
describe('exposing mock internals', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/jest-extensions.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*global jest, beforeAll, afterAll */
jest.mock('node-fetch', () => require('../fetch-mock-jest').sandbox());
jest.mock('node-fetch', () => require('../server').sandbox());
const fetch = require('node-fetch');
describe('jest extensions', () => {
describe('toHaveFetched', () => {
Expand Down
4 changes: 4 additions & 0 deletions browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const fetchMock = require('fetch-mock/cjs/client.js');
const jestify = require('./jestify')

module.exports = jestify(fetchMock);
3 changes: 1 addition & 2 deletions fetch-mock-jest.js → jestify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*global jest*/
require('./jest-extensions');

const fetchMock = require('fetch-mock');
const jestify = fetchMockInstance => {
const jestifiedInstance = new Proxy(fetchMockInstance, {
get: (originalFetchMock, name) => {
Expand Down Expand Up @@ -98,4 +97,4 @@ const jestify = fetchMockInstance => {
return jestifiedInstance;
};

module.exports = jestify(fetchMock);
module.exports = fetchMock => jestify(fetchMock);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "fetch-mock-jest",
"version": "0.0.0",
"description": "Jest wrapper for fetch-mock, a comprehensive stub for fetch",
"main": "fetch-mock-jest.js",
"main": "server.js",
"browser": "browser.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
4 changes: 4 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const fetchMock = require('fetch-mock');
const jestify = require('./jestify')

module.exports = jestify(fetchMock);

0 comments on commit 82f3664

Please sign in to comment.