Skip to content

More jest integration #10

Closed
Closed
@avocadowastaken

Description

@avocadowastaken

First of all I would like to thank you for your work!
It allowed me to decreased snapshot file size from 10k lines to 1.3k!

Add custom matcher

e.g. https://github.com/americanexpress/jest-image-snapshot#usage
See https://facebook.github.io/jest/docs/expect.html#expectextendmatchers
Usage:

expect(nextState).toMatchDiffSnapshot(prevState, { contextLines: 2 })

Add snapshot serializer based on input type

e.g. https://github.com/prettier/prettier/blob/master/tests_config/raw-serializer.js

Current output for object diffs is too noisy, so I had do implement custom serializer in my project, and now output changed from:

 Object {
   \\"bail\\": false,
   \\"context\\": \\".\\",
   \\"devServer\\": Object {
     \\"disableHostCheck\\": true,
-    \\"host\\": \\"localhost\\",
+    \\"host\\": \\"local.host\\",
     \\"hotOnly\\": true,
     \\"inline\\": true,
     \\"noInfo\\": true,
     \\"overlay\\": Object {
       \\"errors\\": true,
       \\"warnings\\": true,
     },
     \\"port\\": 3000,

To:

 Object {
   "bail": false,
   "context": ".",
   "devServer": Object {
     "disableHostCheck": true,
-    "host": "localhost",
+    "host": "local.host",
     "hotOnly": true,
     "inline": true,
     "noInfo": true,
     "overlay": Object {
       "errors": true,
       "warnings": true,
     },
     "port": 3000,

I would love to add PR with this changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions