Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const DEFAULT_PROJECT_CONFIG: ProjectConfig = {
modulePathIgnorePatterns: [],
modulePaths: [],
name: 'test_name',
prettier: 'prettier',
prettierPath: 'prettier',
resetMocks: false,
resetModules: false,
resolver: null,
Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ Presets may also be relative filesystem paths.
}
```

### `prettier` [string]
### `prettierPath` [string]

Default: `'prettier'`

Expand Down
2 changes: 1 addition & 1 deletion docs/SnapshotTesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Inline snapshots behave identically to external snapshots (`.snap` files), excep

> Inline snapshots are powered by [Prettier](https://prettier.io). To use inline snapshots you must have `prettier` installed in your project. Your Prettier configuration will be respected when writing to test files.
>
> If you have `prettier` installed in a location where Jest can't find it, you can tell Jest how to find it using the [`"prettier"`](./Configuration.md#prettier-string) configuration property.
> If you have `prettier` installed in a location where Jest can't find it, you can tell Jest how to find it using the [`"prettierPath"`](./Configuration.md#prettierpath-string) configuration property.

**Example:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export const initialize = ({
const {expand, updateSnapshot} = globalConfig;
const snapshotState = new SnapshotState(testPath, {
expand,
getPrettier: () => (config.prettier ? localRequire(config.prettier) : null),
getPrettier: () =>
config.prettierPath ? localRequire(config.prettierPath) : null,
updateSnapshot,
});
setState({snapshotState, testPath});
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/cli/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export const options = {
description: "A preset that is used as a base for Jest's configuration.",
type: 'string',
},
prettier: {
prettierPath: {
default: 'prettier',
description: 'The path to the "prettier" module used for inline snapshots.',
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default ({
notify: false,
notifyMode: 'always',
preset: null,
prettier: 'prettier',
prettierPath: 'prettier',
projects: null,
resetMocks: false,
resetModules: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const getConfigs = (
modulePathIgnorePatterns: options.modulePathIgnorePatterns,
modulePaths: options.modulePaths,
name: options.name,
prettier: options.prettier,
prettierPath: options.prettierPath,
resetMocks: options.resetMocks,
resetModules: options.resetModules,
resolver: options.resolver,
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,10 @@ export default function normalize(options: InitialOptions, argv: Argv) {
rootDir: options.rootDir,
});
break;
case 'prettier':
// We only want this to throw if "prettier" is explicitly passed from
// config or CLI, and the requested path isn't found. Otherwise we set
// it to null and throw an error lazily when it is used.
case 'prettierPath':
// We only want this to throw if "prettierPath" is explicitly passed
// from config or CLI, and the requested path isn't found. Otherwise we
// set it to null and throw an error lazily when it is used.
value =
options[key] &&
resolve(newOptions.resolver, {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/valid_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default ({
notifyMode: 'always',
onlyChanged: false,
preset: 'react-native',
prettier: '<rootDir>/node_modules/prettier',
prettierPath: '<rootDir>/node_modules/prettier',
projects: ['project-a', 'project-b/'],
reporters: [
'default',
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-jasmine2/src/setup_jest_globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export default ({
const {expand, updateSnapshot} = globalConfig;
const snapshotState = new SnapshotState(testPath, {
expand,
getPrettier: () => (config.prettier ? localRequire(config.prettier) : null),
getPrettier: () =>
config.prettierPath ? localRequire(config.prettierPath) : null,
updateSnapshot,
});
setState({snapshotState, testPath});
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-validate/src/__tests__/fixtures/jest_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const defaultConfig = {
notify: false,
notifyMode: 'always',
preset: null,
prettier: 'prettier',
prettierPath: 'prettier',
resetMocks: false,
resetModules: false,
restoreMocks: false,
Expand Down Expand Up @@ -100,7 +100,7 @@ const validConfig = {
notify: false,
notifyMode: 'always',
preset: 'react-native',
prettier: '<rootDir>/node_modules/prettier',
prettierPath: '<rootDir>/node_modules/prettier',
resetMocks: false,
resetModules: false,
restoreMocks: false,
Expand Down
6 changes: 3 additions & 3 deletions types/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type DefaultOptions = {|
notify: boolean,
notifyMode: string,
preset: ?string,
prettier: ?string,
prettierPath: ?string,
projects: ?Array<string | ProjectConfig>,
resetMocks: boolean,
resetModules: boolean,
Expand Down Expand Up @@ -136,7 +136,7 @@ export type InitialOptions = {
passWithNoTests?: boolean,
preprocessorIgnorePatterns?: Array<Glob>,
preset?: ?string,
prettier?: ?string,
prettierPath?: ?string,
projects?: Array<Glob>,
replname?: ?string,
resetMocks?: boolean,
Expand Down Expand Up @@ -261,7 +261,7 @@ export type ProjectConfig = {|
modulePathIgnorePatterns: Array<string>,
modulePaths: Array<string>,
name: string,
prettier: string,
prettierPath: string,
resetMocks: boolean,
resetModules: boolean,
resolver: ?Path,
Expand Down
1 change: 0 additions & 1 deletion types/HasteMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export type RawModuleMap = {|
mocks: MockData,
|};

// prettier-ignore
export type FileMetaData = [
/* id */ string,
/* mtime */ number,
Expand Down