Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keplersj/jest-runner-prettier
Prettier runner for Jest
https://github.com/keplersj/jest-runner-prettier
css flowtype graphql javascript jest json linter markdown prettier typescript
Last synced: 3 months ago
JSON representation
Prettier runner for Jest
- Host: GitHub
- URL: https://github.com/keplersj/jest-runner-prettier
- Owner: keplersj
- Created: 2017-11-14T04:16:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-30T00:28:52.000Z (3 months ago)
- Last Synced: 2024-07-30T05:12:24.925Z (3 months ago)
- Topics: css, flowtype, graphql, javascript, jest, json, linter, markdown, prettier, typescript
- Language: TypeScript
- Homepage: https://keplersj.com/projects/jest-runner-prettier/
- Size: 2.47 MB
- Stars: 91
- Watchers: 4
- Forks: 11
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- awesome-jest - jest-runner-prettier
README
[![npm](https://img.shields.io/npm/v/jest-runner-prettier)](https://www.npmjs.com/package/jest-runner-prettier)
[![npm](https://img.shields.io/npm/dw/jest-runner-prettier)](https://www.npmjs.com/package/jest-runner-prettier)
[![Codecov](https://img.shields.io/codecov/c/github/keplersj/jest-runner-prettier)](https://app.codecov.io/gh/keplersj/jest-runner-prettier)
[![Bundle Size](https://img.shields.io/bundlephobia/min/jest-runner-prettier)](https://bundlephobia.com/package/jest-runner-prettier)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://www.conventionalcommits.org/)
[![Mentioned in Awesome Jest](https://awesome.re/mentioned-badge.svg)](https://github.com/jest-community/awesome-jest)
## Usage
### Install
Install `jest`, `prettier` and `jest-runner-prettier`
```bash
yarn add --dev jest prettier jest-runner-prettier# or with NPM
npm install --save-dev jest prettier jest-runner-prettier
```### Add it to your Jest config
#### Using Built-in Preset
This package includes a [Jest preset](https://jestjs.io/docs/en/configuration#preset-string) which configures Jest to run Prettier on all files supported by Prettier. To use it set the following in your `package.json`:
```json
{
"jest": {
"preset": "jest-runner-prettier"
}
}
```or `jest.config.js`:
```js
module.exports = {
preset: "jest-runner-prettier",
};
```#### Manually
In your `package.json`
```json
{
"jest": {
"runner": "prettier",
"moduleFileExtensions": [
"js",
"mjs",
"jsx",
"vue",
"ts",
"tsx",
"css",
"less",
"scss",
"html",
"json",
"graphql",
"md",
"markdown",
"mdx",
"yaml",
"yml"
],
"testMatch": [
"**/*.js",
"**/*.mjs",
"**/*.jsx",
"**/*.vue",
"**/*.ts",
"**/*.tsx",
"**/*.css",
"**/*.less",
"**/*.scss",
"**/*.html",
"**/*.json",
"**/*.graphql",
"**/*.md",
"**/*.markdown",
"**/*.mdx",
"**/*.yaml",
"**/*.yml"
]
}
}
```Or in `jest.config.js`
```js
module.exports = {
runner: "prettier",
moduleFileExtensions: [
"js",
"mjs",
"jsx",
"vue",
"ts",
"tsx",
"css",
"less",
"scss",
"html",
"json",
"graphql",
"md",
"markdown",
"mdx",
"yaml",
"yml",
],
testMatch: [
"**/*.js",
"**/*.mjs",
"**/*.jsx",
"**/*.vue",
"**/*.ts",
"**/*.tsx",
"**/*.css",
"**/*.less",
"**/*.scss",
"**/*.html",
"**/*.json",
"**/*.graphql",
"**/*.md",
"**/*.markdown",
"**/*.mdx",
"**/*.yaml",
"**/*.yml",
],
};
```### Run Jest
```bash
npx jest# or, with yarn
yarn jest
```## License
Copyright [Kepler Sticka-Jones](https://keplersj.com) 2017-2022. Licensed MIT.