28 lines
927 B
TypeScript
28 lines
927 B
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
import React from 'react';
|
|
|
|
/**
|
|
* Suppress React 16.8 act() warnings globally.
|
|
* The react teams fix won't be out of alpha until 16.9.0.
|
|
* https://github.com/facebook/react/issues/14769#issuecomment-514589856
|
|
*/
|
|
const consoleError = console.error; // eslint-disable-line no-console
|
|
beforeAll(() => {
|
|
jest.spyOn(console, 'error').mockImplementation((...args) => {
|
|
if (!args[0].includes('Warning: An update to %s inside a test was not wrapped in act')) {
|
|
consoleError(...args);
|
|
}
|
|
});
|
|
});
|
|
|
|
export function mockUseEffects(count = 1) {
|
|
const spy = jest.spyOn(React, 'useEffect');
|
|
for (let i = 0; i < count; i++) {
|
|
spy.mockImplementationOnce((f) => f());
|
|
}
|
|
}
|