Skip to content

Commit

Permalink
refactor: changed back to @strapi/admin-test-utils/environment testEn…
Browse files Browse the repository at this point in the history
…vironment and removed jest-fixed-jsdom
  • Loading branch information
nilsingwersen committed Oct 16, 2024
1 parent 51fd294 commit da04d7c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jest-preset.front.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
globalSetup: '@strapi/admin-test-utils/global-setup',
setupFiles: ['@strapi/admin-test-utils/setup'],
setupFilesAfterEnv: ['@strapi/admin-test-utils/after-env'],
testEnvironment: 'jest-fixed-jsdom',
testEnvironment: '@strapi/admin-test-utils/environment',
prettierPath: require.resolve('prettier-2'),
transform: {
'^.+\\.js(x)?$': [
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
"jest-circus": "29.6.0",
"jest-cli": "29.6.0",
"jest-environment-jsdom": "29.6.1",
"jest-fixed-jsdom": "0.0.4",
"jest-watch-typeahead": "2.2.2",
"lerna": "8.1.2",
"lint-staged": "15.2.10",
Expand Down
14 changes: 14 additions & 0 deletions packages/admin-test-utils/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,19 @@ export default class CustomJSDOMEnvironment extends JSDOMEnvironment {

// TODO: remove once https://github.com/jsdom/jsdom/issues/3363 is closed.
this.global.structuredClone = structuredClone;

// fixing these global APIs according to https://github.com/mswjs/jest-fixed-jsdom/blob/main/index.js
this.global.TextDecoder = TextDecoder;
this.global.TextEncoder = TextEncoder;
this.global.ReadableStream = ReadableStream;

this.global.Blob = Blob;
this.global.Headers = Headers;
this.global.FormData = FormData;
this.global.Request = Request;
this.global.Response = Response;
this.global.fetch = fetch;

this.global.URL = URL;
}
}

0 comments on commit da04d7c

Please sign in to comment.