From 971eb0c5905687e5c00d0a5b1427cac9acbaed33 Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Fri, 28 Jun 2019 01:08:28 +0200 Subject: [PATCH] Update 'esm' dependency (#2053) Requires a small fix to the setup, as 'esm' would complain with Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/fatso/dev/sinon/test/es2015/module-support-assessment-test.mjs when encountering '*.mjs' files --- package-lock.json | 10 +++++----- package.json | 13 ++++++++++--- ...mjs => module-support-assessment-test.es6} | 19 ++++++++++++++----- 3 files changed, 29 insertions(+), 13 deletions(-) rename test/es2015/{module-support-assessment-test.mjs => module-support-assessment-test.es6} (88%) diff --git a/package-lock.json b/package-lock.json index ae683f4e1..7cdccffe1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2216,9 +2216,9 @@ "dev": true }, "esm": { - "version": "3.0.37", - "resolved": "https://registry.npmjs.org/esm/-/esm-3.0.37.tgz", - "integrity": "sha512-T7x0ZOnc8Olgvox3zO5wznU9/kQ9UrteddPp1q6aPCznarz3g07Gj1YKcKCavrBWBoJ+T3nwclDWqeMZsyWGNQ==", + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", "dev": true }, "espree": { @@ -5827,7 +5827,7 @@ }, "convert-source-map": { "version": "1.6.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "resolved": false, "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", "dev": true, "requires": { @@ -5836,7 +5836,7 @@ }, "debug": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "resolved": false, "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, "requires": { diff --git a/package.json b/package.json index e92f481ec..120a2668d 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test-coverage": "nyc npm run test-headless -- --transform [ babelify --ignore [ test ] --plugins [ babel-plugin-istanbul ] ]", "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": "mocha -r esm test/es2015/module-support-assessment-test.es6", "test-esm-bundle": "node test/es2015/check-esm-bundle-is-runnable.js", "test-docker-image": "docker-compose up", "test": "run-s test-node test-headless test-webworker test-esm", @@ -78,7 +78,7 @@ "eslint-plugin-local-rules": "^0.1.0", "eslint-plugin-mocha": "^5.3.0", "eslint-plugin-prettier": "^3.0.1", - "esm": "3.0.37", + "esm": "^3.2.25", "husky": "^0.14.2", "lint-staged": "^6.0.0", "markdownlint-cli": "^0.8.2", @@ -112,5 +112,12 @@ "main": "./lib/sinon.js", "module": "./pkg/sinon-esm.js", "cdn": "./pkg/sinon.js", - "jsdelivr": "./pkg/sinon.js" + "jsdelivr": "./pkg/sinon.js", + "esm": { + "cjs": { + "mutableNamespace": false, + "cache":true + }, + "mode": "auto" + } } diff --git a/test/es2015/module-support-assessment-test.mjs b/test/es2015/module-support-assessment-test.es6 similarity index 88% rename from test/es2015/module-support-assessment-test.mjs rename to test/es2015/module-support-assessment-test.es6 index 8f1b50388..ae943facf 100644 --- a/test/es2015/module-support-assessment-test.mjs +++ b/test/es2015/module-support-assessment-test.es6 @@ -1,12 +1,21 @@ -import referee from "@sinonjs/referee"; -import sinon from "../../lib/sinon"; +/** + * About these tests: + * These tests concern EcmaScript Modules. That is, they test Sinon's behaviour + * when running in a EcmaScript 2015+ environment that has the Module type. + * They do not assert how code that has been transpiled into ES5 using Babel + * and similar will behave. + */ import * as aModule from "./a-module"; -import aModuleWithToStringTag from "./a-module-with-to-string-tag"; -import aModuleWithDefaultExport from "./a-module-with-default"; // Usually one would import the default module, but one can make a form of wrapper like this /* eslint-disable no-unused-vars */ import functionModule, * as functionModuleAlternative from "./a-function-module"; + +import aModuleWithDefaultExport from "./a-module-with-default"; +import aModuleWithToStringTag from "./a-module-with-to-string-tag"; +import referee from "@sinonjs/referee"; +import sinon from "../../lib/sinon"; + const { assert, refute } = referee; function createTestSuite(action) { @@ -52,7 +61,7 @@ function createTestSuite(action) { describe("Modules that exports a function as their default export", function() { it("should not be possible to spy/stub the default export using a wrapper for the exports", function() { assert.exception(function() { - stub = sinon[action](functionModuleAlternative, "anExport"); + stub = sinon[action](functionModuleAlternative, "default"); }, errorRegEx); }); });