mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
fail tests if warning is logged
This commit is contained in:
parent
0185269d97
commit
09751efe95
@ -730,10 +730,6 @@ describe('<ScheduleForm />', () => {
|
||||
);
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
wrapper.find('DatePicker[aria-label="End date"]').simulate('blur');
|
||||
});
|
||||
|
||||
wrapper.update();
|
||||
expect(wrapper.find('#schedule-End-datetime-helper').text()).toBe(
|
||||
'Please select an end date/time that comes after the start date/time.'
|
||||
|
||||
@ -14,8 +14,9 @@ require('@nteract/mockument');
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const asyncFlush = () => new Promise(resolve => setImmediate(resolve));
|
||||
|
||||
let consoleHasError = false;
|
||||
const { error } = global.console;
|
||||
let hasConsoleError = false;
|
||||
let hasConsoleWarn = false;
|
||||
const { error, warn } = global.console;
|
||||
|
||||
global.console = {
|
||||
...console,
|
||||
@ -25,16 +26,24 @@ global.console = {
|
||||
// fail tests that log errors.
|
||||
// adapted from https://github.com/facebook/jest/issues/6121#issuecomment-708330601
|
||||
error: (...args) => {
|
||||
consoleHasError = true;
|
||||
hasConsoleError = true;
|
||||
error(...args);
|
||||
},
|
||||
warn: (...args) => {
|
||||
hasConsoleWarn = true;
|
||||
warn(...args);
|
||||
},
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
if (consoleHasError) {
|
||||
consoleHasError = false;
|
||||
if (hasConsoleError) {
|
||||
hasConsoleError = false;
|
||||
throw new Error('Error logged to console');
|
||||
}
|
||||
if (hasConsoleWarn) {
|
||||
hasConsoleWarn = false;
|
||||
throw new Error('Warning logged to console');
|
||||
}
|
||||
});
|
||||
|
||||
// This global variable is part of our Content Security Policy framework
|
||||
|
||||
@ -61,6 +61,7 @@ const defaultContexts = {
|
||||
session: {
|
||||
isSessionExpired: false,
|
||||
logout: () => {},
|
||||
setAuthRedirectTo: () => {},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user