Skip to content

Commit c8de0c8

Browse files
Drew DiamantoukosSimenB
Drew Diamantoukos
authored andcommitted
Added some languages to missing markdown fencing blocks (#5378)
* Touching up some markdown rules * Missed 3 files! * Addressed linter error, reverted a block that wasn't actually js * run lint:md
1 parent be66ccc commit c8de0c8

20 files changed

+104
-90
lines changed

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
# Jest
22

33
[![CircleCI Build Status](https://circleci.com/gh/facebook/jest.svg?style=shield)](https://circleci.com/gh/facebook/jest)
4-
[![Travis Build Status](https://travis-ci.org/facebook/jest.svg?branch=master)](https://travis-ci.org/facebook/jest) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/8n38o44k585hhvhd/branch/master?svg=true)](https://ci.appveyor.com/project/Daniel15/jest/branch/master) [![npm version](https://badge.fury.io/js/jest.svg)](http://badge.fury.io/js/jest)
4+
[![Travis Build Status](https://travis-ci.org/facebook/jest.svg?branch=master)](https://travis-ci.org/facebook/jest)
5+
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/8n38o44k585hhvhd/branch/master?svg=true)](https://ci.appveyor.com/project/Daniel15/jest/branch/master)
6+
[![npm version](https://badge.fury.io/js/jest.svg)](http://badge.fury.io/js/jest)
57

68
🃏 Delightful JavaScript Testing
79

8-
- **👩🏻‍💻 Easy Setup**: Complete and easy to set-up JavaScript testing solution. Works out of the box for any React project.
10+
* **👩🏻‍💻 Easy Setup**: Complete and easy to set-up JavaScript testing solution.
11+
Works out of the box for any React project.
912

10-
- **🏃🏽 Instant Feedback**: Fast interactive watch mode runs only test files related to changed files and is optimized to give signal quickly.
13+
* **🏃🏽 Instant Feedback**: Fast interactive watch mode runs only test files
14+
related to changed files and is optimized to give signal quickly.
1115

12-
- **📸 Snapshot Testing**: Capture snapshots of React trees or other serializable values to simplify testing and to analyze how state changes over time.
16+
* **📸 Snapshot Testing**: Capture snapshots of React trees or other
17+
serializable values to simplify testing and to analyze how state changes over
18+
time.
1319

1420
## Getting Started
1521

1622
<!-- generated_getting_started_start -->
1723

1824
Install Jest using [`npm`](https://www.npmjs.com/):
1925

20-
```
26+
```bash
2127
npm install --save-dev jest
2228
```
2329

2430
Or via [`yarn`](https://yarnpkg.com/en/package/jest):
2531

26-
```
32+
```bash
2733
yarn add --dev jest
2834
```
2935

@@ -59,7 +65,7 @@ Add the following section to your `package.json`:
5965

6066
Finally, run `npm test` and Jest will print this message:
6167

62-
```
68+
```bash
6369
PASS ./sum.test.js
6470
✓ adds 1 + 2 to equal 3 (5ms)
6571
```
@@ -83,7 +89,8 @@ jest my-test --notify --config=config.json
8389
```
8490

8591
If you'd like to learn more about running `jest` through the command line, take
86-
a look at the [Jest CLI Options](https://facebook.github.io/jest/docs/cli.html) page.
92+
a look at the [Jest CLI Options](https://facebook.github.io/jest/docs/cli.html)
93+
page.
8794

8895
## Additional Configuration
8996

@@ -92,14 +99,14 @@ a look at the [Jest CLI Options](https://facebook.github.io/jest/docs/cli.html)
9299
To use [Babel](http://babeljs.io/), install the `babel-jest` and
93100
`regenerator-runtime` packages:
94101

95-
```
102+
```bash
96103
npm install --save-dev babel-jest babel-core regenerator-runtime
97104
```
98105

99106
> Note: If you are using a babel version 7 then you need to install `babel-jest`
100107
> with the following command:
101108
>
102-
> ```
109+
> ```bash
103110
> npm install --save-dev babel-jest 'babel-core@^7.0.0-0' @babel/core regenerator-runtime
104111
> ```
105112
@@ -165,11 +172,13 @@ started.
165172
166173
To use TypeScript in your tests you can use
167174
[ts-jest](https://github.com/kulshekhar/ts-jest).
175+
168176
<!-- generated_getting_started_end -->
169177
170178
## Documentation
171179
172-
Learn more about using Jest at http://facebook.github.io/jest
180+
Learn more about using
181+
[Jest on the official site!](http://facebook.github.io/jest)
173182
174183
* [Getting Started](http://facebook.github.io/jest/docs/en/getting-started.html)
175184
* [Guides](http://facebook.github.io/jest/docs/en/snapshot-testing.html)
@@ -178,14 +187,18 @@ Learn more about using Jest at http://facebook.github.io/jest
178187
179188
## Badge
180189
181-
Show the world you're using *Jest*[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
190+
Show the world you're using _Jest_ →
191+
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
182192
183193
```md
184194
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
185195
```
186196
187197
## Contributing
188198
189-
Send issues and pull requests with your ideas. For more information about contributing PRs and issues, see our [Contribution Guidelines](https://github.com/facebook/jest/blob/master/CONTRIBUTING.md).
199+
Send issues and pull requests with your ideas. For more information about
200+
contributing PRs and issues, see our
201+
[Contribution Guidelines](https://github.com/facebook/jest/blob/master/CONTRIBUTING.md).
190202
191-
[Good First Issue](https://github.com/facebook/jest/labels/Good%20First%20Issue) is a great starting point for PRs.
203+
[Good First Issue](https://github.com/facebook/jest/labels/Good%20First%20Issue)
204+
is a great starting point for PRs.

docs/Configuration.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ module that exports a function expecting a string as the first argument for the
591591
path to resolve and an object with the following structure as the second
592592
argument:
593593

594-
```
594+
```json
595595
{
596596
"basedir": string,
597597
"browser": bool,
@@ -766,7 +766,7 @@ test(() => {
766766

767767
Rendered snapshot:
768768

769-
```
769+
```json
770770
Pretty foo: Object {
771771
"x": 1,
772772
"y": 2,
@@ -907,7 +907,7 @@ specify both options.
907907

908908
The following is a visualization of the default regex:
909909

910-
```
910+
```bash
911911
├── __tests__
912912
│ └── component.spec.js # test
913913
│ └── anything # test
@@ -925,7 +925,7 @@ This option allows the use of a custom results processor. This processor must be
925925
a node module that exports a function expecting an object with the following
926926
structure as the first argument and return it:
927927

928-
```
928+
```json
929929
{
930930
"success": bool,
931931
"startTime": epoch,
@@ -976,13 +976,13 @@ implementation.
976976

977977
The test runner module must export a function with the following signature:
978978

979-
```
979+
```ts
980980
function testRunner(
981981
config: Config,
982982
environment: Environment,
983983
runtime: Runtime,
984984
testPath: string,
985-
): Promise<TestResult>
985+
): Promise<TestResult>;
986986
```
987987

988988
An example of such function can be found in our default

docs/ExpectAPI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ expect.extend({
136136

137137
This will print something like this:
138138

139-
```
139+
```bash
140140
expect(received).toBe(expected)
141141

142142
Expected value to be (using Object.is):
@@ -1050,7 +1050,7 @@ test('throws on octopus', () => {
10501050

10511051
And it will generate the following snapshot:
10521052

1053-
```
1053+
```js
10541054
exports[`drinking flavors throws on octopus 1`] = `"yuck, octopus flavor"`;
10551055
```
10561056

docs/GettingStarted.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ title: Getting Started
55

66
Install Jest using [`npm`](https://www.npmjs.com/):
77

8-
```
8+
```bash
99
npm install --save-dev jest
1010
```
1111

1212
Or via [`yarn`](https://yarnpkg.com/en/package/jest):
1313

14-
```
14+
```bash
1515
yarn add --dev jest
1616
```
1717

@@ -47,7 +47,7 @@ Add the following section to your `package.json`:
4747

4848
Finally, run `npm test` and Jest will print this message:
4949

50-
```
50+
```bash
5151
PASS ./sum.test.js
5252
✓ adds 1 + 2 to equal 3 (5ms)
5353
```
@@ -80,14 +80,14 @@ a look at the [Jest CLI Options](CLI.md) page.
8080
To use [Babel](http://babeljs.io/), install the `babel-jest` and
8181
`regenerator-runtime` packages:
8282

83-
```
83+
```bash
8484
npm install --save-dev babel-jest babel-core regenerator-runtime
8585
```
8686

8787
> Note: If you are using a babel version 7 then you need to install `babel-jest`
8888
> with the following command:
8989
>
90-
> ```
90+
> ```bash
9191
> npm install --save-dev babel-jest 'babel-core@^7.0.0-0' @babel/core regenerator-runtime
9292
> ```
9393

docs/MigrationGuide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ dirty migration work. It runs a code transformation on your codebase using
3232

3333
Install Jest Codemods with `npm` by running:
3434

35-
```
35+
```bash
3636
npm install -g jest-codemods
3737
```
3838

3939
To transform your existing tests, navigate to the project containing the tests
4040
and run:
4141

42-
```
42+
```bash
4343
jest-codemods
4444
```
4545

docs/MockFunctionAPI.md

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,25 @@ mockFn.mock.calls[1][0] === 1; // true
127127

128128
`mockImplementation` can also be used to mock class constructors:
129129

130-
```
130+
```js
131131
// SomeClass.js
132132
module.exports = class SomeClass {
133133
m(a, b) {}
134-
}
134+
};
135135

136136
// OtherModule.test.js
137-
jest.mock('./SomeClass'); // this happens automatically with automocking
138-
const SomeClass = require('./SomeClass')
139-
const mMock = jest.fn()
137+
jest.mock('./SomeClass'); // this happens automatically with automocking
138+
const SomeClass = require('./SomeClass');
139+
const mMock = jest.fn();
140140
SomeClass.mockImplementation(() => {
141141
return {
142-
m: mMock
143-
}
144-
})
142+
m: mMock,
143+
};
144+
});
145145

146-
const some = new SomeClass()
147-
some.m('a', 'b')
148-
console.log('Calls to m: ', mMock.mock.calls)
146+
const some = new SomeClass();
147+
some.m('a', 'b');
148+
console.log('Calls to m: ', mMock.mock.calls);
149149
```
150150

151151
### `mockFn.mockImplementationOnce(fn)`
@@ -154,30 +154,30 @@ Accepts a function that will be used as an implementation of the mock for one
154154
call to the mocked function. Can be chained so that multiple function calls
155155
produce different results.
156156

157-
```
158-
var myMockFn = jest.fn()
157+
```js
158+
const myMockFn = jest
159+
.fn()
159160
.mockImplementationOnce(cb => cb(null, true))
160161
.mockImplementationOnce(cb => cb(null, false));
161162

162-
myMockFn((err, val) => console.log(val));
163-
> true
163+
myMockFn((err, val) => console.log(val)); // true
164164

165-
myMockFn((err, val) => console.log(val));
166-
> false
165+
myMockFn((err, val) => console.log(val)); // false
167166
```
168167

169168
When the mocked function runs out of implementations defined with
170169
mockImplementationOnce, it will execute the default implementation set with
171170
`jest.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if
172171
they were called:
173172

174-
```
175-
var myMockFn = jest.fn(() => 'default')
173+
```js
174+
const myMockFn = jest
175+
.fn(() => 'default')
176176
.mockImplementationOnce(() => 'first call')
177177
.mockImplementationOnce(() => 'second call');
178178

179+
// 'first call', 'second call', 'default', 'default'
179180
console.log(myMockFn(), myMockFn(), myMockFn(), myMockFn());
180-
> 'first call', 'second call', 'default', 'default'
181181
```
182182

183183
### `mockFn.mockName(value)`
@@ -197,7 +197,7 @@ expect(mockFn).toHaveBeenCalled();
197197

198198
Will result in this error:
199199

200-
```
200+
```bash
201201
expect(mockedFunction).toHaveBeenCalled()
202202

203203
Expected mock function to have been called.
@@ -232,14 +232,15 @@ chained so that successive calls to the mock function return different values.
232232
When there are no more `mockReturnValueOnce` values to use, calls will return a
233233
value specified by `mockReturnValue`.
234234

235-
```
236-
const myMockFn = jest.fn()
235+
```js
236+
const myMockFn = jest
237+
.fn()
237238
.mockReturnValue('default')
238239
.mockReturnValueOnce('first call')
239240
.mockReturnValueOnce('second call');
240241

242+
// 'first call', 'second call', 'default', 'default'
241243
console.log(myMockFn(), myMockFn(), myMockFn(), myMockFn());
242-
> 'first call', 'second call', 'default', 'default'
243244
```
244245

245246
### `mockFn.mockResolvedValue(value)`
@@ -255,7 +256,7 @@ Useful to mock async functions in async tests:
255256
```js
256257
test('async test', async () => {
257258
const asyncMock = jest.fn().mockResolvedValue(43);
258-
259+
259260
await asyncMock(); // 43
260261
});
261262
```
@@ -272,11 +273,12 @@ Useful to resolve different values over multiple async calls:
272273

273274
```js
274275
test('async test', async () => {
275-
const asyncMock = jest.fn()
276+
const asyncMock = jest
277+
.fn()
276278
.mockResolvedValue('default')
277279
.mockResolvedValueOnce('first call')
278280
.mockResolvedValueOnce('second call');
279-
281+
280282
await asyncMock(); // first call
281283
await asyncMock(); // second call
282284
await asyncMock(); // default
@@ -297,7 +299,7 @@ Useful to create async mock functions that will always reject:
297299
```js
298300
test('async test', async () => {
299301
const asyncMock = jest.fn().mockRejectedValue(new Error('Async error'));
300-
302+
301303
await asyncMock(); // throws "Async error"
302304
});
303305
```
@@ -314,10 +316,11 @@ Example usage:
314316

315317
```js
316318
test('async test', async () => {
317-
const asyncMock = jest.fn()
319+
const asyncMock = jest
320+
.fn()
318321
.mockResolvedValueOnce('first call')
319322
.mockRejectedValueOnce(new Error('Async error'));
320-
323+
321324
await asyncMock(); // first call
322325
await asyncMock(); // throws "Async error"
323326
});

0 commit comments

Comments
 (0)