From 28bb93734c94a91571257c85b37af39869f8e300 Mon Sep 17 00:00:00 2001 From: Rhys Evans Date: Sun, 8 Nov 2015 20:07:07 +0000 Subject: [PATCH] throw helpful error to diagnose broken builds --- README.md | 1 + karma.conf.js | 2 +- package.json | 2 +- src/client.js | 4 ++++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b831e5cc..624cc4f2 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Mock http requests made using fetch (or [isomorphic-fetch](https://www.npmjs.com - Browser tests: `require('fetch-mock)` - Server side tests running in nodejs 4 or higher: `require('fetch-mock/server')` - Server side tests running in nodejs 0.12 or lower: `require('fetch-mock/es5/server)` + You will need to ensure `fetch` and `Promise` are already available as globals in your environment diff --git a/karma.conf.js b/karma.conf.js index dd3540e0..1a7090cf 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -12,7 +12,7 @@ module.exports = function(karma) { 'test/client.js': ['browserify'] }, browserify: { - transform: ['babelify'], + transform: [['babelify', { presets: ['es2015'] }]], debug: true }, browsers: ['Chrome'], diff --git a/package.json b/package.json index 38b4cc99..efaeb190 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "babel": "^6.0.15", "babel-cli": "^6.1.2", "babel-preset-es2015": "^6.1.2", - "babelify": "^7.0.0", + "babelify": "^7.2.0", "browserify": "^12.0.0", "chai": "^2.3.0", "karma": "^0.12.31", diff --git a/src/client.js b/src/client.js index 6c36379d..2bfaeaa5 100644 --- a/src/client.js +++ b/src/client.js @@ -1,5 +1,9 @@ 'use strict'; +if (!window) { + throw 'Incorrect fetch-mock: require(\'fetch-mock/server\') in nodejs >= 4, or require(\'fetch-mock/es5/server\' in nodejs 0.12.x'; +} + const FetchMock = require('./fetch-mock'); module.exports = new FetchMock({