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

This commit is contained in:
Zoltán Bedi 2021-11-02 08:38:46 +01:00 committed by GitHub
parent 231f17ab20
commit 85f2c48448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -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');

View File

@ -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', () => {