-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-setup.ts
57 lines (49 loc) · 1.66 KB
/
jest-setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import '@testing-library/jest-dom';
import { configure } from '@testing-library/react';
import failOnConsole from 'jest-fail-on-console';
import fetchMock from 'jest-fetch-mock';
import {
defaultAfterAllTests,
defaultAfterEachTest,
defaultBeforeAllTests,
defaultBeforeEachTest,
getFailOnConsoleDefaultConfig
} from './src/carbonio-ui-commons/test/jest-setup';
import { JEST_MOCKED_ERROR } from './src/constants/tests';
import * as downloadModule from './src/helpers/download';
configure({
asyncUtilTimeout: 2000
});
jest.setTimeout(10000);
failOnConsole({
...getFailOnConsoleDefaultConfig(),
shouldFailOnWarn: false,
silenceMessage: (message): boolean =>
message.includes(JEST_MOCKED_ERROR) ||
// FIXME: these are caused by the wrong usage of the ChipInput, where all the data should
// go in the value of the chip, not the chip itself.
message.includes('Received `false` for a non-boolean attribute `duplicated`') ||
message.includes('React does not recognize the `firstName` prop on a DOM element') ||
message.includes('React does not recognize the `lastName` prop on a DOM element') ||
message.includes('React does not recognize the `fullName` prop on a DOM element') ||
message.includes('React does not recognize the `isGroup` prop on a DOM element')
});
beforeAll(() => {
defaultBeforeAllTests();
fetchMock.doMock();
jest.spyOn(downloadModule, 'redirectToBlob').mockImplementation(() => {});
});
beforeEach(() => {
defaultBeforeEachTest();
});
afterEach(() => {
defaultAfterEachTest();
});
afterAll(() => {
defaultAfterAllTests();
});