Skip to content

Commit

Permalink
chore: lint files in website/blog directory (#13379)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas authored Oct 4, 2022
1 parent 5e1e105 commit 3904eb8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ bin/
packages/*/build/**
packages/*/dist/**
website/.docusaurus
website/blog
website/build
website/node_modules
website/i18n/*.js
Expand Down
19 changes: 17 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ module.exports = {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'arrow-body-style': 'off',
'consistent-return': 'off',
'import/export': 'off',
'import/no-extraneous-dependencies': 'off',
Expand All @@ -191,16 +190,32 @@ module.exports = {
'no-console': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'off',
'sort-keys': 'off',
},
},
// demonstration of matchers usage
{
files: ['**/UsingMatchers.md/**'],
rules: {
'jest/prefer-to-be': 'off',
},
},
// demonstration of 'jest/valid-expect' rule
{
files: [
'**/2017-05-06-jest-20-delightful-testing-multi-project-runner.md/**',
],
rules: {
'jest/valid-expect': 'off',
},
},
// Jest 11 did not had `toHaveLength` matcher
{
files: ['**/2016-04-12-jest-11.md/**'],
rules: {
'jest/prefer-to-have-length': 'off',
},
},

// snapshots in examples plus inline snapshots need to keep backtick
{
Expand Down
12 changes: 7 additions & 5 deletions website/blog/2017-12-18-jest-22.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To get a better understanding of custom runners and Jest as a platform, make sur

In order to more easily identify which assertion is failing your test, we've added a code frame showing the context where the assertion is in order to focus on your own code. See the following example test:

```
```js
test('some test', () => {
function someFunctionWhichShouldThrow() {
if (false) {
Expand All @@ -35,7 +35,7 @@ test('some test', () => {
return 'success!';
}

expect(someFunctionWhichShouldThrow).toThrowError();
expect(someFunctionWhichShouldThrow).toThrow();
});
```

Expand All @@ -51,7 +51,7 @@ In Jest 22, we have added a codeframe, giving more context to the failing assert

You can now use `toThrow` and `toThrowErrorMatchingSnapshot` on promise rejections in the same way you can on synchronous errors.

```
```js
async function throwingFunction() {
throw new Error('This failed');
}
Expand Down Expand Up @@ -81,17 +81,18 @@ Jest uses Babel under the hood to power code coverage and advanced mocking featu

There has been a couple of changes to mock functions in Jest 22, making them even easier to use. Firstly, we added a [`mockName`](/docs/mock-function-api#mockfnmocknamevalue) property allowing you to name your mocks, which is useful in assertion failures. We have also made the Jest mock function serializable in `pretty-format`, meaning that you can snapshot test mocks. In Jest 21, `expect(jest.fn()).toMatchSnapshot()` would serialize to `[Function]`, in Jest 22, you might get something like this:

```
```js
test('my mocking test', () => {
const mock = jest.fn().mockName('myMock');

mock('hello', { foo: 'bar' });
mock('hello', {foo: 'bar'});

expect(mock).toMatchSnapshot();
});

// Serializes to:

exports[`my mocking test 1`] = `
[MockFunction myMock] {
"calls": Array [
Array [
Expand All @@ -102,6 +103,7 @@ test('my mocking test', () => {
],
],
}
`;
```

## Highlights from Jest 21
Expand Down

0 comments on commit 3904eb8

Please sign in to comment.