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?