Skip to content

Commit

Permalink
chore(NA): add Blob polyfill on jest env (elastic#162197)
Browse files Browse the repository at this point in the history
This PR adds the `Blob` polyfill into the jest jsdom env which is
currently not supported as mentioned in
jsdom/jsdom#2555

---------

Co-authored-by: Thomas Watson <w@tson.dk>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit e9a6519)

# Conflicts:
#	package.json
#	packages/kbn-test/src/jest/setup/polyfills.jsdom.js
#	yarn.lock
  • Loading branch information
mistic committed Jul 20, 2023
1 parent 47018ee commit 73950a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@
"babel-plugin-styled-components": "^2.0.7",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"backport": "^5.6.6",
"blob-polyfill": "^7.0.20220408",
"callsites": "^3.1.0",
"chai": "3.5.0",
"chance": "1.0.18",
Expand Down
7 changes: 7 additions & 0 deletions packages/kbn-test/src/jest/setup/polyfills.jsdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ if (!global.URL.hasOwnProperty('createObjectURL')) {
// Will be replaced with a better solution in EUI
// https://github.com/elastic/eui/issues/3713
global._isJest = true;

// NOTE: We should evaluate removing this once we upgrade to Node 18 and find out if loaders.gl already fixed this usage
// or instead check if we can use the official Blob implementation.
// This is needed for x-pack/plugins/file_upload/public/importer/geo/geojson_importer/geojson_importer.test.js
//
// https://github.com/jsdom/jsdom/issues/2555
global.Blob = require('blob-polyfill').Blob;
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9074,6 +9074,11 @@ bl@^4.0.1, bl@^4.0.3:
inherits "^2.0.4"
readable-stream "^3.4.0"

blob-polyfill@^7.0.20220408:
version "7.0.20220408"
resolved "https://registry.yarnpkg.com/blob-polyfill/-/blob-polyfill-7.0.20220408.tgz#38bf5e046c41a21bb13654d9d19f303233b8218c"
integrity sha512-oD8Ydw+5lNoqq+en24iuPt1QixdPpe/nUF8azTHnviCZYu9zUC+TwdzIp5orpblJosNlgNbVmmAb//c6d6ImUQ==

blob-util@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/blob-util/-/blob-util-2.0.2.tgz#3b4e3c281111bb7f11128518006cdc60b403a1eb"
Expand Down

0 comments on commit 73950a2

Please sign in to comment.