Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Custom snapshot serializer not used when reporting error diffs #15386

Open
danfuzz opened this issue Nov 22, 2024 · 0 comments
Open

[Bug]: Custom snapshot serializer not used when reporting error diffs #15386

danfuzz opened this issue Nov 22, 2024 · 0 comments

Comments

@danfuzz
Copy link

danfuzz commented Nov 22, 2024

Version

29.7.0

Steps to reproduce

  1. Unpack this tarball: 2024-danfuzz-jest-demo.tar.gz
  2. npm install
  3. npm test

Expected behavior

I expect to see the custom serializer used when displaying the diffs between the expected and received values in the second test case (test('fails, thereby demonstrating the problem', ...)). In this case it should probably look like this:

    - Expected  - 2
    + Received  + 2

      new SomeClass(
    -   "zorch",
    -   "florp")
    +   "foo",
    +   "bar")

Actual behavior

The custom serializer is ignored. The salient part of the reported error looks like this, which is unfortunately not very helpful:

    Expected: {}
    Received: serializes to the same string

Additional context

I tried adding the custom serializer both via the config file (snapshotSerializers) and using expect.addSnapshotSerializer() in the test file. Neither seems to work.

The first test in example.test.js is there to demonstrate that the serializer is indeed hooked up.

In case it's useful, here's the example tarball in base64-encoded form:

H4sIAFLSQGcAA+1cS2/bRhBWixZF1XN7LBbqQRKiUHzTsuECTmogLvJ20gfS1l5JS4kOxW
V2KUd14P/Re/9F7732zxS9Fp3lQ5Jp05JjhWmi/QBC1HI4nN3l7M7nGUtXdfNmHwfu+OTk
5hHh0c0+GdF2ZZVQVdWxLBR/2sknPDX5TIE009FVzdI0VUPwaetWBVkrtaIAYx5hBqakY1
AoB2Kue4metB/Tz3cE+sXzrxyIc6VHA9cbKEf8Ws+A8bBNs3j+ddNI5990hICqq7YB86+u
qI+XYs3nv/LxF59UPqxU7uEeerCPfkApRFvlUzh0OF7AIb7/vpzKnSdPHqen4o7f4PgsJ/
LBrP3zHh0pOAx9ooSMHpMABz0iBP7+548v//roz39X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node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - /opt/homebrew/bin/npm
  npmPackages:
    jest: ^29.7.0 => 29.7.0
@danfuzz danfuzz changed the title [Bug]: [Bug]: Custom snapshot serializer not used when reporting error diffs Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant