Install jest
(it needs Jest 21+) and jest-runner-prettier
yarn add --dev jest jest-runner-prettier
# or with NPM
npm install --save-dev jest jest-runner-prettier
In your package.json
{
"jest": {
"runner": "jest-runner-prettier",
"moduleFileExtensions": [
"js",
"jsx",
"json",
"ts",
"tsx",
"css",
"less",
"scss",
"graphql",
"md",
"markdown"
],
"testMatch": [
"**/*.js",
"**/*.jsx",
"**/*.json",
"**/*.ts",
"**/*.tsx",
"**/*.css",
"**/*.less",
"**/*.scss",
"**/*.graphql",
"**/*.md",
"**/*.markdown"
]
}
}
Or in jest.config.js
module.exports = {
runner: "jest-runner-prettier",
moduleFileExtensions: [
"js",
"jsx",
"json",
"ts",
"tsx",
"css",
"less",
"scss",
"graphql",
"md",
"markdown"
],
testMatch: [
"**/*.js",
"**/*.jsx",
"**/*.json",
"**/*.ts",
"**/*.tsx",
"**/*.css",
"**/*.less",
"**/*.scss",
"**/*.graphql",
"**/*.md",
"**/*.markdown"
]
};
yarn jest