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