mattermost-plugin-shelfmark/webapp/tests/setup_globals.js
Felipe M. bcdb6fd4e5
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Fix webapp test compatibility with bun and undici
Add setup_globals.js to polyfill web APIs (ReadableStream, Blob, File,
etc.) that undici requires but jsdom does not provide. Remove deprecated
enzyme-to-json snapshot serializer which has incompatible cheerio deps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 09:37:02 +01:00

32 lines
817 B
JavaScript

/* eslint-disable no-undef, import/order */
// Polyfill web APIs for jsdom test environment (required by undici)
const {Blob} = require('buffer');
const {ReadableStream, WritableStream, TransformStream} = require('stream/web');
class File extends Blob {
constructor(chunks, name, options = {}) {
super(chunks, options);
this.name = name;
this.lastModified = options.lastModified || Date.now();
}
}
class MessagePort {}
if (typeof global.DOMException === 'undefined') {
global.DOMException = class DOMException extends Error {
constructor(message, name) {
super(message);
this.name = name || 'Error';
}
};
}
Object.assign(global, {
ReadableStream,
WritableStream,
TransformStream,
Blob,
File,
MessagePort,
});