updating an inline snapshot on a typescript file leads to wrong async syntax
See original GitHub issue🐛 Bug Report
When updating an inline snapshot on a typescript jest file that contains async calls, jest generates wrong syntax for async tests.
To Reproduce
Steps to reproduce the behavior:
-
install dependencies
yarn install
-
run the tests
npx jest
-
remember the following line in
async-test.ts
it("leaves my async alone", async (done) => {
-
update the snapshot using
npx jest -u
-
now check the line again
Expected behavior
The source code line
it("leaves my async alone", async (done) => {
should stay untouched.
Actual behavior
Line is rewritten to
it("leaves my async alone", async done => {
Link to repl or repo (highly encouraged)
Issues without a reproduction link are likely to stall.
Run npx envinfo --preset jest
Paste the results here:
npx: installed 1 in 2.269s
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 10.11.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npmPackages:
@types/jest: ^23.1.1 => 23.3.2
jest: * => 23.6.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Inline snapshots are not written to js files containing JSX ...
Regression Report Inline snapshots are not written to JavaScript files containing JSX syntax when the file is located in a subfolder.
Read more >Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >What's wrong with snapshot tests. Since snapshot ... - Medium
When you write expect(mycomponent).toMatchSnapshot() , Jest creates a snapshot file, like mytest.spec.js.snap , with all snapshots of your test file. You ...
Read more >Async/await in TypeScript - LogRocket Blog
Async /await simply enables you to write the code in a more synchronous manner and unwraps the promise in-line for you.
Read more >babel/plugin-transform-typescript
This plugin adds support for the types syntax used by the TypeScript ... You can set the sourceMaps: "inline" option in your babel.config.json...
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
You have to configure prettier to leave them alone: https://prettier.io/docs/en/options.html#arrow-function-parentheses. SO I think this is working as intended? Happy to reopen if not
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.