diff --git a/.eslintignore b/.eslintignore index 976cc7dd7..67fe9ce0c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,6 +5,3 @@ docs/_site/ docs/js/ docs/releases/ docs/assets/js/ - -# has "invalid" ESM syntax -rollup.config.js diff --git a/.travis.yml b/.travis.yml index 28c798596..f3670ba4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,15 +28,16 @@ before_script: # these build targets only need to run once per build, so let's conserve a few resources # ESLint only supports Node >=4 - if [ "x$TRAVIS_NODE_VERSION" = "x10" ]; then npm run lint; fi + - if [ "x$TRAVIS_NODE_VERSION" = "x10" ]; then npm run lint-markdown; fi - if [ "x$TRAVIS_NODE_VERSION" = "x10" ]; then npm run test-headless -- --allow-chrome-as-root; fi - if [ "x$TRAVIS_NODE_VERSION" = "x10" ]; then npm run test-webworker -- --allow-chrome-as-root; fi - - if [ "x$TRAVIS_NODE_VERSION" = "x10" ]; then npm run test-esm-bundle; fi - if [ "x$TRAVIS_NODE_VERSION" = "x10" ] && [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test-cloud; fi -script: npm run test-node +script: + - npm run test-node after_success: - - if [ "x$TRAVIS_NODE_VERSION" = "x10" ]; then npm run test-coverage -- --allow-chrome-as-root && cat ./coverage/lcov.info | coveralls lib; fi + - if [ "x$TRAVIS_NODE_VERSION" = "x10" ]; then npm run test-coverage && cat ./coverage/lcov.info | coveralls lib; fi git: - depth: 1 + depth: 10 diff --git a/package.json b/package.json index 53c0f4bb9..f2513ccca 100644 --- a/package.json +++ b/package.json @@ -14,26 +14,22 @@ }, "license": "BSD-3-Clause", "scripts": { - "test-node": "mocha --recursive -R dot test/**-test.js", + "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 --plugin [ proxyquire-universal ] test/**-test.js", - "test-coverage": "mochify --recursive -R dot --grep WebWorker --invert --plugin [ proxyquire-universal ] --plugin [ mochify-istanbul --exclude '**/test/**' --report text --report lcovonly --dir ./coverage ] test/**-test.js", + "test-headless": "mochify --recursive -R dot --grep WebWorker --invert --plugin [ proxyquire-universal ] test/**.js", + "test-coverage": "mochify --recursive -R dot --grep WebWorker --invert --plugin [ proxyquire-universal ] --plugin [ mochify-istanbul --exclude '**/test/**' --report text --report lcovonly --dir ./coverage ] test/**.js", "test-cloud": "npm run test-headless -- --wd", "test-webworker": "mochify --https-server 8080 test/webworker/webworker-support-assessment.js", - "test-esm": "mocha -r esm test/es2015/module-support-assessment-test.mjs", - "test-esm-bundle": "node test/es2015/check-esm-bundle-is-runnable.js", - "test": "run-s test-node test-headless test-webworker test-esm", + "test-es-module": "mocha -r esm test/es2015/module-support-assessment-test.mjs", + "test": "run-s test-node test-headless test-webworker test-es-module", "check-dependencies": "dependency-check package.json --unused --no-dev --ignore-module coveralls --ignore-module esm", - "build": "run-p build-*", - "build-bundle": "node ./build.js", - "build-esm": "rollup -c", + "build": "node ./build.js", "lint": "run-p lint-js lint-markdown", "lint-js": "eslint '**/*.{js,mjs}'", "lint-markdown": "find docs -type f -name '*.md' ! -name 'changelog.md' | xargs markdownlint", "precommit": "lint-staged", "pretest-webworker": "npm run build", "prebuild": "rimraf pkg && npm run check-dependencies", - "postbuild": "run-s test-esm-bundle", "prepublishOnly": "npm run build", "preversion": "./scripts/preversion.sh", "postversion": "./scripts/postversion.sh" @@ -72,13 +68,7 @@ "proxyquire": "^1.8.0", "proxyquire-universal": "^1.0.8", "proxyquireify": "^3.2.1", - "puppeteer": "^1.4.0", "rimraf": "^2.5.3", - "rollup": "^0.59.3", - "rollup-plugin-commonjs": "^9.1.3", - "rollup-plugin-node-builtins": "^2.1.2", - "rollup-plugin-node-globals": "^1.2.1", - "rollup-plugin-node-resolve": "^3.3.0", "samsam": "^1.3.0" }, "files": [ @@ -92,7 +82,6 @@ "README.md" ], "main": "./lib/sinon.js", - "module": "./pkg/sinon-esm.js", "cdn": "./pkg/sinon.js", "jsdelivr": "./pkg/sinon.js" } diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 43eb40663..000000000 --- a/rollup.config.js +++ /dev/null @@ -1,26 +0,0 @@ -import commonjs from "rollup-plugin-commonjs"; -import nodeResolve from "rollup-plugin-node-resolve"; -import builtins from "rollup-plugin-node-builtins"; -import globals from "rollup-plugin-node-globals"; - -export default { - input: "./lib/sinon.js", - output: { - file: "pkg/sinon-esm.js", - format: "es" - }, - plugins: [ - nodeResolve({ - jsnext: true, - main: true - }), - - commonjs({ - // if false then skip sourceMap generation for CommonJS modules - sourceMap: true // Default: true - }), - - builtins(), - globals() - ] -}; diff --git a/test/es2015/.eslintrc.yml b/test/es2015/.eslintrc.yml index f1b3da266..add5a7856 100644 --- a/test/es2015/.eslintrc.yml +++ b/test/es2015/.eslintrc.yml @@ -1,3 +1,2 @@ parserOptions: sourceType: module - ecmaVersion: 2017 diff --git a/test/es2015/check-esm-bundle-is-runnable.js b/test/es2015/check-esm-bundle-is-runnable.js deleted file mode 100644 index 80aea76cc..000000000 --- a/test/es2015/check-esm-bundle-is-runnable.js +++ /dev/null @@ -1,87 +0,0 @@ -/* eslint-disable no-process-exit */ -const puppeteer = require("puppeteer"); - -const http = require("http"); -const fs = require("fs"); -const port = 3876; - -const htmlWithModuleScript = ` - -`; - -// start server where our built sinon esm bundle resides -process.chdir(`${__dirname}/../../pkg/`); -const sinonModule = fs.readFileSync("./sinon-esm.js"); - -async function evaluatePageContent() { - const browser = await puppeteer.launch({ - // https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-on-travis-ci - args: ["--no-sandbox"], - // allow overriding chrome path - executablePath: process.env.SINON_CHROME_BIN || null - }); - const page = await browser.newPage(); - - function die(reason) { - if (reason) { - /* eslint-disable no-console */ - console.error(reason); - } - - browser.close(); - process.exit(1); - } - - page.on("error", function (err) { - throw err; - }); - - // our "assertion framework" :) - page.on("console", function (msg) { - var text = msg.text(); - - if (text.startsWith("sinon-result:works")) { - browser.close(); - process.exit(0); - } else if (text.startsWith("sinon-result:fails")) { - die(text); - } - }); - - await page.goto("http://localhost:3876"); - - setTimeout(() => die("No result within timeout."), 1000); -} - -const app = http.createServer((req, res) => { - let body, type; - - if (req.url.match(/sinon-esm\.js/)) { - body = sinonModule; - type = "application/javascript"; - } else { - body = htmlWithModuleScript; - type = "text/html"; - } - - const headers = { - "Content-Length": Buffer.byteLength(body), - "Content-Type": type - }; - res.writeHead(200, headers); - res.end(body); -}); - -app.listen(port, evaluatePageContent);