Giter Site home page Giter Site logo

jest-flow-prettier-issue's Introduction

Jest Bug Repro

When updating inline snapshots Jest applies Prettier. Unfortunatly with Flow files, Jest disregards the parser defined in the user's Pretteir config and instead uses an infered one for that file.

In the case of Flow files, Jest seems to pick incorrectly, and instead uses babel.

This leads prettier to think it's okay to remove quotes around numeric object keys.

Note that Prettier never unquotes numeric property names in Angular expressions, TypeScript, and Flow because the distinction between string and numeric keys is significant in these languages

-- Prettier Docs

The result is that Jest writes back a snapshot file which Prettier cannot parse, and so even subsequent Prettier runs cannot restore the file to a parseable state.

The only recourse is to manually update all numeric keys in the test file (and to be very careful not to ever update the inline snapshot automatically ever again).

The bug is caused on this line of jest-snapshot where the infered parser is prefered over one explcitly defined in the config.

Repro

yarn
yarn repro # jest -u

Expected

The snapshot updates and the rest of the file is left untouched.

Actual

The snapshot updates and line 3 of test.js is updated to remove the quotes. Now Flow can't parse that file.

jest-flow-prettier-issue's People

Contributors

captbaritone avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.