bun test toMatchInlineSnapshot
fails due to backtick string indentation
#16403
Labels
bug
Something isn't working
bun:test
Something related to the `bun test` runner
confirmed bug
We can reproduce this issue
What version of Bun is running?
1.1.44-canary.57+cc8ec65e3
What platform is your computer?
Darwin 23.6.0 arm64 arm
What steps can reproduce the bug?
I wanted to test the compatibility of
@apollo/server
with bun and wanted to try out bun's own jest compatible test runnerbun test
when i ran the tests, i've noticed tests failing that are using
.toMatchInlineSnapshot
matchers (which bun lists as implemented), that otherwise succeed in node.js with jest.Upon closer inspection, i've noticed that the "Expected" part of the failing tests are indented just like the given string in the test file, while the "Received" part shows the value as received with a different indentation. This indentation mismatch causes the test to fail, although it doesn't do that in jest.
for an example see the
errors.test.ts
in the apollo-server repository.https://github.com/apollographql/apollo-server/blob/a94828d0bca58ba862e9d02b06d076d478b98446/packages/server/src/__tests__/errors.test.ts#L120
To confirm this behavior, i've modified this file locally to put the backtick string at the very start of the line and further modified the indentation (2 spaces instead of 4 originally) to match the result output of
bun test
. The test then passes.What is the expected behavior?
.toMatchInlineSnapshot
should ignore indentation just like in jest. At very least when the string passed is a serialized JSON object like in the example.https://github.com/apollographql/apollo-server/blob/a94828d0bca58ba862e9d02b06d076d478b98446/packages/server/src/__tests__/errors.test.ts#L120
What do you see instead?
No response
Additional information
The text was updated successfully, but these errors were encountered: