1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/jest.setup.ts
Janne Savolainen f281df1693
Fix installation of helm charts (#5841)
* Relax validator for installing charts

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Tweak spacing between words in confirmation dialog

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Add mocks for monaco editor and virtualized auto sizer to allow components to be rendered in unit tests

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Improve typing for a function

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove usage of shared global state from a component

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Provide a way to unit test usages of storages

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Add way to get current value from select in behavioural unit tests

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Rework installation of helm charts to get rid of the majority of bugs

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Update snapshots

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove technical test for being covered in behaviours

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Split behaviour to smaller pieces

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Add tests accidentally removed back

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Mark functions causing side effects

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove behaviour covered by other behaviours

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Tweak naming

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove unused dependency

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2022-07-20 08:15:27 +03:00

47 lines
1.2 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import fetchMock from "jest-fetch-mock";
import configurePackages from "./common/configure-packages";
import { configure } from "mobx";
import { setImmediate } from "timers";
import { TextEncoder, TextDecoder as TextDecoderNode } from "util";
// setup default configuration for external npm-packages
configurePackages();
configure({
// Needed because we want to use jest.spyOn()
// ref https://github.com/mobxjs/mobx/issues/2784
safeDescriptors: false,
});
// rewire global.fetch to call 'fetchMock'
fetchMock.enableMocks();
// Mock __non_webpack_require__ for tests
globalThis.__non_webpack_require__ = jest.fn();
global.setImmediate = setImmediate;
global.fail = ((error = "Test failed without explicit error") => {
console.error(error);
}) as any;
process.on("unhandledRejection", (err: any) => {
global.fail(err);
});
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoderNode as unknown as typeof TextDecoder;
global.ResizeObserver = class {
observe = () => {};
unobserve = () => {};
disconnect = () => {};
};
jest.mock("./renderer/components/monaco-editor/monaco-editor");