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:
Kim Joar Bekkelund 2018-01-18 18:08:00 +01:00 committed by GitHub
parent 88ed489e2a
commit 7b0b381684
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 4 deletions

View file

@ -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": [

View 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);
};

View file

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

View file

@ -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,

View file

@ -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,