Excited about the new snapshot testing! I tried to set it up, and it runs, but for some reason the generated snapshot file (and diff when the test fails) is shown as an object, rather than pretty-formatted like in the blog post.
"jest": "^14.1.0",
"babel-jest": "^14.1.0",
"react-test-renderer": "^15.3.0",
"react": "^15.3.0"
{
"automock": false,
"scriptPreprocessor": "<rootDir>/config/jest/transform.js",
"testEnvironment": "node"
}
exports[`test LoginLink renders correctly 1`] = `
{
"_component": {
"_calledComponentWillUnmount": false,
"_compositeType": 0,
"_context": Object {},
"_currentElement": Object {
"$$typeof": Symbol(react.element),
"_owner": null,
"_store": Object {},
"key": null,
"props": Object {
"$$typeof": Symbol(react.element),
"_owner": null,
"_store": Object {},
"key": null,
"props": Object {},
"ref": null,
"type": [Function LoginLink]
},
"ref": null,
"type": [Function anonymous]
},
"_debugID": 0,
"_hostContainerInfo": null,
"_hostParent": null,
"_instance": {
"_reactInternalInstance": [Circular],
"context": Object {},
"props": Object {
"$$typeof": Symbol(react.element),
"_owner": null,
"_store": Object {},
"key": null,
"props": Object {},
"ref": null,
"type": [Function LoginLink]
},
"refs": Object {},
"state": null,
"updater": Object {
"enqueueCallback": [Function anonymous],
"enqueueCallbackInternal": [Function anonymous],
"enqueueElementInternal": [Function anonymous],
"enqueueForceUpdate": [Function anonymous],
"enqueueReplaceState": [Function anonymous],
"enqueueSetState": [Function anonymous],
"isMounted": [Function anonymous],
"validateCallback": [Function anonymous]
}
},
"_mountImage": null,
"_mountIndex": 0,
"_mountOrder": 1,
"_pendingCallbacks": null,
"_pendingElement": null,
"_pendingForceUpdate": false,
"_pendingReplaceState": false,
"_pendingStateQueue": null,
"_renderedComponent": {
"_calledComponentWillUnmount": false,
"_compositeType": 2,
"_context": Object {},
"_currentElement": Object {
"$$typeof": Symbol(react.element),
"_owner": null,
"_store": Object {},
"key": null,
"props": Object {},
"ref": null,
"type": [Function LoginLink]
},
"_debugID": 1,
"_hostContainerInfo": null,
"_hostParent": null,
"_instance": StatelessComponent {
"_reactInternalInstance": [Circular],
"context": Object {},
"props": Object {},
"refs": Object {},
"state": null,
"updater": Object {
"enqueueCallback": [Function anonymous],
"enqueueCallbackInternal": [Function anonymous],
"enqueueElementInternal": [Function anonymous],
"enqueueForceUpdate": [Function anonymous],
"enqueueReplaceState": [Function anonymous],
"enqueueSetState": [Function anonymous],
"isMounted": [Function anonymous],
"validateCallback": [Function anonymous]
}
},
"_mountImage": null,
"_mountIndex": 0,
"_mountOrder": 2,
"_pendingCallbacks": null,
"_pendingElement": null,
"_pendingForceUpdate": false,
"_pendingReplaceState": false,
"_pendingStateQueue": null,
"_renderedComponent": {
"_currentElement": Object {
"$$typeof": Symbol(react.element),
"_owner": [Circular],
"_store": Object {},
"key": null,
"props": Object {
"children": "Log in",
"href": "/auth/google"
},
"ref": null,
"type": "a"
},
"_debugID": 2,
"_mountImage": null,
"_mountIndex": 0,
"_renderedChildren": Object {
".0": {
"_currentElement": "Log in",
"_debugID": 3,
"_mountImage": null,
"_mountIndex": 0
}
},
"_topLevelWrapper": null
},
"_renderedNodeType": 0,
"_rootNodeID": null,
"_topLevelWrapper": [Circular],
"_updateBatchNumber": null,
"_warnedAboutRefsInRender": false
},
"_renderedNodeType": 1,
"_rootNodeID": null,
"_topLevelWrapper": null,
"_updateBatchNumber": null,
"_warnedAboutRefsInRender": false
}
}
`;
Excited about the new snapshot testing! I tried to set it up, and it runs, but for some reason the generated snapshot file (and diff when the test fails) is shown as an object, rather than pretty-formatted like in the blog post.
Packages:
My config:
config/jest/transform.js:
babel.server:
LoginLink component:
Test:
Snapshot: