diff --git a/package.json b/package.json index ef446084..33fb9eca 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test-check-coverage": "npm run test-coverage && nyc check-coverage", "test-cloud": "mochify --wd --no-detect-globals --timeout=10000", "test-coverage": "nyc --all --reporter text --reporter html --reporter lcovonly npm run test-node", - "test-esm": "node -r esm test/fake-timers-esm-test.js", + "test-esm": "node -r esm test-esm/fake-timers-esm-test.js", "test": "npm run lint && npm run test-node && npm run test-headless && npm run test-esm", "bundle": "node ./build.js", "prepublishOnly": "npm run bundle", @@ -72,7 +72,19 @@ "ie11/no-weak-collections": [ "error" ] - } + }, + "overrides": [ + { + "files": "test-esm/*", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "modules": true + } + } + } + ] }, "module": "./pkg/fake-timers-esm.js", "cdn": "./pkg/fake-timers.js", @@ -93,6 +105,8 @@ "statements": 92, "exclude": [ "**/*-test.js", + "**/*-test-esm.js", + "./build.js", "coverage/**", "pkg/**" ] diff --git a/test/fake-timers-esm-test.js b/test-esm/fake-timers-esm-test.js similarity index 57% rename from test/fake-timers-esm-test.js rename to test-esm/fake-timers-esm-test.js index 9301b455..a6dd1181 100644 --- a/test/fake-timers-esm-test.js +++ b/test-esm/fake-timers-esm-test.js @@ -1,6 +1,7 @@ -import * as timers from '../pkg/fake-timers-esm.js'; +/* eslint-disable no-console */ +import * as timers from "../pkg/fake-timers-esm.js"; -const expectedExports = ['timers', 'createClock', 'install', 'withGlobal']; +const expectedExports = ["timers", "createClock", "install", "withGlobal"]; for (const exp of expectedExports) { if (!timers[exp]) { @@ -10,12 +11,11 @@ for (const exp of expectedExports) { } let hasRun = false; -const org = setTimeout; const clock = timers.install(); setTimeout(() => (hasRun = true)); clock.tick(); if (!hasRun) { - console.error('Failed to tick timers in ES Module'); + console.error("Failed to tick timers in ES Module"); process.exit(1); }