question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline snapshot are broken when using latest prettier (2.1.0)

See original GitHub issue

🐛 Bug Report

When using expect.toMatchInlineSnapshot using prettier 2.1.0, jest throws the following error:

 FAIL  src/App.test.tsx
  ● Test suite failed to run

    TypeError: Cannot read property 'start' of undefined

      at CallExpression (node_modules/jest-snapshot/build/inline_snapshots.js:217:57)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        4.224s
Ran all test suites related to changed files.

Watch Usage: Press w to show more.

To Reproduce

Steps to reproduce the behavior:

  1. Create react app with typescript template (this is my env but I haven’t tested without typescript)
yarn create react-app --template typescript
  1. Write a test that generates a snapshot
// App.test.tsx
test('matches snapshot', () => {
  const { container } = render(<App />);
  expect(container).toMatchInlineSnapshot();
});
  1. Add prettier@2.0.5 and run test : it works
yarn add prettier@2.0.5 -D
yarn test
  1. Remove snasphot, add prettier@2.1.0 and run test : it throws an error
yarn add prettier@2.1.0 -D
yarn test

Expected behavior

Test should write a new snapshot like at step 3.

Link to repl or repo (highly encouraged)

https://www.github.com/iwazaru/jest-inline-snapshot-bug

envinfo

  System:
    OS: macOS 10.15.6
    CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
  Binaries:
    Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.7 - ~/.nvm/versions/node/v12.18.3/bin/npm

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
SimenBcommented, Aug 26, 2020

2.1.1 is released and updating fixes the reproduction in the OP. Thanks!

1reaction
fiskercommented, Aug 25, 2020

The only loc I removed from https://github.com/prettier/prettier/pull/8678 is for typescript parser, so for a quick fix, we may just need add this line back

Some other part in Prettier updates the range, so the location info still not “real”, but it works that way before too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prettierx | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
all documented artifacts — cljdoc
cerber/cerber-oauth2-provider 2.1.0-SNAPSHOT. more versions ... clojure-interop/org.datavec.api.split 1.0.0 ... com.github.seancorfield/clj-new 1.2.399.
Read more >
Untitled
use -fPIC, not -fpic, also -DUSE_SEMAPHORE to make it thread safe, as per bug #20935 - use -fpic ... Converted users of ebitmaps...
Read more >
Untitled
(RH Bug #130029) - Update to new 0.22 release - Added BuildRequires for ... rebuilt for new gcc4.1 snapshot and glibc changes -...
Read more >
Prettier 2.6: new singleAttributePerLine option and new ...
We've updated the version of TypeScript that we use to parse TS code to TypeScript 4.6. However, no new syntax was added in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found