Skip to content

Commit

Permalink
Update 'esm' dependency (sinonjs#2053)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fatso83 authored and Franck Romano committed Oct 1, 2019
1 parent bbedbbd commit 995edcc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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);
});
});
Expand Down

0 comments on commit 995edcc

Please sign in to comment.