Jest: prettierPath only works via CLI option, not config

Created on 25 Nov 2018  路  4Comments  路  Source: facebook/jest

馃悰 Bug Report

When specifying the prettierPath option in a config file or JSON object, it is ignored. Jest prints the warning:

    Jest: Inline Snapshots requires Prettier.
    Please ensure "prettier" is installed in your project.

By putting a console.log in the module at the specified prettierPath, it is apparent that Jest never even attempts to import the supplied path. The value that eventually makes it to getPrettier() in the jest-jasmine2 package is null.

Using the same value with --prettierPath via the CLI works.

To Reproduce

Specify the prettierPath option in a config file or --config JSON object.

Expected behavior

The provided path will be used for Prettier.

Link to repl or repo (highly encouraged)

Please provide either a repl.it demo or a minimal repository on GitHub.

Issues without a reproduction link are likely to stall.

Run npx envinfo --preset jest

Paste the results here:

npx: installed 1 in 2.496s

  System:
    OS: macOS 10.14.1
    CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
  Binaries:
    Node: 8.9.4 - ~/.nvm/versions/node/v8.9.4/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v8.9.4/bin/npm
  npmPackages:
    jest: ^23.6.0 => 23.6.0

Most helpful comment

I refuse to believe this is intentional (if it is I'll argue against it), so PR very much welcome 馃檪

All 4 comments

It seems that argv has a default value for prettierPath and it overrides config file's prettierPath. I could do a PR, unless I am missing something and the default value is intentional.

Hmm, @azz is that intentional?

I refuse to believe this is intentional (if it is I'll argue against it), so PR very much welcome 馃檪

Definately not intentional

Was this page helpful?
0 / 5 - 0 ratings