jest-environment-jsdom-npm-29.5.0-fc600add1e.patch 1.1 KB

12345678910111213141516171819202122232425
  1. diff --git a/build/index.js b/build/index.js
  2. index ec8a133f3fbea56f4b395c96ca2b27bd4903c62e..dfd3852248f5008f82794ce61e3dca10ee8f8389 100644
  3. --- a/build/index.js
  4. +++ b/build/index.js
  5. @@ -49,7 +49,7 @@ class JSDOMEnvironment {
  6. global;
  7. errorEventListener;
  8. moduleMocker;
  9. - customExportConditions = ['browser'];
  10. + customExportConditions = ['jest','browser'];
  11. constructor(config, context) {
  12. const {projectConfig} = config;
  13. const virtualConsole = new (_jsdom().VirtualConsole)();
  14. @@ -93,6 +93,11 @@ class JSDOMEnvironment {
  15. // TODO: remove this ASAP, but it currently causes tests to run really slow
  16. global.Buffer = Buffer;
  17. + // JSDOM does not provide the following, thankfully Node.js ships with spec-compliant equivalent:
  18. + global.TextDecoder = TextDecoder;
  19. + global.TextEncoder = TextEncoder;
  20. + Object.defineProperty(global, 'crypto', {__proto__:null, value:require('node:crypto').webcrypto});
  21. +
  22. // Report uncaught errors.
  23. this.errorEventListener = event => {
  24. if (userErrorListenerCount === 0 && event.error != null) {