Chore: Enable jest-fail-on-console to prevent console errors in unit tests (#46835)

* Add jest-fail-on-console

* Fix last 2 console warnings

* Update package syntax
This commit is contained in:
Ashley Harrison
2022-03-22 17:03:07 +00:00
committed by GitHub
parent ba62f5ad5d
commit 04bbafb4a6
5 changed files with 26 additions and 0 deletions

View File

@@ -506,8 +506,10 @@ describe('DashboardModel', () => {
describe('Given model with time', () => {
let model: DashboardModel;
let consoleWarnSpy: jest.SpyInstance;
beforeEach(() => {
consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
model = new DashboardModel({
time: {
from: 'now-6h',
@@ -521,6 +523,10 @@ describe('DashboardModel', () => {
};
});
afterEach(() => {
consoleWarnSpy.mockRestore();
});
it('hasTimeChanged should be true', () => {
expect(model.hasTimeChanged()).toBeTruthy();
});

View File

@@ -37,6 +37,11 @@ jest.mock('../hooks/usePluginConfig.tsx', () => ({
})),
}));
jest.mock('../helpers.ts', () => ({
...jest.requireActual('../helpers.ts'),
updatePanels: jest.fn(),
}));
const renderPluginDetails = (
pluginOverride: Partial<CatalogPlugin>,
{