diff --git a/jest/create-jest-config.cjs b/jest/create-jest-config.cjs index 3ab2429e19..63e9394dbe 100644 --- a/jest/create-jest-config.cjs +++ b/jest/create-jest-config.cjs @@ -3,7 +3,11 @@ module.exports = function createJestConfig(root, options) { return Object.assign( { rootDir: root, - setupFilesAfterEnv: ['../../jest/custom-matchers.ts', ...setupFilesAfterEnv], + setupFilesAfterEnv: [ + '../../jest/custom-matchers.ts', + '../../jest/polyfills.ts', + ...setupFilesAfterEnv, + ], transform: { '^.+\\.(t|j)sx?$': '@swc/jest', ...transform, diff --git a/jest/polyfills.ts b/jest/polyfills.ts new file mode 100644 index 0000000000..f928491855 --- /dev/null +++ b/jest/polyfills.ts @@ -0,0 +1,15 @@ +// JSDOM Doesn't implement innerText yet: https://github.com/jsdom/jsdom/issues/1245 +// So this is a hacky way of implementing it using `textContent`. +// Real implementation doesn't use textContent because: +// > textContent gets the content of all elements, including