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.

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:

  1. checkout https://github.com/rburgst/jest-typescript-inline

  2. install dependencies

    yarn install
    
  3. run the tests

    npx jest
    
  4. remember the following line in async-test.ts

    it("leaves my async alone", async (done) => {
    
  5. update the snapshot using

    npx jest -u 
    
  6. 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:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Oct 11, 2018

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

0reactions
github-actions[bot]commented, May 12, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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