I get the below error; Expected onBeforeMountComponent() parent and onSetChildren() to be consistent. according to https://github.com/facebook/react/issues/8692 This will be a non issue in React 16. I'm using Enzyme for this test suite, so I can't upgrade to the latest React Native untile Enzyme supports React 16.
I wanted to suppress the error for now, and I noticed something strange:
The test results get posted to stderr instead of stdout and when I turn on verbose logging it get even stranger, stdout gets the errors and most of what I would expect in stdout gets logged to stderr?
(the failing test and console log are on purpose)
The full output of my test:
$ npm test -- --coverage
> App@ test /media/dev/app
> jest "--coverage"
FAIL core/tests/components/settings.js
โ Console
console.error node_modules/react-native/Libraries/Core/ExceptionsManager.js:71
Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
console.error node_modules/react-native/Libraries/Core/ExceptionsManager.js:71
Warning: Exception thrown by hook while handling onSetChildren: Invariant Violation: Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (7 has parents 0 and 5).
Invariant Violation: Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (7 has parents 0 and 5).
at invariant (/media/dj/dev/scan-app/node_modules/fbjs/lib/invariant.js:44:15)
at Object.onSetChildren (/media/dj/dev/scan-app/node_modules/react/lib/ReactComponentTreeHook.js:186:78)
at callHook (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:27:8)
at emitEvent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:39:7)
at Object.onSetChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:311:5)
at ReactTestComponent.setChildrenForInstrumentation (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:157:38)
at ReactTestComponent._updateChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:360:39)
at ReactTestComponent.updateChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:299:12)
at ReactTestComponent.receiveComponent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactTestRenderer.js:68:10)
at Object.receiveComponent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactReconciler.js:125:22)
console.log core/tests/components/settings.js:97
[ 1, 3, 2 ]
โ settings functions work as expected โบ Settings.getAllSelected(product) works as expected
expect(received).toEqual(expected)
Expected value to equal:
false
Received:
true
at Object.<anonymous> (core/tests/components/settings.js:99:35)
PASS src/tests/view-test.js
PASS core/tests/components/details.js
PASS core/tests/components/scan.js
PASS core/tests/components/search.js
PASS core/tests/components/login.js
PASS core/tests/helpers/collections.js
PASS core/tests/helpers/search-guests.js
PASS core/tests/helpers/urls-dev.js
PASS core/tests/components/init.js
PASS core/tests/helpers/urls-prod.js
=============================== Coverage summary ===============================
Statements : 43.59% ( 558/1280 )
Branches : 33.72% ( 175/519 )
Functions : 50% ( 227/454 )
Lines : 49.26% ( 467/948 )
================================================================================
Test Suites: 1 failed, 10 passed, 11 total
Tests: 1 failed, 1 skipped, 34 passed, 36 total
Snapshots: 13 passed, 13 total
Time: 5.437s
Ran all test suites.
npm ERR! Test failed. See above for more details.
only stdout:
$ npm test -- --coverage 2>/dev/null
> App@ test /media/dev/app
> jest "--coverage"
Determining test suites to run...
=============================== Coverage summary ===============================
Statements : 43.59% ( 558/1280 )
Branches : 33.72% ( 175/519 )
Functions : 50% ( 227/454 )
Lines : 49.26% ( 467/948 )
================================================================================
only stderr:
$ npm test -- --coverage 1>/dev/null
FAIL core/tests/components/settings.js
โ Console
console.error node_modules/react-native/Libraries/Core/ExceptionsManager.js:71
Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
console.error node_modules/react-native/Libraries/Core/ExceptionsManager.js:71
Warning: Exception thrown by hook while handling onSetChildren: Invariant Violation: Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (7 has parents 0 and 5).
Invariant Violation: Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (7 has parents 0 and 5).
at invariant (/media/dj/dev/scan-app/node_modules/fbjs/lib/invariant.js:44:15)
at Object.onSetChildren (/media/dj/dev/scan-app/node_modules/react/lib/ReactComponentTreeHook.js:186:78)
at callHook (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:27:8)
at emitEvent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:39:7)
at Object.onSetChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:311:5)
at ReactTestComponent.setChildrenForInstrumentation (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:157:38)
at ReactTestComponent._updateChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:360:39)
at ReactTestComponent.updateChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:299:12)
at ReactTestComponent.receiveComponent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactTestRenderer.js:68:10)
at Object.receiveComponent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactReconciler.js:125:22)
console.log core/tests/components/settings.js:97
[ 1, 3, 2 ]
โ settings functions work as expected โบ Settings.getAllSelected(product) works as expected
expect(received).toEqual(expected)
Expected value to equal:
false
Received:
true
at Object.<anonymous> (core/tests/components/settings.js:99:35)
PASS src/tests/view-test.js
PASS core/tests/components/search.js
PASS core/tests/components/details.js
PASS core/tests/components/scan.js
PASS core/tests/components/login.js
PASS core/tests/helpers/collections.js
PASS core/tests/helpers/search-guests.js
PASS core/tests/helpers/urls-dev.js
PASS core/tests/components/init.js
PASS core/tests/helpers/urls-prod.js
Test Suites: 1 failed, 10 passed, 11 total
Tests: 1 failed, 1 skipped, 34 passed, 36 total
Snapshots: 13 passed, 13 total
Time: 5.985s
Ran all test suites.
npm ERR! Test failed. See above for more details.
even more strange, when I turn on verbose the error gets logged to stdout..
$ npm test -- --coverage --verbose 2>/dev/null
> Chipta@ test /media/dj/dev/scan-app
> jest "--coverage" "--verbose"
console.error node_modules/react-native/Libraries/Core/ExceptionsManager.js:71
Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
console.error node_modules/react-native/Libraries/Core/ExceptionsManager.js:71
Warning: Exception thrown by hook while handling onSetChildren: Invariant Violation: Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (7 has parents 0 and 5).
Invariant Violation: Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (7 has parents 0 and 5).
at invariant (/media/dj/dev/scan-app/node_modules/fbjs/lib/invariant.js:44:15)
at Object.onSetChildren (/media/dj/dev/scan-app/node_modules/react/lib/ReactComponentTreeHook.js:186:78)
at callHook (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:27:8)
at emitEvent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:39:7)
at Object.onSetChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactDebugTool.js:311:5)
at ReactTestComponent.setChildrenForInstrumentation (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:157:38)
at ReactTestComponent._updateChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:360:39)
at ReactTestComponent.updateChildren (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactMultiChild.js:299:12)
at ReactTestComponent.receiveComponent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactTestRenderer.js:68:10)
at Object.receiveComponent (/media/dj/dev/scan-app/node_modules/react-test-renderer/lib/ReactReconciler.js:125:22)
console.log core/tests/components/settings.js:97
[ 1, 3, 2 ]
=============================== Coverage summary ===============================
Statements : 43.59% ( 558/1280 )
Branches : 33.72% ( 175/519 )
Functions : 50% ( 227/454 )
Lines : 49.26% ( 467/948 )
================================================================================
$ npm test -- --coverage --verbose 1>/dev/null
FAIL core/tests/components/settings.js
โ settings functions work as expected โบ Settings.getAllSelected(product) works as expected
expect(received).toEqual(expected)
Expected value to equal:
false
Received:
true
at Object.<anonymous> (core/tests/components/settings.js:99:35)
Settings renders correctly
โ without event (32ms)
โ with event (30ms)
settings functions work as expected
โ Settings.selectEventProduct(product) adds product as expected (22ms)
โ Settings.selectEventProduct(product) removes product as expected (18ms)
โ Settings.getSelected(product) works as expected (9ms)
โ Settings.getAllSelected(product) works as expected (28ms)
โ Settings.selectAll() works as expected (20ms)
โ skipped 1 test
PASS src/tests/view-test.js
โ LoginView renders correctly (39ms)
โ SettingsView renders correctly (10ms)
โ DrawerView renders correctly (65ms)
โ ScanView renders correctly (4ms)
โ ResultView renders correctly (17ms)
โ DetailsView renders correctly (19ms)
PASS core/tests/components/details.js
โ Details renderers correctly (47ms)
PASS core/tests/components/scan.js
โ Scan renderers correctly (22ms)
PASS core/tests/components/login.js
โ Login renders correctly (19ms)
PASS core/tests/components/search.js
โ Search renderers correctly (14ms)
PASS core/tests/helpers/collections.js
models are created as expected
โ event is created properly (2ms)
โ guest is created properly (1ms)
โ event product is created properly
โ guest product is created properly (1ms)
guest functions work as expected
โ guest.getFullName() returns full name of user (1ms)
โ guest.getFullName() returns email of guest if no name is found (1ms)
โ guest.getTotals() returns [used products, total products] (2ms)
guest product functions work as expected
โ guestProduct.isValid() checks if the product is valid (1ms)
โ guestProduct.confirm(eventId, status) sets last use time on product (3ms)
PASS core/tests/helpers/search-guests.js
searchGuests works as expected
โ searchGuests works as expected without searchTerm (1ms)
โ searchGuests works as expected with name (3ms)
โ searchGuests works as expected with barcode (2ms)
PASS core/tests/helpers/urls-dev.js
โ makeGuestProductUrl works as expected
URLconfig is correct for dev
โ ajaxURL
โ socketURL (1ms)
PASS core/tests/components/init.js
โ Init renders correctly (5ms)
PASS core/tests/helpers/urls-prod.js
URLconfig is correct for prod
โ ajaxURL
โ socketURL
Test Suites: 1 failed, 10 passed, 11 total
Tests: 1 failed, 1 skipped, 34 passed, 36 total
Snapshots: 13 passed, 13 total
Time: 5.485s
Ran all test suites.
npm ERR! Test failed. See above for more details.
This is how it works in Jest and it's not a bug.
pass or fail is not error, it is expected output.
error is error, not expected output.
I can only find it strange.
Is there documentation on this I could read?
Most helpful comment
pass or fail is not error, it is expected output.
error is error, not expected output.
I can only find it strange.
Is there documentation on this I could read?