From d37ca03ed65ca57d7335faf42a3510262437e952 Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Tue, 1 Aug 2017 10:57:09 +0200 Subject: [PATCH] Add proxyquire-universal to headless run This commit reintroduces the proxyquire-universal changes that caused some issues (see #1498 and commit cbf11282). What is different is that it removes proxyquire from the build step. This should never have been there, and was probably introduced to make proxyquire calls in the tests work with browsers. The problem was that the tests are not using the built sinon file, so the config changes would only be utilized for the built file. By adding the proxquire-universal plugin to the NPM script "test-headless" it would only take place for these tests and the cloud tests (which are reusing the headless config). This commit, along with the previous, fixes #1498. --- package.json | 4 +++- test/call-test.js | 2 ++ test/sinon-test.js | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c066c78d3..97484a7d7 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "scripts": { "test-node": "mocha --recursive -R dot test/", "test-dev": "npm run test-node -- --watch -R min", - "test-headless": "mochify --recursive -R dot --grep WebWorker --invert test/", + "test-headless": "mochify --recursive -R dot --grep WebWorker --invert --plugin [ proxyquire-universal ] test/", "test-coverage": "mochify --recursive -R dot --grep WebWorker --invert --plugin [ mochify-istanbul --exclude '**/+(test|node_modules)/**/*' --report text --report lcovonly --dir ./coverage ] test/", "test-cloud": "npm run test-headless -- --wd", "test-webworker": "browserify --no-commondir --full-paths -p [ mocaccino -R spec --color ] test/webworker/webworker-support-assessment.js | phantomic --web-security false", @@ -56,6 +56,8 @@ "phantomic": "^1.4.0", "phantomjs-prebuilt": "^2.1.14", "proxyquire": "^1.8.0", + "proxyquire-universal": "^1.0.8", + "proxyquireify": "^3.2.1", "referee": "^1.2.0", "rimraf": "^2.5.3" }, diff --git a/test/call-test.js b/test/call-test.js index 5d0cc5fb6..bcf8808da 100644 --- a/test/call-test.js +++ b/test/call-test.js @@ -852,6 +852,7 @@ describe("sinonSpy.call", function () { }); // https://github.com/sinonjs/sinon/issues/1066 + /* eslint-disable consistent-return */ it("does not throw when the call stack is empty", function (done) { if (!global.Promise) { this.skip(); } @@ -869,6 +870,7 @@ describe("sinonSpy.call", function () { }) .catch( done ); }); + /* eslint-enable consistent-return */ }); describe("constructor", function () { diff --git a/test/sinon-test.js b/test/sinon-test.js index 0b2d29301..8916a37c6 100644 --- a/test/sinon-test.js +++ b/test/sinon-test.js @@ -3,7 +3,6 @@ var proxyquire = require("proxyquire"); var assert = require("referee").assert; var hasPromise = typeof Promise === "function"; -var proxyquire = require("proxyquire"); if (!hasPromise) { return;