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:
- Create react app with typescript template (this is my env but I haven’t tested without typescript)
yarn create react-app --template typescript
- Write a test that generates a snapshot
// App.test.tsx
test('matches snapshot', () => {
const { container } = render(<App />);
expect(container).toMatchInlineSnapshot();
});
- Add prettier@2.0.5 and run test : it works
yarn add prettier@2.0.5 -D
yarn test
- 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:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
2.1.1 is released and updating fixes the reproduction in the OP. Thanks!
The only
loc
I removed from https://github.com/prettier/prettier/pull/8678 is fortypescript
parser, so for a quick fix, we may just need add this line backSome other part in Prettier updates the range, so the location info still not “real”, but it works that way before too.