mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Fail test if it 'console.error's (#16116)
* Fail test if it 'console.error's * oneOf -> oneOfType * Fix react-color console.error
This commit is contained in:
parent
88ed489e2a
commit
7b0b381684
5 changed files with 17 additions and 4 deletions
|
@ -23,7 +23,8 @@
|
|||
},
|
||||
"setupFiles": [
|
||||
"<rootDir>/src/dev/jest/setup/babel_polyfill.js",
|
||||
"<rootDir>/src/dev/jest/setup/enzyme.js"
|
||||
"<rootDir>/src/dev/jest/setup/enzyme.js",
|
||||
"<rootDir>/src/dev/jest/setup/throw_on_console_error.js"
|
||||
],
|
||||
"coverageDirectory": "<rootDir>/target/jest-coverage",
|
||||
"coverageReporters": [
|
||||
|
|
5
src/dev/jest/setup/throw_on_console_error.js
Normal file
5
src/dev/jest/setup/throw_on_console_error.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
// Fail if a test ends up `console.error`-ing, e.g. if React logs because of a
|
||||
// failed prop types check.
|
||||
console.error = message => {
|
||||
throw new Error(message);
|
||||
};
|
|
@ -11,6 +11,13 @@ let onChange;
|
|||
|
||||
beforeEach(() => {
|
||||
onChange = sinon.spy();
|
||||
|
||||
// There's a `console.error` within `react-color`, so we're just "hiding it"
|
||||
sinon.stub(console, 'error');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
console.error.restore();
|
||||
});
|
||||
|
||||
test('renders KuiColorPicker', () => {
|
||||
|
|
|
@ -127,7 +127,7 @@ export function KuiListingTable({
|
|||
|
||||
KuiListingTable.propTypes = {
|
||||
header: PropTypes.arrayOf(
|
||||
PropTypes.oneOf([
|
||||
PropTypes.oneOfType([
|
||||
PropTypes.node,
|
||||
PropTypes.shape({
|
||||
content: PropTypes.node,
|
||||
|
@ -141,7 +141,7 @@ KuiListingTable.propTypes = {
|
|||
rows: PropTypes.arrayOf(PropTypes.shape({
|
||||
id: PropTypes.string,
|
||||
cells: PropTypes.arrayOf(
|
||||
PropTypes.oneOf([
|
||||
PropTypes.oneOfType([
|
||||
PropTypes.node,
|
||||
PropTypes.shape({
|
||||
content: PropTypes.node,
|
||||
|
|
|
@ -55,7 +55,7 @@ KuiListingTableRow.propTypes = {
|
|||
row: PropTypes.shape({
|
||||
id: PropTypes.string,
|
||||
cells: PropTypes.arrayOf(
|
||||
PropTypes.oneOf([
|
||||
PropTypes.oneOfType([
|
||||
PropTypes.node,
|
||||
PropTypes.shape({
|
||||
content: PropTypes.node,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue