mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
ba62f5ad5d
commit
04bbafb4a6
@ -195,6 +195,7 @@
|
||||
"jest": "27.5.0",
|
||||
"jest-canvas-mock": "2.3.1",
|
||||
"jest-date-mock": "1.0.8",
|
||||
"jest-fail-on-console": "2.3.0",
|
||||
"jest-junit": "13.0.0",
|
||||
"jest-matcher-utils": "27.5.0",
|
||||
"jest-mock-console": "1.2.3",
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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>,
|
||||
{
|
||||
|
@ -1,4 +1,8 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import failOnConsole from 'jest-fail-on-console';
|
||||
import { matchers } from './matchers';
|
||||
|
||||
failOnConsole({
|
||||
shouldFailOnLog: true,
|
||||
});
|
||||
expect.extend(matchers);
|
||||
|
10
yarn.lock
10
yarn.lock
@ -20933,6 +20933,7 @@ __metadata:
|
||||
jest: 27.5.0
|
||||
jest-canvas-mock: 2.3.1
|
||||
jest-date-mock: 1.0.8
|
||||
jest-fail-on-console: 2.3.0
|
||||
jest-junit: 13.0.0
|
||||
jest-matcher-utils: 27.5.0
|
||||
jest-mock-console: 1.2.3
|
||||
@ -23609,6 +23610,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"jest-fail-on-console@npm:2.3.0":
|
||||
version: 2.3.0
|
||||
resolution: "jest-fail-on-console@npm:2.3.0"
|
||||
dependencies:
|
||||
chalk: ^4.1.0
|
||||
checksum: b0ce97a5f6bc11226a1eecb9406c98e42ce5e7197310019f3cb27495b43cc1d01aaee36b094ea46a23deffcb62b246ddccd5dfdefe525b72d8dad2c9f1f634ee
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"jest-get-type@npm:^26.3.0":
|
||||
version: 26.3.0
|
||||
resolution: "jest-get-type@npm:26.3.0"
|
||||
|
Loading…
Reference in New Issue
Block a user