You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

jest-runner-prettier

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-runner-prettier - npm Package Compare versions

Comparing version

to
0.3.0

jest-preset.js

27

jest.config.js

@@ -11,30 +11,5 @@ module.exports = {

{
preset: "./jest-preset.js",
runner: "./src/index.js",
displayName: "lint: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"
],
testPathIgnorePatterns: [

@@ -41,0 +16,0 @@ "/node_modules/",

{
"name": "jest-runner-prettier",
"version": "0.2.8",
"version": "0.3.0",
"description": "A prettier runner for Jest",

@@ -5,0 +5,0 @@ "main": "src/index.js",

[![Build Status](https://travis-ci.org/keplersj/jest-runner-prettier.svg?branch=master)](https://travis-ci.org/keplersj/jest-runner-prettier)
[![npm version](https://badge.fury.io/js/jest-runner-prettier.svg)](https://badge.fury.io/js/jest-runner-prettier)
[![codecov](https://codecov.io/gh/keplersj/jest-runner-prettier/branch/master/graph/badge.svg)](https://codecov.io/gh/keplersj/jest-runner-prettier)
[![Mentioned in Awesome Jest](https://awesome.re/mentioned-badge.svg)](https://github.com/jest-community/awesome-jest)

@@ -24,10 +25,10 @@ <div align="center">

Install `jest`_(it needs Jest 21+)_ and `jest-runner-prettier`
Install `jest`, `prettier` and `jest-runner-prettier`
```bash
yarn add --dev jest jest-runner-prettier
yarn add --dev jest prettier jest-runner-prettier
# or with NPM
npm install --save-dev jest jest-runner-prettier
npm install --save-dev jest prettier jest-runner-prettier
```

@@ -37,2 +38,24 @@

#### 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`

@@ -43,7 +66,8 @@

"jest": {
"runner": "jest-runner-prettier",
"runner": "prettier",
"moduleFileExtensions": [
"js",
"mjs",
"jsx",
"json",
"vue",
"ts",

@@ -54,18 +78,29 @@ "tsx",

"scss",
"html",
"json",
"graphql",
"md",
"markdown"
"markdown",
"mdx",
"yaml",
"yml"
],
"testMatch": [
"**/*.js",
"**/*.jsx",
"**/*.json",
"**/*.ts",
"**/*.tsx",
"**/*.css",
"**/*.less",
"**/*.scss",
"**/*.graphql",
"**/*.md",
"**/*.markdown"
"**/*js",
"**/*mjs",
"**/*jsx",
"**/*vue",
"**/*ts",
"**/*tsx",
"**/*css",
"**/*less",
"**/*scss",
"**/*html",
"**/*json",
"**/*graphql",
"**/*md",
"**/*markdown",
"**/*mdx",
"**/*yaml",
"**/*yml"
]

@@ -80,7 +115,8 @@ }

module.exports = {
runner: "jest-runner-prettier",
runner: "prettier",
moduleFileExtensions: [
"js",
"mjs",
"jsx",
"json",
"vue",
"ts",

@@ -91,18 +127,29 @@ "tsx",

"scss",
"html",
"json",
"graphql",
"md",
"markdown"
"markdown",
"mdx",
"yaml",
"yml"
],
testMatch: [
"**/*.js",
"**/*.jsx",
"**/*.json",
"**/*.ts",
"**/*.tsx",
"**/*.css",
"**/*.less",
"**/*.scss",
"**/*.graphql",
"**/*.md",
"**/*.markdown"
"**/*js",
"**/*mjs",
"**/*jsx",
"**/*vue",
"**/*ts",
"**/*tsx",
"**/*css",
"**/*less",
"**/*scss",
"**/*html",
"**/*json",
"**/*graphql",
"**/*md",
"**/*markdown",
"**/*mdx",
"**/*yaml",
"**/*yml"
]

@@ -115,3 +162,7 @@ };

```bash
npx jest
# or, with yarn
yarn jest
```

@@ -17,22 +17,54 @@ const path = require("path");

const snapShotTest = fileName => () => {
it("matches snapshot", () => {
return run({
testPath: path.join(__dirname, "__fixtures__", fileName),
config: {},
globalConfig: {}
}).then(result => {
expect(result).toMatchSnapshot();
describe("jest-runner-prettier", () => {
describe("JSON", () => {
describe("good fixture", () => {
it("matches snapshot", () => {
return run({
testPath: path.join(__dirname, "__fixtures__", `good.json`),
config: {},
globalConfig: {}
}).then(result => {
expect(result).toMatchSnapshot();
});
});
});
describe("bad fixture", () => {
it("matches snapshot", () => {
return run({
testPath: path.join(__dirname, "__fixtures__", `bad.json`),
config: {},
globalConfig: {}
}).then(result => {
expect(result).toMatchSnapshot();
});
});
});
});
};
const fileTypeTests = fileType => () => {
describe("good fixture", snapShotTest(`good.${fileType}`));
describe("bad fixture", snapShotTest(`bad.${fileType}`));
};
describe("JSX", () => {
describe("good fixture", () => {
it("matches snapshot", () => {
return run({
testPath: path.join(__dirname, "__fixtures__", `good.jsx`),
config: {},
globalConfig: {}
}).then(result => {
expect(result).toMatchSnapshot();
});
});
});
describe("jest-runner-prettier", () => {
describe("JSON", fileTypeTests("json"));
describe("JSX", fileTypeTests("jsx"));
describe("bad fixture", () => {
it("matches snapshot", () => {
return run({
testPath: path.join(__dirname, "__fixtures__", `bad.jsx`),
config: {},
globalConfig: {}
}).then(result => {
expect(result).toMatchSnapshot();
});
});
});
});
});