From fd911ae0192a06c98c6688411f0ff1c5eef29743 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Mon, 26 Feb 2018 22:57:31 +0000 Subject: [PATCH 1/2] Add community packages documentation --- docs/CommunityPackages.md | 119 ++++++++++++++++++++++++++++++++++++++ website/i18n/en.json | 1 + website/sidebars.json | 1 + 3 files changed, 121 insertions(+) create mode 100644 docs/CommunityPackages.md diff --git a/docs/CommunityPackages.md b/docs/CommunityPackages.md new file mode 100644 index 000000000000..ffddc13ffe31 --- /dev/null +++ b/docs/CommunityPackages.md @@ -0,0 +1,119 @@ +--- +id: community-packages +title: Community Packages +--- + +Jest has a large community of packages out there in the wild, here's a list of +some of the popular packages to enhance your Jest experience: + +## jest-extended + +Additional Jest matchers including multiple APIs for different types including: + +* Array +* Boolean +* Date +* Function +* Mock +* Number +* Object +* Promise +* String + +### Example + +`.toContainEntries([[key, value]])` + +Use .toContainEntries when checking if an object contains all of the provided +entries. + +```javascript +test('passes when object contains all of the given entries', () => { + const o = {a: 'foo', b: 'bar', c: 'baz'}; + expect(o).toContainEntries([['a', 'foo']]); + expect(o).toContainEntries([['c', 'baz'], ['a', 'foo']]); + expect(o).not.toContainEntries([['b', 'qux'], ['a', 'foo']]); +}); +``` + +You can find all of the available matchers `jest-extended` has to offer in the +[readme file](https://github.com/jest-community/jest-extended/blob/master/README.md). + +## vscode-jest + +The optimal flow for Jest based testing in VS Code + +A comprehensive experience when using Facebook's Jest within a project. + +* Useful IDE based Feedback +* Session based test watching + +Find out how to install and setup `vscode-jest` in the +[readme file](https://github.com/jest-community/vscode-jest/blob/master/README.md). + +## eslint-plugin-jest + +ESLint plugin for Jest + +Popular rules include: + +* `jest/no-disabled-tests` +* `jest/no-focused-tests` +* `jest/no-identical-title` +* `jest/valid-expect` + +You can find all of the available rules `eslint-plugin-jest` has to offer in the +[readme file](https://github.com/jest-community/eslint-plugin-jest/blob/master/README.md). + +## jest-each + +Data Driven Jest Testing + +jest-each allows you to provide multiple arguments to your test/describe which +results in the test/suite being run once per row of data. _Supports skipping and +focussing tests_. + +### Example data driven test + +```javascript +import each from 'jest-each'; + +each([[1, 1, 2], [1, 2, 3], [2, 1, 3]]).test( + 'returns the result of adding %s to %s', + (a, b, expected) => { + expect(a + b).toBe(expected); + }, +); +``` + +Read the full documentation of `jest-each` in the +[readme file](https://github.com/mattphillips/jest-each/blob/master/README.md). + +## babel-jest-assertions + +Automatically add `expect.assertions(n)` and `expect.hasAssertions` to all tests +using babel + +### Usage + +Simply write your tests as you would normally and this plugin will add the +verification of assertions in the background. + +```javascript +it('resolves to one', () => { + Promise.reject(1).then(value => expect(value).toBe(1)); +}); +``` + +`↓ ↓ ↓ ↓ ↓ ↓` + +```javascript +it('resolves to one', () => { + expect.hasAssertions(); + expect.assertions(1); + Promise.reject(1).then(value => expect(value).toBe(1)); +}); +``` + +Find out how to install and setup `babel-jest-assertions` in the +[readme file](https://github.com/mattphillips/babel-jest-assertions/blob/master/README.md). diff --git a/website/i18n/en.json b/website/i18n/en.json index b11d7d41c4ea..05902b6ac03d 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -5,6 +5,7 @@ "previous": "Previous", "tagline": "🃏 Delightful JavaScript Testing", "cli": "Jest CLI Options", + "community-packages": "Community Packages", "configuration": "Configuring Jest", "es6-class-mocks": "ES6 Class Mocks", "expect": "Expect", diff --git a/website/sidebars.json b/website/sidebars.json index 2f5f48529200..e162c89dbf98 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -7,6 +7,7 @@ "setup-teardown", "mock-functions", "jest-platform", + "community-packages", "more-resources" ], "Guides": [ From 990c33f0f497d70a194f2c7848a06c83afd46f28 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Tue, 27 Feb 2018 17:22:19 +0000 Subject: [PATCH 2/2] Replace community packages with jest-community docs --- docs/CommunityPackages.md | 119 -------------------------------------- docs/JestCommunity.md | 31 ++++++++++ website/i18n/en.json | 2 +- website/sidebars.json | 2 +- 4 files changed, 33 insertions(+), 121 deletions(-) delete mode 100644 docs/CommunityPackages.md create mode 100644 docs/JestCommunity.md diff --git a/docs/CommunityPackages.md b/docs/CommunityPackages.md deleted file mode 100644 index ffddc13ffe31..000000000000 --- a/docs/CommunityPackages.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -id: community-packages -title: Community Packages ---- - -Jest has a large community of packages out there in the wild, here's a list of -some of the popular packages to enhance your Jest experience: - -## jest-extended - -Additional Jest matchers including multiple APIs for different types including: - -* Array -* Boolean -* Date -* Function -* Mock -* Number -* Object -* Promise -* String - -### Example - -`.toContainEntries([[key, value]])` - -Use .toContainEntries when checking if an object contains all of the provided -entries. - -```javascript -test('passes when object contains all of the given entries', () => { - const o = {a: 'foo', b: 'bar', c: 'baz'}; - expect(o).toContainEntries([['a', 'foo']]); - expect(o).toContainEntries([['c', 'baz'], ['a', 'foo']]); - expect(o).not.toContainEntries([['b', 'qux'], ['a', 'foo']]); -}); -``` - -You can find all of the available matchers `jest-extended` has to offer in the -[readme file](https://github.com/jest-community/jest-extended/blob/master/README.md). - -## vscode-jest - -The optimal flow for Jest based testing in VS Code - -A comprehensive experience when using Facebook's Jest within a project. - -* Useful IDE based Feedback -* Session based test watching - -Find out how to install and setup `vscode-jest` in the -[readme file](https://github.com/jest-community/vscode-jest/blob/master/README.md). - -## eslint-plugin-jest - -ESLint plugin for Jest - -Popular rules include: - -* `jest/no-disabled-tests` -* `jest/no-focused-tests` -* `jest/no-identical-title` -* `jest/valid-expect` - -You can find all of the available rules `eslint-plugin-jest` has to offer in the -[readme file](https://github.com/jest-community/eslint-plugin-jest/blob/master/README.md). - -## jest-each - -Data Driven Jest Testing - -jest-each allows you to provide multiple arguments to your test/describe which -results in the test/suite being run once per row of data. _Supports skipping and -focussing tests_. - -### Example data driven test - -```javascript -import each from 'jest-each'; - -each([[1, 1, 2], [1, 2, 3], [2, 1, 3]]).test( - 'returns the result of adding %s to %s', - (a, b, expected) => { - expect(a + b).toBe(expected); - }, -); -``` - -Read the full documentation of `jest-each` in the -[readme file](https://github.com/mattphillips/jest-each/blob/master/README.md). - -## babel-jest-assertions - -Automatically add `expect.assertions(n)` and `expect.hasAssertions` to all tests -using babel - -### Usage - -Simply write your tests as you would normally and this plugin will add the -verification of assertions in the background. - -```javascript -it('resolves to one', () => { - Promise.reject(1).then(value => expect(value).toBe(1)); -}); -``` - -`↓ ↓ ↓ ↓ ↓ ↓` - -```javascript -it('resolves to one', () => { - expect.hasAssertions(); - expect.assertions(1); - Promise.reject(1).then(value => expect(value).toBe(1)); -}); -``` - -Find out how to install and setup `babel-jest-assertions` in the -[readme file](https://github.com/mattphillips/babel-jest-assertions/blob/master/README.md). diff --git a/docs/JestCommunity.md b/docs/JestCommunity.md new file mode 100644 index 000000000000..2b60966f61ab --- /dev/null +++ b/docs/JestCommunity.md @@ -0,0 +1,31 @@ +--- +title: Jest Community +id: jest-community +--- + +The community around Jest is working hard to make the testing experience even +greater. + +[jest-community](https://github.com/jest-community) is a new GitHub organization +for high quality Jest additions curated by Jest maintainers and collaborators. +It already features some of our favorite projects, to name a few: + +* [vscode-jest](https://github.com/jest-community/vscode-jest) +* [jest-extended](https://github.com/jest-community/jest-extended) +* [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) +* [awesome-jest](https://github.com/jest-community/awesome-jest) + +Community projects under one organisation are a great way for Jest to experiment +with new ideas/techniques and approaches. Encourage contributions from the +community and publish contributions independently at a faster pace. + +The jest-community org maintains an +[awesome-jest](https://github.com/jest-community/awesome-jest) list of great +projects and resources related to Jest, this includes all projects not just the +ones in the jest-community org. + +If you have something awesome to share, feel free to reach out to us! We'd love +to share your project on the awesome-jest list +([send a PR here](https://github.com/jest-community/awesome-jest/pulls)) or if +you would like to transfer your project to the jest-community org reachout to +one of the owners of the org. diff --git a/website/i18n/en.json b/website/i18n/en.json index 05902b6ac03d..ab79fd12f251 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -5,12 +5,12 @@ "previous": "Previous", "tagline": "🃏 Delightful JavaScript Testing", "cli": "Jest CLI Options", - "community-packages": "Community Packages", "configuration": "Configuring Jest", "es6-class-mocks": "ES6 Class Mocks", "expect": "Expect", "getting-started": "Getting Started", "api": "Globals", + "jest-community": "Jest Community", "jest-object": "The Jest Object", "jest-platform": "Jest Platform", "manual-mocks": "Manual Mocks", diff --git a/website/sidebars.json b/website/sidebars.json index e162c89dbf98..12778a3e8a28 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -7,7 +7,7 @@ "setup-teardown", "mock-functions", "jest-platform", - "community-packages", + "jest-community", "more-resources" ], "Guides": [