Files
cloudbeaver/webapp/packages/core-cli/tests/test.environment.js
T
Sychev Andreyandmr-anton-t a835f7e215 Cb 5860 bump versions (#3116)
* CB-5860 chore: bump versions

* CB-5860 chore: bump i18next

---------

Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com>
2024-12-06 07:39:49 +03:00

32 lines
1.1 KiB
JavaScript

/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { TransformStream } from 'node:stream/web';
const Environment = require('jest-environment-jsdom').default;
/**
JSDOM does not have an implementation for TextDecoder / TextEncoder / TransformStream present on their globals
and therefore not only are they not found, but you can't add them without access to their global context inside the VM.
MSW 2.0 related issue.
*/
module.exports = class CustomTestEnvironment extends Environment {
async setup() {
await super.setup();
this.global.TextEncoder = TextEncoder;
this.global.TextDecoder = TextDecoder;
this.global.Response = Response;
this.global.Request = Request;
this.global.TransformStream = TransformStream;
// FIXME https://github.com/jsdom/jsdom/issues/3363
this.global.structuredClone = structuredClone;
// different machine has its own timezones and some tests can fail because of it
process.env.TZ = 'UTC';
}
};