From a39089a00105bca7e1d2f59dffb89dbf0ea9e3ed Mon Sep 17 00:00:00 2001 From: Christoph Tavan Date: Fri, 24 Apr 2020 11:48:58 +0200 Subject: [PATCH] test: add test for Node.js ES Modules and CommonJS usage Also remove unused npm script for browser-esmodules --- .github/workflows/ci.yml | 2 ++ examples/node-esmodules/{example.js => example.mjs} | 0 examples/node-esmodules/package.json | 3 +-- package.json | 11 +++++++---- 4 files changed, 10 insertions(+), 6 deletions(-) rename examples/node-esmodules/{example.js => example.mjs} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47a71bd2..342840f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,3 +38,5 @@ jobs: if: matrix.node-version == '12.x' env: BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} + - run: npm run test:node + if: matrix.node-version == '12.x' || matrix.node-version == '14.x' diff --git a/examples/node-esmodules/example.js b/examples/node-esmodules/example.mjs similarity index 100% rename from examples/node-esmodules/example.js rename to examples/node-esmodules/example.mjs diff --git a/examples/node-esmodules/package.json b/examples/node-esmodules/package.json index 24265f5e..8afddfed 100644 --- a/examples/node-esmodules/package.json +++ b/examples/node-esmodules/package.json @@ -2,9 +2,8 @@ "name": "uuid-example-node-esmodules", "version": "0.0.0", "private": true, - "type": "module", "scripts": { - "test": "node --experimental-modules example.js" + "test": "node --experimental-modules example.mjs" }, "dependencies": { "uuid": "file:../../.local" diff --git a/package.json b/package.json index 54937a64..192a77bd 100644 --- a/package.json +++ b/package.json @@ -72,16 +72,19 @@ "standard-version": "7.1.0" }, "scripts": { - "examples:browser-webpack:build": "cd examples/browser-webpack && npm install && npm run build", - "examples:browser-rollup:build": "cd examples/browser-rollup && npm install && npm run build", - "examples:browser-esmodules:build": "cd examples/browser-esmodules && npm install && npm run build", + "examples:browser:webpack:build": "cd examples/browser-webpack && npm install && npm run build", + "examples:browser:rollup:build": "cd examples/browser-rollup && npm install && npm run build", + "examples:node:commonjs:test": "cd examples/node-commonjs && npm install && npm test", + "examples:node:esmodules:test": "cd examples/node-esmodules && npm install && npm test", "lint": "npm run eslint:check && npm run prettier:check", "eslint:check": "eslint src/ test/ examples/ *.js", "eslint:fix": "eslint --fix src/ test/ examples/ *.js", "pretest": "[ -n $CI ] || npm run build", "test": "BABEL_ENV=commonjs node --throw-deprecation node_modules/.bin/jest test/unit/", - "pretest:browser": "npm run build && npm-run-all --parallel examples:**", + "pretest:browser": "npm run build && npm-run-all --parallel examples:browser:**", "test:browser": "wdio run ./wdio.conf.js", + "pretest:node": "npm run build", + "test:node": "npm-run-all --parallel examples:node:**", "prettier:check": "prettier --ignore-path .prettierignore --check '**/*.{js,jsx,json,md}'", "prettier:fix": "prettier --ignore-path .prettierignore --write '**/*.{js,jsx,json,md}'", "bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",