Toolkit: Don't to show console errors in tests (#41078)

pull/41179/head
Zoltán Bedi 4 years ago committed by GitHub
parent 231f17ab20
commit 85f2c48448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      packages/grafana-toolkit/src/config/jest.plugin.config.test.ts
  2. 7
      packages/grafana-toolkit/src/config/webpack/loaders.test.ts

@ -1,7 +1,14 @@
import { jestConfig, allowedJestConfigOverrides } from './jest.plugin.config';
describe('Jest config', () => {
afterEach(() => {
jest.restoreAllMocks();
});
it('should throw if not supported overrides provided', () => {
// Do not show console error,log when running test
jest.spyOn(console, 'error').mockImplementation();
jest.spyOn(console, 'log').mockImplementation();
const getConfig = () => jestConfig(`${__dirname}/mocks/jestSetup/unsupportedOverrides`);
expect(getConfig).toThrow('Provided Jest config is not supported');

@ -2,11 +2,10 @@ import { getStylesheetEntries, hasThemeStylesheets } from './loaders';
describe('Loaders', () => {
describe('stylesheet helpers', () => {
const logSpy = jest.spyOn(console, 'log').mockImplementation();
jest.spyOn(console, 'log').mockImplementation();
afterAll(() => {
logSpy.mockRestore();
logSpy.mockRestore();
jest.restoreAllMocks();
});
describe('getStylesheetEntries', () => {
@ -24,10 +23,12 @@ describe('Loaders', () => {
describe('hasThemeStylesheets', () => {
it('throws when only one theme file is defined', () => {
jest.spyOn(console, 'error').mockImplementation();
const result = () => {
hasThemeStylesheets(`${__dirname}/../mocks/stylesheetsSupport/missing-theme-file`);
};
expect(result).toThrow();
jest.restoreAllMocks();
});
it('returns false when no theme files present', () => {

Loading…
Cancel
Save