Skip to content

Commit 56a6765

Browse files
committed
fix Jest and ESM issues from #156
1 parent 47384d5 commit 56a6765

File tree

10 files changed

+348
-216
lines changed

10 files changed

+348
-216
lines changed

package-lock.json

Lines changed: 142 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"jsnext:main": "./dist/unfetch.mjs",
99
"umd:main": "./dist/unfetch.umd.js",
1010
"scripts": {
11-
"test": "eslint && jest",
11+
"test": "eslint && NODE_OPTIONS=--experimental-vm-modules jest",
1212
"build": "microbundle src/index.mjs -f cjs,esm,umd && microbundle polyfill/polyfill.mjs -o polyfill/index.js -f cjs --no-sourcemap && cp dist/unfetch.module.js dist/unfetch.es.js",
1313
"prepare": "npm run -s build",
1414
"release": "cross-var npm run build -s && cross-var git commit -am $npm_package_version && cross-var git tag $npm_package_version && git push && git push --tags && npm publish"
@@ -49,9 +49,14 @@
4949
"extends": "developit"
5050
},
5151
"jest": {
52-
"testURL": "http://localhost/",
52+
"testEnvironmentOptions": {
53+
"url": "http://localhost/"
54+
},
5355
"testMatch": [
54-
"<rootDir>/test/**/*.?(m)js?(x)"
56+
"<rootDir>/test/**/*.test.?(m)js?(x)"
57+
],
58+
"setupFiles": [
59+
"<rootDir>/test/_setup.js"
5560
],
5661
"moduleFileExtensions": [
5762
"mjs",
@@ -73,6 +78,8 @@
7378
"devDependencies": {
7479
"@babel/core": "^7.20.7",
7580
"@babel/preset-env": "^7.20.2",
81+
"@types/jest": "^29.2.5",
82+
"@types/node": "^18.11.18",
7683
"cross-var": "^1.1.0",
7784
"eslint": "^8.30.0",
7885
"eslint-config-developit": "^1.2.0",

packages/isomorphic-unfetch/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module.exports = global.fetch =
66
(typeof process == "undefined"
77
? r(require("unfetch"))
88
: function (url, opts) {
9-
if (typeof url === "string" || url instanceof URL)
9+
if (typeof url === "string" || url instanceof URL) {
1010
url = String(url).replace(/^\/\//g, "https://");
11+
}
1112
return import("node-fetch").then((m) => r(m)(url, opts));
1213
});

0 commit comments

Comments
 (0)