diff --git a/package.json b/package.json index c066c78d3..212d8cc67 100644 --- a/package.json +++ b/package.json @@ -15,15 +15,18 @@ "license": "BSD-3-Clause", "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-dev": "run-s test-node -- --watch -R min", + "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-cloud": "run-s 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", - "test": "npm run test-node && npm run test-headless && npm run test-webworker", + "test": "run-s test-node test-headless test-webworker", + "build": "./build.js", "lint": "eslint .", "precommit": "lint-staged", - "prepublish": "rimraf pkg && ./build.js", + "pretest-webworker": "run-s build", + "prebuild": "rimraf pkg", + "prepublishOnly": "run -s build", "preversion": "./scripts/preversion.sh", "postversion": "./scripts/postversion.sh", "eslint-pre-commit": "./scripts/eslint-pre-commit" @@ -53,9 +56,12 @@ "mocha": "^3.1.2", "mochify": "^3.0.0", "mochify-istanbul": "^2.4.1", + "npm-run-all": "^4.0.2", "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 78a481281..bcf8808da 100644 --- a/test/call-test.js +++ b/test/call-test.js @@ -852,7 +852,10 @@ 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(); } + var stub1 = sinonStub().resolves(1); var stub2 = sinonStub().returns(1); @@ -867,6 +870,7 @@ describe("sinonSpy.call", function () { }) .catch( done ); }); + /* eslint-enable consistent-return */ }); describe("constructor", function () { diff --git a/test/issues/issues-test.js b/test/issues/issues-test.js index 7e3c8c653..47b472dd2 100644 --- a/test/issues/issues-test.js +++ b/test/issues/issues-test.js @@ -223,6 +223,7 @@ describe("issues", function () { }); describe("#1474 - promise library should be propagated through fakes and behaviors", function () { + var stub; function makeAssertions(fake, expected) { @@ -232,6 +233,10 @@ describe("issues", function () { assert.equals(fake.tap(), expected); } + before(function () { + if (!global.Promise) { this.skip(); } + }); + beforeEach(function () { var promiseLib = { resolve: function (value) { diff --git a/test/sandbox-test.js b/test/sandbox-test.js index d765afae1..bd74908e4 100644 --- a/test/sandbox-test.js +++ b/test/sandbox-test.js @@ -17,6 +17,7 @@ var sinonAssert = require("../lib/sinon/assert"); var sinonClock = require("../lib/sinon/util/fake_timers"); var supportsAjax = typeof XMLHttpRequest !== "undefined" || typeof ActiveXObject !== "undefined"; +var supportPromise = !!global.Promise; var globalXHR = global.XMLHttpRequest; var globalAXO = global.ActiveXObject; @@ -148,6 +149,7 @@ describe("sinonSandbox", function () { }); it("must set all stubs created from sandbox with mockPromise", function () { + if (!supportPromise) { return this.skip(); } var resolveValue = {}; var mockPromise = { @@ -167,6 +169,7 @@ describe("sinonSandbox", function () { // eslint-disable-next-line mocha/no-identical-title it("must set all stubs created from sandbox with mockPromise", function () { + if (!supportPromise) { return this.skip(); } var resolveValue = {}; var mockPromise = { diff --git a/test/sinon-test.js b/test/sinon-test.js index c5be2af68..8916a37c6 100644 --- a/test/sinon-test.js +++ b/test/sinon-test.js @@ -1,5 +1,6 @@ "use strict"; +var proxyquire = require("proxyquire"); var assert = require("referee").assert; var hasPromise = typeof Promise === "function"; @@ -12,7 +13,6 @@ describe("sinon module", function () { fakeNise; beforeEach(function () { - var proxyquire = require("proxyquire"); fakeNise = { fakeServer: "47c86a4c-6b48-4748-bb8c-d853f999720c",