Skip to content

Commit

Permalink
shell-ui: Swith whatwg-fetch to node-fetch to polyfill fetch in node …
Browse files Browse the repository at this point in the history
…(refs: mswjs/msw#448)
  • Loading branch information
JBWatenbergScality committed Apr 9, 2021
1 parent be84e47 commit 9e8cc2b
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 11 deletions.
95 changes: 88 additions & 7 deletions shell-ui/package-lock.json

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

9 changes: 6 additions & 3 deletions shell-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"main": "index.js",
"scripts": {
"test": "jest",
"start": "webpack serve --config webpack.config.dev.js",
"start:navbar": "webpack serve --config webpack.config.dev.js --env=entry=navbar",
"start:alerts": "webpack serve --config webpack.config.dev.js --env=entry=alerts",
"build": "webpack --config webpack.config.prd.js"
},
"devDependencies": {
Expand All @@ -17,6 +18,7 @@
"@mdx-js/loader": "^1.6.22",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/react-hooks": "^5.1.1",
"@testing-library/user-event": "^13.0.10",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
Expand All @@ -26,12 +28,13 @@
"jest": "^26.6.3",
"jest-localstorage-mock": "^2.4.8",
"msw": "^0.26.2",
"node-fetch": "^2.6.1",
"prop-types": "^15.7.2",
"react-test-renderer": "^17.0.2",
"style-loader": "^2.0.0",
"webpack": "^5.17.0",
"webpack-cli": "^4.4.0",
"webpack-dev-server": "^3.11.2",
"whatwg-fetch": "^3.6.1"
"webpack-dev-server": "^3.11.2"
},
"dependencies": {
"@scality/core-ui": "github:scality/core-ui.git#v0.13.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'whatwg-fetch';
import fetch from 'node-fetch';
import 'regenerator-runtime/runtime';
import '@testing-library/jest-dom/extend-expect';
import 'jest-localstorage-mock';
Expand All @@ -9,3 +9,8 @@ window.crypto = {
return nodeCrypto.randomFillSync(buffer);
},
};

window.fetch = (url, ...rest) => fetch(
/^https?:/.test(url) ? url : new URL(url, 'http://localhost'),
...rest
);

0 comments on commit 9e8cc2b

Please sign in to comment.