From c9f1ce63f6564740ebdfe227f8959f91e5e31cef Mon Sep 17 00:00:00 2001 From: Dustin Ryerson Date: Wed, 6 Feb 2019 14:56:20 -0800 Subject: [PATCH 1/2] Update links to use the new Jest website --- docs/guides/choosing-a-test-runner.md | 2 +- docs/guides/testing-async-components.md | 2 +- .../testing-single-file-components-with-jest.md | 16 ++++++++-------- docs/guides/using-with-typescript.md | 4 ++-- docs/guides/using-with-vuex.md | 2 +- docs/ja/guides/choosing-a-test-runner.md | 2 +- docs/ja/guides/testing-async-components.md | 2 +- .../testing-single-file-components-with-jest.md | 16 ++++++++-------- docs/ja/guides/using-with-typescript.md | 4 ++-- docs/ja/guides/using-with-vuex.md | 2 +- docs/ru/guides/choosing-a-test-runner.md | 2 +- docs/ru/guides/testing-async-components.md | 2 +- .../testing-single-file-components-with-jest.md | 16 ++++++++-------- docs/ru/guides/using-with-typescript.md | 4 ++-- docs/ru/guides/using-with-vuex.md | 2 +- docs/zh/guides/choosing-a-test-runner.md | 2 +- docs/zh/guides/testing-async-components.md | 2 +- .../testing-single-file-components-with-jest.md | 16 ++++++++-------- docs/zh/guides/using-with-typescript.md | 4 ++-- docs/zh/guides/using-with-vuex.md | 2 +- 20 files changed, 52 insertions(+), 52 deletions(-) diff --git a/docs/guides/choosing-a-test-runner.md b/docs/guides/choosing-a-test-runner.md index 2aaeab49d..9b6f1be47 100644 --- a/docs/guides/choosing-a-test-runner.md +++ b/docs/guides/choosing-a-test-runner.md @@ -6,7 +6,7 @@ There are many popular JavaScript test runners, and Vue Test Utils works with al There are a few things to consider when choosing a test runner though: feature set, performance, and support for single-file component (SFC) pre-compilation. After carefully comparing existing libraries, here are two test runners that we recommend: -- [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) is the most fully featured test runner. It requires the least configuration, sets up JSDOM by default, provides built-in assertions, and has a great command line user experience. However, you will need a preprocessor to be able to import SFC components in your tests. We have created the `vue-jest` preprocessor which can handle most common SFC features, but it currently does not have 100% feature parity with `vue-loader`. +- [Jest](https://jestjs.io/docs/en/getting-started.html#content) is the most fully featured test runner. It requires the least configuration, sets up JSDOM by default, provides built-in assertions, and has a great command line user experience. However, you will need a preprocessor to be able to import SFC components in your tests. We have created the `vue-jest` preprocessor which can handle most common SFC features, but it currently does not have 100% feature parity with `vue-loader`. - [mocha-webpack](https://github.com/zinserjan/mocha-webpack) is a wrapper around webpack + Mocha, but with a more streamlined interface and watch mode. The benefits of this setup is that we can get complete SFC support via webpack + `vue-loader`, but it requires more configuration upfront. diff --git a/docs/guides/testing-async-components.md b/docs/guides/testing-async-components.md index d872b46ad..45c3c3a96 100644 --- a/docs/guides/testing-async-components.md +++ b/docs/guides/testing-async-components.md @@ -2,7 +2,7 @@ To simplify testing, Vue Test Utils applies DOM updates _synchronously_. However, there are some techniques you need to be aware of when testing a component with asynchronous behavior such as callbacks or promises. -One of the most common asynchronous behaviors is API calls and Vuex actions. The following examples shows how to test a method that makes an API call. This example uses Jest to run the test and to mock the HTTP library `axios`. More about Jest manual mocks can be found [here](https://facebook.github.io/jest/docs/en/manual-mocks.html#content). +One of the most common asynchronous behaviors is API calls and Vuex actions. The following examples shows how to test a method that makes an API call. This example uses Jest to run the test and to mock the HTTP library `axios`. More about Jest manual mocks can be found [here](https://jestjs.io/docs/en/manual-mocks.html#content). The implementation of the `axios` mock looks like this: diff --git a/docs/guides/testing-single-file-components-with-jest.md b/docs/guides/testing-single-file-components-with-jest.md index 07fa7fc09..594b729a0 100644 --- a/docs/guides/testing-single-file-components-with-jest.md +++ b/docs/guides/testing-single-file-components-with-jest.md @@ -2,7 +2,7 @@ > An example project for this setup is available on [GitHub](https://github.com/vuejs/vue-test-utils-jest-example). -Jest is a test runner developed by Facebook, aiming to deliver a battery-included unit testing solution. You can learn more about Jest on its [official documentation](https://facebook.github.io/jest/). +Jest is a test runner developed by Facebook, aiming to deliver a battery-included unit testing solution. You can learn more about Jest on its [official documentation](https://jestjs.io/). #### Setting up Jest @@ -122,7 +122,7 @@ Example `.babelrc`: ### Placing Test Files -By default, Jest will recursively pick up all files that have a `.spec.js` or `.test.js` extension in the entire project. If this does not fit your needs, it's possible [to change the `testRegex`](https://facebook.github.io/jest/docs/en/configuration.html#testregex-string) in the config section in the `package.json` file. +By default, Jest will recursively pick up all files that have a `.spec.js` or `.test.js` extension in the entire project. If this does not fit your needs, it's possible [to change the `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string) in the config section in the `package.json` file. Jest recommends creating a `__tests__` directory right next to the code being tested, but feel free to structure your tests as you see fit. Just beware that Jest would create a `__snapshots__` directory next to test files that performs snapshot testing. @@ -130,7 +130,7 @@ Jest recommends creating a `__tests__` directory right next to the code being te Jest can be used to generate coverage reports in multiple formats. The following is a simple example to get started with: -Extend your `jest` config (usually in `package.json` or `jest.config.js`) with the [`collectCoverage`](https://facebook.github.io/jest/docs/en/configuration.html#collectcoverage-boolean) option, and then add the [`collectCoverageFrom`](https://facebook.github.io/jest/docs/en/configuration.html#collectcoveragefrom-array) array to define the files for which coverage information should be collected. +Extend your `jest` config (usually in `package.json` or `jest.config.js`) with the [`collectCoverage`](https://jestjs.io/docs/en/configuration.html#collectcoverage-boolean) option, and then add the [`collectCoverageFrom`](https://jestjs.io/docs/en/configuration.html#collectcoveragefrom-array) array to define the files for which coverage information should be collected. ```json { @@ -142,7 +142,7 @@ Extend your `jest` config (usually in `package.json` or `jest.config.js`) with t } ``` -This will enable coverage reports with the [default coverage reporters](https://facebook.github.io/jest/docs/en/configuration.html#coveragereporters-array-string). You can customise these with the `coverageReporters` option: +This will enable coverage reports with the [default coverage reporters](https://jestjs.io/docs/en/configuration.html#coveragereporters-array-string). You can customise these with the `coverageReporters` option: ```json { @@ -153,11 +153,11 @@ This will enable coverage reports with the [default coverage reporters](https:// } ``` -Further documentation can be found in the [Jest configuration documentation](https://facebook.github.io/jest/docs/en/configuration.html#collectcoverage-boolean), where you can find options for coverage thresholds, target output directories, etc. +Further documentation can be found in the [Jest configuration documentation](https://jestjs.io/docs/en/configuration.html#collectcoverage-boolean), where you can find options for coverage thresholds, target output directories, etc. ### Example Spec -If you are familiar with Jasmine, you should feel right at home with Jest's [assertion API](https://facebook.github.io/jest/docs/en/expect.html#content): +If you are familiar with Jasmine, you should feel right at home with Jest's [assertion API](https://jestjs.io/docs/en/expect.html#content): ```js import { mount } from '@vue/test-utils' @@ -173,7 +173,7 @@ describe('Component', () => { ### Snapshot Testing -When you mount a component with Vue Test Utils, you get access to the root HTML element. This can be saved as a snapshot for [Jest snapshot testing](https://facebook.github.io/jest/docs/en/snapshot-testing.html): +When you mount a component with Vue Test Utils, you get access to the root HTML element. This can be saved as a snapshot for [Jest snapshot testing](https://jestjs.io/docs/en/snapshot-testing.html): ```js test('renders correctly', () => { @@ -205,5 +205,5 @@ Then configure it in `package.json`: - [Example project for this setup](https://github.com/vuejs/vue-test-utils-jest-example) - [Examples and slides from Vue Conf 2017](https://github.com/codebryo/vue-testing-with-jest-conf17) -- [Jest](https://facebook.github.io/jest/) +- [Jest](https://jestjs.io/) - [Babel preset env](https://github.com/babel/babel-preset-env) diff --git a/docs/guides/using-with-typescript.md b/docs/guides/using-with-typescript.md index b858d3120..ca7211bc8 100644 --- a/docs/guides/using-with-typescript.md +++ b/docs/guides/using-with-typescript.md @@ -30,7 +30,7 @@ The next step is to add Jest to the project. ### Setting up Jest -Jest is a test runner developed by Facebook, aiming to deliver a battery-included unit testing solution. You can learn more about Jest on its [official documentation](https://facebook.github.io/jest/). +Jest is a test runner developed by Facebook, aiming to deliver a battery-included unit testing solution. You can learn more about Jest on its [official documentation](https://jestjs.io/). Install Jest and Vue Test Utils: @@ -154,4 +154,4 @@ That's all we need to do to get TypeScript and Vue Test Utils working together! ### Resources - [Example project for this setup](https://github.com/vuejs/vue-test-utils-typescript-example) -- [Jest](https://facebook.github.io/jest/) +- [Jest](https://jestjs.io/) diff --git a/docs/guides/using-with-vuex.md b/docs/guides/using-with-vuex.md index 98d563e82..403cbb995 100644 --- a/docs/guides/using-with-vuex.md +++ b/docs/guides/using-with-vuex.md @@ -94,7 +94,7 @@ What’s happening here? First we tell Vue to use Vuex with the `localVue.use` m We then make a mock store by calling `new Vuex.Store` with our mock values. We only pass it the actions, since that’s all we care about. -The actions are [jest mock functions](https://facebook.github.io/jest/docs/en/mock-functions.html). These mock functions give us methods to assert whether the actions were called or not. +The actions are [jest mock functions](https://jestjs.io/docs/en/mock-functions.html). These mock functions give us methods to assert whether the actions were called or not. We can then assert in our tests that the action stub was called when expected. diff --git a/docs/ja/guides/choosing-a-test-runner.md b/docs/ja/guides/choosing-a-test-runner.md index c379f88ff..e70c8e9a0 100644 --- a/docs/ja/guides/choosing-a-test-runner.md +++ b/docs/ja/guides/choosing-a-test-runner.md @@ -6,7 +6,7 @@ ですが、テストランナを選択する際には、機能セット、パフォーマンス、および単一ファイルコンポーネント (SFC) の事前コンパイルのサポートなどを考慮すべきです。既存のライブラリを慎重に比較した上で、以下の 2 つのテストランナをお勧めします: -- [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) は最も充実したテストランナです。最小の設定が必要で、デフォルトで JSDOM を設定し、組み込みの検証を提供し、コマンドラインのユーザーエクスペリエンスが優れています。ただし、テストで SFC コンポーネントをインポートできるようにするには、プリプロセッサが必要です。最も一般的な SFC 機能を処理できる `vue-jest` プリプロセッサを作成しましたが、現在 `vue-loader` と 100% 同じ機能を持っていません。 +- [Jest](https://jestjs.io/docs/en/getting-started.html#content) は最も充実したテストランナです。最小の設定が必要で、デフォルトで JSDOM を設定し、組み込みの検証を提供し、コマンドラインのユーザーエクスペリエンスが優れています。ただし、テストで SFC コンポーネントをインポートできるようにするには、プリプロセッサが必要です。最も一般的な SFC 機能を処理できる `vue-jest` プリプロセッサを作成しましたが、現在 `vue-loader` と 100% 同じ機能を持っていません。 - [mocha-webpack](https://github.com/zinserjan/mocha-webpack) は webpack + Mocha のラッパですが、より合理的なインタフェースと watch モードを備えています。この設定のメリットは、webpack + `vue-loader` を使用して完全な SFC サポートを得ることができるということですが、より多くの設定を行う必要があります。 diff --git a/docs/ja/guides/testing-async-components.md b/docs/ja/guides/testing-async-components.md index 610699f21..d695737c7 100644 --- a/docs/ja/guides/testing-async-components.md +++ b/docs/ja/guides/testing-async-components.md @@ -2,7 +2,7 @@ テストをシンプルにするために、 `vue-test-utils` は DOM の更新を同期的に適用します。しかし、コールバックや Promise のようなコンポーネントの非同期動作をテストする場合、いくつかのテクニックを知っておく必要があります。 -よくある非同期動作の 1 つとして API 呼び出しと Vuex の action があります。以下の例は API 呼び出しをするメソッドをテストする方法を示しています。この例は HTTP のライブラリである `axios` をモックしてテストを実行するために Jest を使っています。Jest のモックの詳細は[ここ](https://facebook.github.io/jest/docs/en/manual-mocks.html#content)にあります。 +よくある非同期動作の 1 つとして API 呼び出しと Vuex の action があります。以下の例は API 呼び出しをするメソッドをテストする方法を示しています。この例は HTTP のライブラリである `axios` をモックしてテストを実行するために Jest を使っています。Jest のモックの詳細は[ここ](https://jestjs.io/docs/en/manual-mocks.html#content)にあります。 `axios` のモックの実装はこのようにします。 diff --git a/docs/ja/guides/testing-single-file-components-with-jest.md b/docs/ja/guides/testing-single-file-components-with-jest.md index 6029b2846..493d5f66e 100644 --- a/docs/ja/guides/testing-single-file-components-with-jest.md +++ b/docs/ja/guides/testing-single-file-components-with-jest.md @@ -2,7 +2,7 @@ > このセットアップのサンプルプロジェクトは、 [GitHub](https://github.com/vuejs/vue-test-utils-jest-example) にあります。 -Jest は Facebook が開発したテストランナであり、ユニットテストソリューションの提供を目指しています。 Jest の詳細については、[公式ドキュメント](https://facebook.github.io/jest/)を参照してください。 +Jest は Facebook が開発したテストランナであり、ユニットテストソリューションの提供を目指しています。 Jest の詳細については、[公式ドキュメント](https://jestjs.io/)を参照してください。 ### Jest のセットアップ @@ -120,7 +120,7 @@ webpack で `babel-preset-env` を使用するとした場合、webpack は ES M ### テストファイルの配置 -デフォルトでは、Jest はプロジェクト全体で `.spec.js` または `.test.js` 拡張子を持つすべてのファイルを再帰的に取得します。これがあなたのニーズに合わない場合は、`package.json` ファイルの config セクションで[testRegex を変更する](https://facebook.github.io/jest/docs/en/configuration.html#testregex-string)ことが可能です。 +デフォルトでは、Jest はプロジェクト全体で `.spec.js` または `.test.js` 拡張子を持つすべてのファイルを再帰的に取得します。これがあなたのニーズに合わない場合は、`package.json` ファイルの config セクションで[testRegex を変更する](https://jestjs.io/docs/en/configuration.html#testregex-string)ことが可能です。 Jest は、テスト対象のコードのすぐ隣に`__tests__`ディレクトリを作成することを推奨していますが、適切にテストを構造化することは自由です。 Jest がスナップショットテストを実行するテストファイルの隣に`__snapshots__`ディレクトリを作成することに注意してください。 @@ -128,7 +128,7 @@ Jest は、テスト対象のコードのすぐ隣に`__tests__`ディレクト Jest は複数のフォーマットでカバレッジを取ることができます。 以下はそれをするための簡単な例です。 -`jest` の設定 (普通は `package.json` か  `jest.config.js`) に  [collectCoverage](https://facebook.github.io/jest/docs/en/configuration.html#collectcoverage-boolean) オプションを加えます。それから、カバレッジを収集する対象のファイルを [collectCoverageFrom](https://facebook.github.io/jest/docs/en/configuration.html#collectcoveragefrom-array) に配列で定義します。 +`jest` の設定 (普通は `package.json` か  `jest.config.js`) に  [collectCoverage](https://jestjs.io/docs/en/configuration.html#collectcoverage-boolean) オプションを加えます。それから、カバレッジを収集する対象のファイルを [collectCoverageFrom](https://jestjs.io/docs/en/configuration.html#collectcoveragefrom-array) に配列で定義します。 ```json { @@ -140,7 +140,7 @@ Jest は複数のフォーマットでカバレッジを取ることができま } ``` -[デフォルトのカバレッジレポーター](https://facebook.github.io/jest/docs/en/configuration.html#coveragereporters-array-string)のカバレッジレポートは有効になります。 `coverageReporters` オプションでそれらをカスタマイズすることができます。 +[デフォルトのカバレッジレポーター](https://jestjs.io/docs/en/configuration.html#coveragereporters-array-string)のカバレッジレポートは有効になります。 `coverageReporters` オプションでそれらをカスタマイズすることができます。 ```json { @@ -151,11 +151,11 @@ Jest は複数のフォーマットでカバレッジを取ることができま } ``` -より詳しい情報は [Jest configuration documentation](https://facebook.github.io/jest/docs/en/configuration.html#collectcoverage-boolean) にあります。 カバレッジの閾値やターゲットを出力するディレクトリなどのオプションが記載されています。 +より詳しい情報は [Jest configuration documentation](https://jestjs.io/docs/en/configuration.html#collectcoverage-boolean) にあります。 カバレッジの閾値やターゲットを出力するディレクトリなどのオプションが記載されています。 ### Spec の例 -あなたが Jasmine をよく知っているなら、Jest の [assertion API](https://facebook.github.io/jest/docs/en/expect.html#content)は自宅のように感じるはずです。 +あなたが Jasmine をよく知っているなら、Jest の [assertion API](https://jestjs.io/docs/en/expect.html#content)は自宅のように感じるはずです。 ```js import { mount } from '@vue/test-utils' @@ -171,7 +171,7 @@ describe('Component', () => { ### スナップショットテスト -Vue Test Utils でコンポーネントをマウントすると、コンポーネントのルート HTML 要素にアクセスすることができます。 [Jest のスナップショットテスト](https://facebook.github.io/jest/docs/en/snapshot-testing.html)で使用するためにこれを保存することができます。 +Vue Test Utils でコンポーネントをマウントすると、コンポーネントのルート HTML 要素にアクセスすることができます。 [Jest のスナップショットテスト](https://jestjs.io/docs/en/snapshot-testing.html)で使用するためにこれを保存することができます。 ```js test('renders correctly', () => { @@ -203,5 +203,5 @@ npm install --save-dev jest-serializer-vue - [このセットアップのプロジェクト例](https://github.com/vuejs/vue-test-utils-jest-example) - [Vue Conf 2017 のスライド](https://github.com/codebryo/vue-testing-with-jest-conf17) -- [Jest](https://facebook.github.io/jest/) +- [Jest](https://jestjs.io/) - [Babel preset env](https://github.com/babel/babel-preset-env) diff --git a/docs/ja/guides/using-with-typescript.md b/docs/ja/guides/using-with-typescript.md index bbe3e47c7..e8558315c 100644 --- a/docs/ja/guides/using-with-typescript.md +++ b/docs/ja/guides/using-with-typescript.md @@ -30,7 +30,7 @@ Vue と TypeScript を一緒に使うためのセットアップの詳細は、 ### Jest のセットアップ -Jest はバッテリー付属のユニットテストソリューションを提供するために Facebook が開発したテストランナです。 Jest の詳細については[公式ドキュメント](https://facebook.github.io/jest/) を参照してください。 +Jest はバッテリー付属のユニットテストソリューションを提供するために Facebook が開発したテストランナです。 Jest の詳細については[公式ドキュメント](https://jestjs.io/) を参照してください。 Jest と Vue Test Utils をインストールします。 @@ -154,4 +154,4 @@ describe('HelloWorld.vue', () => { ### リソース - [この記事のサンプルプロジェクト](https://github.com/vuejs/vue-test-utils-typescript-example) -- [Jest](https://facebook.github.io/jest/) +- [Jest](https://jestjs.io/) diff --git a/docs/ja/guides/using-with-vuex.md b/docs/ja/guides/using-with-vuex.md index 19195e611..f9626f9c7 100644 --- a/docs/ja/guides/using-with-vuex.md +++ b/docs/ja/guides/using-with-vuex.md @@ -95,7 +95,7 @@ describe('Actions.vue', () => { 次に、新しい `Vuex.store` をモックした値で呼び出すことによってモックのストアを作成します。それをアクションに渡すだけです。それが気にしなければならないことの全てだからです。 -アクションは、[Jest のモック関数](https://facebook.github.io/jest/docs/en/mock-functions.html)です。これらモック関数は、アクションが呼び出されたかどうかを検証するメソッドを提供します。 +アクションは、[Jest のモック関数](https://jestjs.io/docs/en/mock-functions.html)です。これらモック関数は、アクションが呼び出されたかどうかを検証するメソッドを提供します。 アクションのスタブが期待どおりに呼び出されたことを検証することができます。 diff --git a/docs/ru/guides/choosing-a-test-runner.md b/docs/ru/guides/choosing-a-test-runner.md index 5536ac06f..6411cc5b9 100644 --- a/docs/ru/guides/choosing-a-test-runner.md +++ b/docs/ru/guides/choosing-a-test-runner.md @@ -6,7 +6,7 @@ Test runner — это программа, которая запускает т Есть несколько вещей, которые следует учитывать при выборе программы запуска тестов: набор функций, производительность и поддержка предварительной компиляции однофайловых компонентов. После тщательного сравнения существующих библиотек мы рекомендуем два варианта конфигурации: -- [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) наиболее функциональный способ запуска тестов. Он меньше всех требует конфигурирования, устанавливает JSDOM по умолчанию, предоставляет встроенные проверки (assertions) и имеет отличный интерфейс для работы через командную строку. Тем не менее, вам понадобится пре-процессор, чтобы иметь возможность импортировать однофайловые компоненты в свои тесты. Мы создали пре-процессор `vue-jest`, который может обрабатывать наиболее распространённые функции однофайловых компонентов, но в настоящее время он не имеет 100% паритетности функций с `vue-loader`. +- [Jest](https://jestjs.io/docs/en/getting-started.html#content) наиболее функциональный способ запуска тестов. Он меньше всех требует конфигурирования, устанавливает JSDOM по умолчанию, предоставляет встроенные проверки (assertions) и имеет отличный интерфейс для работы через командную строку. Тем не менее, вам понадобится пре-процессор, чтобы иметь возможность импортировать однофайловые компоненты в свои тесты. Мы создали пре-процессор `vue-jest`, который может обрабатывать наиболее распространённые функции однофайловых компонентов, но в настоящее время он не имеет 100% паритетности функций с `vue-loader`. - [mocha-webpack](https://github.com/zinserjan/mocha-webpack) — это обёртка вокруг webpack + Mocha, но с более оптимизированным интерфейсом и режимом отслеживания. Преимущества этой конфигурации в том, что мы можем получить полную поддержку однофайловых компонентов с помощью webpack + `vue-loader`, но для этого требуется больше настройки. diff --git a/docs/ru/guides/testing-async-components.md b/docs/ru/guides/testing-async-components.md index 8b4415e6a..e26e23a71 100644 --- a/docs/ru/guides/testing-async-components.md +++ b/docs/ru/guides/testing-async-components.md @@ -2,7 +2,7 @@ Чтобы упростить тестирование, `vue-test-utils` применяет обновления DOM _синхронно_. Однако, есть некоторые тонкости, когда вам необходимо протестировать компонент с асинхронным поведением, таким как коллбэки или промисы. -Одними из самых распространённых поведений являются запросы к API и действия Vuex. В примерах ниже будет показано как протестировать метод, который делает запрос к API. В этом примере используется Jest для запуска тестов и мок для HTTP-библиотеки `axios`. Подробнее о использовании моков в Jest можно прочитать [здесь](https://facebook.github.io/jest/docs/en/manual-mocks.html#content). +Одними из самых распространённых поведений являются запросы к API и действия Vuex. В примерах ниже будет показано как протестировать метод, который делает запрос к API. В этом примере используется Jest для запуска тестов и мок для HTTP-библиотеки `axios`. Подробнее о использовании моков в Jest можно прочитать [здесь](https://jestjs.io/docs/en/manual-mocks.html#content). Реализация мока для `axios` выглядит так: diff --git a/docs/ru/guides/testing-single-file-components-with-jest.md b/docs/ru/guides/testing-single-file-components-with-jest.md index 654c00009..e90ee2597 100644 --- a/docs/ru/guides/testing-single-file-components-with-jest.md +++ b/docs/ru/guides/testing-single-file-components-with-jest.md @@ -2,7 +2,7 @@ > Пример проекта для этой конфигурации доступен на [GitHub](https://github.com/vuejs/vue-test-utils-jest-example). -Jest — это программа для запуска тестов, разработанная Facebook, направленная на предоставление функционального решения для модульного тестирования. Вы можете узнать больше о Jest в [официальной документации](https://facebook.github.io/jest/). +Jest — это программа для запуска тестов, разработанная Facebook, направленная на предоставление функционального решения для модульного тестирования. Вы можете узнать больше о Jest в [официальной документации](https://jestjs.io/). ### Установка Jest @@ -122,7 +122,7 @@ npm install --save-dev babel-jest ### Расположение файлов тестов -По умолчанию Jest будет рекурсивно выбирать все файлы с расширением `.spec.js` или `.test.js` во всём проекте. Если это поведение не соответствует вашим потребностям, то возможно [изменить `testRegex`](https://facebook.github.io/jest/docs/en/configuration.html#testregex-string) в секции конфигурации в файле `package.json`. +По умолчанию Jest будет рекурсивно выбирать все файлы с расширением `.spec.js` или `.test.js` во всём проекте. Если это поведение не соответствует вашим потребностям, то возможно [изменить `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string) в секции конфигурации в файле `package.json`. Jest рекомендует создать каталог `__tests__` рядом с тестируемым кодом, но не стесняйтесь структурировать ваши тесты по своему усмотрению. Просто остерегайтесь того, что Jest создаст каталог `__snapshots__` рядом с тестовыми файлами, который необходим для тестирования с помощью моментальных снимков. @@ -130,7 +130,7 @@ Jest рекомендует создать каталог `__tests__` рядом Jest может быть использован для генерации отчётов о покрытии кода в нескольких форматах. Ниже приведён простой пример для начала: -Расширьте вашу конфигурацию `jest` (обычно расположенную в `package.json` или `jest.config.js`) с помощью опции [collectCoverage](https://facebook.github.io/jest/docs/en/configuration.html#collectcoverage-boolean), и затем добавьте массив [collectCoverageFrom](https://facebook.github.io/jest/docs/en/configuration.html#collectcoveragefrom-array) для определения файлов, для которых требуется собирать информацию о покрытии. +Расширьте вашу конфигурацию `jest` (обычно расположенную в `package.json` или `jest.config.js`) с помощью опции [collectCoverage](https://jestjs.io/docs/en/configuration.html#collectcoverage-boolean), и затем добавьте массив [collectCoverageFrom](https://jestjs.io/docs/en/configuration.html#collectcoveragefrom-array) для определения файлов, для которых требуется собирать информацию о покрытии. ```json { @@ -142,7 +142,7 @@ Jest может быть использован для генерации отч } ``` -Это включит отчёты о покрытии с использованием [стандартных отчётов о покрытии](https://facebook.github.io/jest/docs/en/configuration.html#coveragereporters-array-string). Вы можете настроить их с помощью опции `coverageReporters`: +Это включит отчёты о покрытии с использованием [стандартных отчётов о покрытии](https://jestjs.io/docs/en/configuration.html#coveragereporters-array-string). Вы можете настроить их с помощью опции `coverageReporters`: ```json { @@ -153,11 +153,11 @@ Jest может быть использован для генерации отч } ``` -Дополнительную информацию можно найти в [документации по конфигурации Jest](https://facebook.github.io/jest/docs/en/configuration.html#collectcoverage-boolean), где вы можете найти параметры для пороговых значений покрытия, каталоги вывода данных и т.д. +Дополнительную информацию можно найти в [документации по конфигурации Jest](https://jestjs.io/docs/en/configuration.html#collectcoverage-boolean), где вы можете найти параметры для пороговых значений покрытия, каталоги вывода данных и т.д. ### Пример спецификации -Если вы знакомы с Jasmine, то вы должны чувствовать себя как дома с [проверочным API](https://facebook.github.io/jest/docs/en/expect.html#content) Jest: +Если вы знакомы с Jasmine, то вы должны чувствовать себя как дома с [проверочным API](https://jestjs.io/docs/en/expect.html#content) Jest: ```js import { mount } from '@vue/test-utils' @@ -173,7 +173,7 @@ describe('Component', () => { ### Тестирование моментальными снимками -Когда вы монтируете компонент с помощью Vue Test Utils, вы получаете доступ к корневому элементу HTML. Это можно сохранить в виде моментального снимка для [тестирования моментальными снимками в Jest](https://facebook.github.io/jest/docs/en/snapshot-testing.html): +Когда вы монтируете компонент с помощью Vue Test Utils, вы получаете доступ к корневому элементу HTML. Это можно сохранить в виде моментального снимка для [тестирования моментальными снимками в Jest](https://jestjs.io/docs/en/snapshot-testing.html): ```js test('renders correctly', () => { @@ -203,5 +203,5 @@ npm install --save-dev jest-serializer-vue - [Пример проекта для этой конфигурации](https://github.com/vuejs/vue-test-utils-jest-example) - [Примеры и слайды с Vue Conf 2017](https://github.com/codebryo/vue-testing-with-jest-conf17) -- [Jest](https://facebook.github.io/jest/) +- [Jest](https://jestjs.io/) - [Babel preset env](https://github.com/babel/babel-preset-env) diff --git a/docs/ru/guides/using-with-typescript.md b/docs/ru/guides/using-with-typescript.md index e4fa4b407..12d6fa6d4 100644 --- a/docs/ru/guides/using-with-typescript.md +++ b/docs/ru/guides/using-with-typescript.md @@ -30,7 +30,7 @@ $ vue create hello-world ### Настройка Jest -Jest — это программа для запуска тестов, разработанный Facebook и направленный на предоставление многофункционального решения для модульного тестирования. Вы можете узнать больше о Jest на его [официальной документации](https://facebook.github.io/jest/). +Jest — это программа для запуска тестов, разработанный Facebook и направленный на предоставление многофункционального решения для модульного тестирования. Вы можете узнать больше о Jest на его [официальной документации](https://jestjs.io/). Установить Jest и Vue Test Utils: @@ -154,4 +154,4 @@ describe('HelloWorld.vue', () => { ### Ресурсы - [Пример проекта для этой конфигурации](https://github.com/vuejs/vue-test-utils-typescript-example) -- [Jest](https://facebook.github.io/jest/) +- [Jest](https://jestjs.io/) diff --git a/docs/ru/guides/using-with-vuex.md b/docs/ru/guides/using-with-vuex.md index 51a166784..65554eef7 100644 --- a/docs/ru/guides/using-with-vuex.md +++ b/docs/ru/guides/using-with-vuex.md @@ -95,7 +95,7 @@ describe('Actions.vue', () => { Затем мы создаём мок хранилища вызовом `new Vuex.store` с нашими заготовленными значениями. Мы передаём ему только действия, так как это всё, что нам необходимо. -Действия реализуются с помощью [mock-функций jest](https://facebook.github.io/jest/docs/en/mock-functions.html). Эти mock-функции предоставляют нам методы для проверки, вызывались ли действия или нет. +Действия реализуются с помощью [mock-функций jest](https://jestjs.io/docs/en/mock-functions.html). Эти mock-функции предоставляют нам методы для проверки, вызывались ли действия или нет. Затем мы можем проверить в наших тестах, что заглушка действия была вызвана когда ожидалось. diff --git a/docs/zh/guides/choosing-a-test-runner.md b/docs/zh/guides/choosing-a-test-runner.md index fa83202a2..852a0b3e4 100644 --- a/docs/zh/guides/choosing-a-test-runner.md +++ b/docs/zh/guides/choosing-a-test-runner.md @@ -6,7 +6,7 @@ 当然在我们选用测试运行器的时候也需要考虑一些事项:功能集合、性能和对单文件组件预编译的支持等。在仔细比对现有的库之后,我们推荐其中的两个测试运行器: -- [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) 是功能最全的测试运行器。它所需的配置是最少的,默认安装了 JSDOM,内置断言且命令行的用户体验非常好。不过你需要一个能够将单文件组件导入到测试中的预处理器。我们已经创建了 `vue-jest` 预处理器来处理最常见的单文件组件特性,但仍不是 `vue-loader` 100% 的功能。 +- [Jest](https://jestjs.io/docs/en/getting-started.html#content) 是功能最全的测试运行器。它所需的配置是最少的,默认安装了 JSDOM,内置断言且命令行的用户体验非常好。不过你需要一个能够将单文件组件导入到测试中的预处理器。我们已经创建了 `vue-jest` 预处理器来处理最常见的单文件组件特性,但仍不是 `vue-loader` 100% 的功能。 - [mocha-webpack](https://github.com/zinserjan/mocha-webpack) 是一个 webpack + Mocha 的包裹器,同时包含了更顺畅的接口和侦听模式。这些设置的好处在于我们能够通过 webpack + `vue-loader` 得到完整的单文件组件支持,但这本身是需要很多配置的。 diff --git a/docs/zh/guides/testing-async-components.md b/docs/zh/guides/testing-async-components.md index 2d45d04bd..36a1febd2 100644 --- a/docs/zh/guides/testing-async-components.md +++ b/docs/zh/guides/testing-async-components.md @@ -2,7 +2,7 @@ 为了让测试变得简单,`@vue/test-utils` *同步*应用 DOM 更新。不过当测试一个带有回调或 Promise 等异步行为的组件时,你需要留意一些技巧。 -API 调用和 Vuex action 都是最常见的异步行为之一。下列例子展示了如何测试一个会调用到 API 的方法。这个例子使用 Jest 运行测试用例同时模拟了 HTTP 库 `axios`。更多关于 Jest 的手动模拟的介绍可移步[这里](https://facebook.github.io/jest/docs/en/manual-mocks.html#content)。 +API 调用和 Vuex action 都是最常见的异步行为之一。下列例子展示了如何测试一个会调用到 API 的方法。这个例子使用 Jest 运行测试用例同时模拟了 HTTP 库 `axios`。更多关于 Jest 的手动模拟的介绍可移步[这里](https://jestjs.io/docs/en/manual-mocks.html#content)。 `axios` 的模拟实现大概是这个样子的: diff --git a/docs/zh/guides/testing-single-file-components-with-jest.md b/docs/zh/guides/testing-single-file-components-with-jest.md index 36fcda8ac..277aa845c 100644 --- a/docs/zh/guides/testing-single-file-components-with-jest.md +++ b/docs/zh/guides/testing-single-file-components-with-jest.md @@ -2,7 +2,7 @@ > 我们在 [GitHub](https://github.com/vuejs/vue-test-utils-jest-example) 上放有一个关于这些设置的示例工程。 -Jest 是一个由 Facebook 开发的测试运行器,致力于提供一个“bettery-included”单元测试解决方案。你可以在其[官方文档](https://facebook.github.io/jest/)学习到更多 Jest 的知识。 +Jest 是一个由 Facebook 开发的测试运行器,致力于提供一个“bettery-included”单元测试解决方案。你可以在其[官方文档](https://jestjs.io/)学习到更多 Jest 的知识。 ### 安装 Jest @@ -120,7 +120,7 @@ npm install --save-dev babel-jest ### 放置测试文件 -默认情况下,Jest 将会递归的找到整个工程里所有 `.spec.js` 或 `.test.js` 扩展名的文件。如果这不符合你的需求,你也可以在 `package.json` 里的配置段落中[改变它的 `testRegex`](https://facebook.github.io/jest/docs/en/configuration.html#testregex-string)。 +默认情况下,Jest 将会递归的找到整个工程里所有 `.spec.js` 或 `.test.js` 扩展名的文件。如果这不符合你的需求,你也可以在 `package.json` 里的配置段落中[改变它的 `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string)。 Jest 推荐你在被测试代码的所在目录下创建一个 `__tests__` 目录,但你也可以为你的测试文件随意设计自己习惯的文件结构。不过要当心 Jest 会为快照测试在临近测试文件的地方创建一个 `__snapshots__` 目录。 @@ -128,7 +128,7 @@ Jest 推荐你在被测试代码的所在目录下创建一个 `__tests__` 目 Jest 可以被用来生成多种格式的测试覆盖率报告。以下是一个简单的起步的例子: -扩展你的 `jest` 配置 (通常在 `package.json` 或 `jest.config.js` 中) 的 [`collectCoverage`](https://facebook.github.io/jest/docs/en/configuration.html#collectcoverage-boolean) 选项,然后添加 [`collectCoverageFrom`](https://facebook.github.io/jest/docs/en/configuration.html#collectcoveragefrom-array) 数组来定义需要收集测试覆盖率信息的文件。 +扩展你的 `jest` 配置 (通常在 `package.json` 或 `jest.config.js` 中) 的 [`collectCoverage`](https://jestjs.io/docs/en/configuration.html#collectcoverage-boolean) 选项,然后添加 [`collectCoverageFrom`](https://jestjs.io/docs/en/configuration.html#collectcoveragefrom-array) 数组来定义需要收集测试覆盖率信息的文件。 ```json { @@ -140,7 +140,7 @@ Jest 可以被用来生成多种格式的测试覆盖率报告。以下是一个 } ``` -这样就会开启[默认格式的测试覆盖率报告](https://facebook.github.io/jest/docs/en/configuration.html#coveragereporters-array-string)。你可以通过 `coverageReporters` 选项来定制它们。 +这样就会开启[默认格式的测试覆盖率报告](https://jestjs.io/docs/en/configuration.html#coveragereporters-array-string)。你可以通过 `coverageReporters` 选项来定制它们。 ```json { @@ -151,11 +151,11 @@ Jest 可以被用来生成多种格式的测试覆盖率报告。以下是一个 } ``` -更多文档内容请移步至 [Jest 配置文档](https://facebook.github.io/jest/docs/en/configuration.html#collectcoverage-boolean),在那里你可以找到覆盖率阀值、目标输出目录等选项。 +更多文档内容请移步至 [Jest 配置文档](https://jestjs.io/docs/en/configuration.html#collectcoverage-boolean),在那里你可以找到覆盖率阀值、目标输出目录等选项。 ### 测试规范示例 -如果你已经熟悉了 Jasmine,你应该很适应 Jest 的[断言 API](https://facebook.github.io/jest/docs/en/expect.html#content): +如果你已经熟悉了 Jasmine,你应该很适应 Jest 的[断言 API](https://jestjs.io/docs/en/expect.html#content): ```js import { mount } from '@vue/test-utils' @@ -171,7 +171,7 @@ describe('Component', () => { ### 快照测试 -当你用 Vue Test Utils 挂载一个组件时,你可以访问到 HTML 根元素。这可以保存为一个快照为 [Jest 快照测试](https://facebook.github.io/jest/docs/en/snapshot-testing.html)所用。 +当你用 Vue Test Utils 挂载一个组件时,你可以访问到 HTML 根元素。这可以保存为一个快照为 [Jest 快照测试](https://jestjs.io/docs/en/snapshot-testing.html)所用。 ```js test('renders correctly', () => { @@ -203,5 +203,5 @@ npm install --save-dev jest-serializer-vue - [该设置的示例工程](https://github.com/vuejs/vue-test-utils-jest-example) - [Vue Conf 2017 中的示例和幻灯片](https://github.com/codebryo/vue-testing-with-jest-conf17) -- [Jest](https://facebook.github.io/jest/) +- [Jest](https://jestjs.io/) - [Babel preset env](https://github.com/babel/babel-preset-env) diff --git a/docs/zh/guides/using-with-typescript.md b/docs/zh/guides/using-with-typescript.md index 1c053278a..4013c944e 100644 --- a/docs/zh/guides/using-with-typescript.md +++ b/docs/zh/guides/using-with-typescript.md @@ -30,7 +30,7 @@ $ vue create hello-world ### 设置 Jest -Jest 是一个由 Facebook 研发的测试运行器,它致力于提供一个低能耗的测试解决方案。你可以在其[官方文档](https://facebook.github.io/jest/)中了解更多 Jest 的情况。 +Jest 是一个由 Facebook 研发的测试运行器,它致力于提供一个低能耗的测试解决方案。你可以在其[官方文档](https://jestjs.io/)中了解更多 Jest 的情况。 安装 Jest 和 Vue Test Utils: @@ -154,4 +154,4 @@ describe('HelloWorld.vue', () => { ### 相关资料 - [该设置的示例工程](https://github.com/vuejs/vue-test-utils-typescript-example) -- [Jest](https://facebook.github.io/jest/) +- [Jest](https://jestjs.io/) diff --git a/docs/zh/guides/using-with-vuex.md b/docs/zh/guides/using-with-vuex.md index bcc4b09f3..99c55e432 100644 --- a/docs/zh/guides/using-with-vuex.md +++ b/docs/zh/guides/using-with-vuex.md @@ -95,7 +95,7 @@ describe('Actions.vue', () => { 然后我们用 `new Vuex.Store` 伪造了一个 store 并填入假数据。我们只把它传递给 action,因为我们只关心这个。 -该 action 是 [Jest 伪造函数](https://facebook.github.io/jest/docs/en/mock-functions.html)。这些伪造函数让我们去断言该 action 是否被调用。 +该 action 是 [Jest 伪造函数](https://jestjs.io/docs/en/mock-functions.html)。这些伪造函数让我们去断言该 action 是否被调用。 然后我们可以在我们的测试中断言 action 存根是否如预期般被调用。 From fbb204ca0859ee5a050458d21f09f28a63ec64cb Mon Sep 17 00:00:00 2001 From: Dustin Ryerson Date: Wed, 6 Feb 2019 14:57:27 -0800 Subject: [PATCH 2/2] Fix testRegex link --- docs/guides/testing-single-file-components-with-jest.md | 2 +- docs/ja/guides/testing-single-file-components-with-jest.md | 2 +- docs/ru/guides/testing-single-file-components-with-jest.md | 2 +- docs/zh/guides/testing-single-file-components-with-jest.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guides/testing-single-file-components-with-jest.md b/docs/guides/testing-single-file-components-with-jest.md index 594b729a0..d56f404bd 100644 --- a/docs/guides/testing-single-file-components-with-jest.md +++ b/docs/guides/testing-single-file-components-with-jest.md @@ -122,7 +122,7 @@ Example `.babelrc`: ### Placing Test Files -By default, Jest will recursively pick up all files that have a `.spec.js` or `.test.js` extension in the entire project. If this does not fit your needs, it's possible [to change the `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string) in the config section in the `package.json` file. +By default, Jest will recursively pick up all files that have a `.spec.js` or `.test.js` extension in the entire project. If this does not fit your needs, it's possible [to change the `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string-array-string) in the config section in the `package.json` file. Jest recommends creating a `__tests__` directory right next to the code being tested, but feel free to structure your tests as you see fit. Just beware that Jest would create a `__snapshots__` directory next to test files that performs snapshot testing. diff --git a/docs/ja/guides/testing-single-file-components-with-jest.md b/docs/ja/guides/testing-single-file-components-with-jest.md index 493d5f66e..abc1be465 100644 --- a/docs/ja/guides/testing-single-file-components-with-jest.md +++ b/docs/ja/guides/testing-single-file-components-with-jest.md @@ -120,7 +120,7 @@ webpack で `babel-preset-env` を使用するとした場合、webpack は ES M ### テストファイルの配置 -デフォルトでは、Jest はプロジェクト全体で `.spec.js` または `.test.js` 拡張子を持つすべてのファイルを再帰的に取得します。これがあなたのニーズに合わない場合は、`package.json` ファイルの config セクションで[testRegex を変更する](https://jestjs.io/docs/en/configuration.html#testregex-string)ことが可能です。 +デフォルトでは、Jest はプロジェクト全体で `.spec.js` または `.test.js` 拡張子を持つすべてのファイルを再帰的に取得します。これがあなたのニーズに合わない場合は、`package.json` ファイルの config セクションで[testRegex を変更する](https://jestjs.io/docs/en/configuration.html#testregex-string-array-string)ことが可能です。 Jest は、テスト対象のコードのすぐ隣に`__tests__`ディレクトリを作成することを推奨していますが、適切にテストを構造化することは自由です。 Jest がスナップショットテストを実行するテストファイルの隣に`__snapshots__`ディレクトリを作成することに注意してください。 diff --git a/docs/ru/guides/testing-single-file-components-with-jest.md b/docs/ru/guides/testing-single-file-components-with-jest.md index e90ee2597..1102e8de6 100644 --- a/docs/ru/guides/testing-single-file-components-with-jest.md +++ b/docs/ru/guides/testing-single-file-components-with-jest.md @@ -122,7 +122,7 @@ npm install --save-dev babel-jest ### Расположение файлов тестов -По умолчанию Jest будет рекурсивно выбирать все файлы с расширением `.spec.js` или `.test.js` во всём проекте. Если это поведение не соответствует вашим потребностям, то возможно [изменить `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string) в секции конфигурации в файле `package.json`. +По умолчанию Jest будет рекурсивно выбирать все файлы с расширением `.spec.js` или `.test.js` во всём проекте. Если это поведение не соответствует вашим потребностям, то возможно [изменить `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string-array-string) в секции конфигурации в файле `package.json`. Jest рекомендует создать каталог `__tests__` рядом с тестируемым кодом, но не стесняйтесь структурировать ваши тесты по своему усмотрению. Просто остерегайтесь того, что Jest создаст каталог `__snapshots__` рядом с тестовыми файлами, который необходим для тестирования с помощью моментальных снимков. diff --git a/docs/zh/guides/testing-single-file-components-with-jest.md b/docs/zh/guides/testing-single-file-components-with-jest.md index 277aa845c..d70ca90de 100644 --- a/docs/zh/guides/testing-single-file-components-with-jest.md +++ b/docs/zh/guides/testing-single-file-components-with-jest.md @@ -120,7 +120,7 @@ npm install --save-dev babel-jest ### 放置测试文件 -默认情况下,Jest 将会递归的找到整个工程里所有 `.spec.js` 或 `.test.js` 扩展名的文件。如果这不符合你的需求,你也可以在 `package.json` 里的配置段落中[改变它的 `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string)。 +默认情况下,Jest 将会递归的找到整个工程里所有 `.spec.js` 或 `.test.js` 扩展名的文件。如果这不符合你的需求,你也可以在 `package.json` 里的配置段落中[改变它的 `testRegex`](https://jestjs.io/docs/en/configuration.html#testregex-string-array-string)。 Jest 推荐你在被测试代码的所在目录下创建一个 `__tests__` 目录,但你也可以为你的测试文件随意设计自己习惯的文件结构。不过要当心 Jest 会为快照测试在临近测试文件的地方创建一个 `__snapshots__` 目录。