Skip to content

Commit

Permalink
Merge branch 'develop' into feat.googleads.ecom.spec.support.v2
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai authored Feb 27, 2024
2 parents f47ec39 + 37ac0ea commit dcf2d81
Show file tree
Hide file tree
Showing 34 changed files with 3,282 additions and 4,948 deletions.
2 changes: 1 addition & 1 deletion jest.preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
},
setupFilesAfterEnv: ['../../jest/jest.setup-dom.js'],
setupFiles: ['core-js', 'jest-date-mock', '../../jest/jest.polyfills.js'],
testEnvironment: 'jest-environment-jsdom',
testEnvironment: '../../jest/jsdom-extended.js',
testRunner: 'jest-circus/runner',
cacheDirectory: '../../node_modules/.cache/unit-tests',
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
Expand Down
6 changes: 0 additions & 6 deletions jest/jest.polyfills.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */

require('isomorphic-fetch');

// Mocking Math random
Expand All @@ -18,7 +16,3 @@ console.warn = jest.fn();
console.error = jest.fn();
// Mock browsers sendBeacon utility
navigator.sendBeacon = jest.fn();

import { TextEncoder, TextDecoder } from 'util';

Object.assign(global, { TextDecoder, TextEncoder });
26 changes: 26 additions & 0 deletions jest/jsdom-extended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import JSDOMEnvironment from 'jest-environment-jsdom';

// Adding relevant polyfilled extensions in the JSDOm to have msw v2 working
// More on: https://github.com/mswjs/msw/issues/1916#issuecomment-1919965699
class JSDOMEnvironmentExtended extends JSDOMEnvironment {
constructor(...args) {
super(...args);

this.global.ReadableStream = ReadableStream;
this.global.TextDecoder = TextDecoder;
this.global.TextEncoder = TextEncoder;

this.global.Blob = Blob;
this.global.File = File;
this.global.Headers = Headers;
this.global.FormData = FormData;
this.global.Request = Request;
this.global.Response = Response;
this.global.Request = Request;
this.global.Response = Response;
this.global.fetch = fetch;
this.global.structuredClone = structuredClone;
}
}

module.exports = JSDOMEnvironmentExtended;
Loading

0 comments on commit dcf2d81

Please sign in to comment.