Merge pull request #18234 from backstage/blam/jsdom-env

cli: Add `Request` `Response` `Headers` and `fetch` to `jsdom` environment
This commit is contained in:
Fredrik Adelöw
2023-06-20 10:40:26 +02:00
committed by GitHub
128 changed files with 25 additions and 186 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Make sure to include a `fetch` environment for `jsdom` in `jest` tests
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-bitrise': patch
---
Remove `cross-fetch` dependency as it's not used
+8 -1
View File
@@ -194,9 +194,16 @@ async function getProjectConfig(targetPath, extraConfig) {
...getRoleConfig(closestPkgJson?.backstage?.role),
};
options.setupFilesAfterEnv = options.setupFilesAfterEnv || [];
if (options.testEnvironment === require.resolve('jest-environment-jsdom')) {
// FIXME https://github.com/jsdom/jsdom/issues/1724
options.setupFilesAfterEnv.unshift(require.resolve('cross-fetch/polyfill'));
}
// Use src/setupTests.ts as the default location for configuring test env
if (fs.existsSync(path.resolve(targetPath, 'src/setupTests.ts'))) {
options.setupFilesAfterEnv = ['<rootDir>/setupTests.ts'];
options.setupFilesAfterEnv.push('<rootDir>/setupTests.ts');
}
const config = Object.assign(options, ...pkgJsonConfigs);
+1
View File
@@ -74,6 +74,7 @@
"chalk": "^4.0.0",
"chokidar": "^3.3.1",
"commander": "^9.1.0",
"cross-fetch": "^3.1.5",
"cross-spawn": "^7.0.3",
"css-loader": "^6.5.1",
"diff": "^5.0.0",
@@ -48,8 +48,7 @@
"@testing-library/react": "{{versionQuery '@testing-library/react' '12.1.3'}}",
"@testing-library/user-event": "{{versionQuery '@testing-library/user-event' '14.0.0'}}",
"@types/node": "{{versionQuery '@types/node' '16.11.26'}}",
"msw": "{{versionQuery 'msw' '1.0.0'}}",
"cross-fetch": "{{versionQuery 'cross-fetch' '3.1.5'}}"
"msw": "{{versionQuery 'msw' '1.0.0'}}"
},
"files": [
"dist"
@@ -1,2 +1 @@
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -59,7 +59,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/zen-observable": "^0.8.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0",
"react-router-beta": "npm:react-router@6.0.0-beta.0",
"react-router-dom-beta": "npm:react-router-dom@6.0.0-beta.0",
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -101,7 +101,6 @@
"@types/react-virtualized-auto-sizer": "^1.0.1",
"@types/react-window": "^1.8.5",
"@types/zen-observable": "^0.8.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -70,7 +70,6 @@
"@types/node": "^16.11.26",
"@types/prop-types": "^15.7.3",
"@types/zen-observable": "^0.8.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -48,7 +48,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -50,7 +50,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -37,7 +37,6 @@ describe('The production Airbrake API', () => {
);
const groups = await productionApi.fetchGroups('123456');
expect(groups).toStrictEqual(mockGroupsData);
});
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -49,7 +49,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -49,7 +49,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
// eslint-disable-next-line no-restricted-imports
import { TextEncoder } from 'util';
@@ -46,7 +46,6 @@
"@types/jest": "^28.1.3",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
// eslint-disable-next-line no-restricted-imports
import { TextEncoder } from 'util';
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -47,7 +47,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -58,7 +58,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -60,7 +60,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
+1 -2
View File
@@ -51,8 +51,7 @@
"@backstage/dev-utils": "workspace:^",
"@backstage/test-utils": "workspace:^",
"@testing-library/jest-dom": "^5.16.5",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5"
"@types/node": "^16.11.26"
},
"files": [
"dist"
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
+1 -2
View File
@@ -51,8 +51,7 @@
"@backstage/cli": "workspace:^",
"@backstage/dev-utils": "workspace:^",
"@testing-library/jest-dom": "^5.10.1",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5"
"@types/react": "^16.13.1 || ^17.0.0"
},
"files": [
"dist"
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -31,7 +31,6 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.61",
"cross-fetch": "^3.1.5",
"lodash": "^4.17.21",
"luxon": "^3.0.0",
"qs": "^6.9.6",
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -69,7 +69,6 @@
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^8.0.0",
"@testing-library/user-event": "^14.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -89,7 +89,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/jwt-decode": "^3.1.0",
"@types/zen-observable": "^0.8.0",
"cross-fetch": "^3.1.5",
"react-test-renderer": "^16.13.1"
},
"files": [
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
@@ -44,7 +44,6 @@
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
+1 -2
View File
@@ -70,8 +70,7 @@
"@testing-library/dom": "^8.0.0",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^14.0.0",
"cross-fetch": "^3.1.5"
"@testing-library/user-event": "^14.0.0"
},
"files": [
"dist"
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -51,7 +51,6 @@
"@types/luxon": "^3.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -17,4 +17,3 @@
/* eslint-disable @backstage/no-undeclared-imports */
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -57,7 +57,6 @@
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"@types/recharts": "^1.8.15",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -49,7 +49,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -52,7 +52,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -56,7 +56,6 @@
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -63,7 +63,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -50,7 +50,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -57,7 +57,6 @@
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"@types/sanitize-html": "^2.6.2",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -54,7 +54,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/recharts": "^1.8.15",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -54,7 +54,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -52,7 +52,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
@@ -63,7 +63,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -61,7 +61,6 @@
"@types/luxon": "^3.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -48,7 +48,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -70,7 +70,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react-grid-layout": "^1.3.2",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -55,7 +55,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -52,7 +52,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"jest-when": "^3.1.0",
"msw": "^1.0.0"
},
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -71,7 +71,6 @@
"@testing-library/react-hooks": "^8.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -16,7 +16,6 @@
import '@testing-library/jest-dom';
// eslint-disable-next-line no-restricted-imports
import { TextDecoder, TextEncoder } from 'util';
import 'cross-fetch/polyfill';
// These are missing from jest-node, so not available on global.
Object.defineProperty(global, 'TextEncoder', {
-1
View File
@@ -62,7 +62,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -58,7 +58,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -72,7 +72,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
+1 -2
View File
@@ -41,8 +41,7 @@
"@backstage/cli": "workspace:^",
"@backstage/dev-utils": "workspace:^",
"@testing-library/jest-dom": "^5.10.1",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5"
"@types/react": "^16.13.1 || ^17.0.0"
},
"files": [
"dist"
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -48,7 +48,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -57,7 +57,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -61,7 +61,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -14,4 +14,3 @@
* limitations under the License.
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -63,7 +63,6 @@
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^14.0.0",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
-1
View File
@@ -52,7 +52,6 @@
"@types/luxon": "^3.0.0",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
-1
View File
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';

Some files were not shown because too many files have changed in this diff Show More