├── .editorconfig
├── .gitattributes
├── es_ES
├── code-of-conduct.md
├── contributing.md
├── docs
│ ├── 01-writing-tests.md
│ ├── 02-execution-context.md
│ ├── 03-assertions.md
│ ├── 04-snapshot-testing.md
│ ├── 05-command-line.md
│ └── recipes
│ │ ├── browser-testing.md
│ │ ├── code-coverage.md
│ │ ├── endpoint-testing.md
│ │ ├── react.md
│ │ ├── typescript.md
│ │ └── when-to-use-plan.md
├── maintaining.md
└── readme.md
├── fr_FR
├── code-of-conduct.md
├── contributing.md
├── docs
│ ├── 01-writing-tests.md
│ ├── 02-execution-context.md
│ ├── 03-assertions.md
│ ├── 04-snapshot-testing.md
│ ├── 05-command-line.md
│ ├── 06-configuration.md
│ ├── 07-test-timeouts.md
│ ├── 08-common-pitfalls.md
│ ├── recipes
│ │ ├── babel.md
│ │ ├── browser-testing.md
│ │ ├── code-coverage.md
│ │ ├── debugging-with-chrome-devtools.md
│ │ ├── debugging-with-vscode.md
│ │ ├── debugging-with-webstorm.md
│ │ ├── endpoint-testing-with-mongoose.md
│ │ ├── endpoint-testing.md
│ │ ├── es-modules.md
│ │ ├── isolated-mongodb-integration-tests.md
│ │ ├── passing-arguments-to-your-test-files.md
│ │ ├── puppeteer.md
│ │ ├── react.md
│ │ ├── shared-workers.md
│ │ ├── splitting-tests-ci.md
│ │ ├── test-setup.md
│ │ ├── testing-with-selenium-webdriverjs.md
│ │ ├── typescript.md
│ │ ├── vue.md
│ │ ├── watch-mode.md
│ │ └── when-to-use-plan.md
│ └── support-statement.md
├── maintaining.md
├── readme.md
└── related
│ ├── ava-codemods
│ └── readme.md
│ ├── babel
│ └── README.md
│ └── eslint-plugin-ava
│ ├── docs
│ ├── new-rule.md
│ └── rules
│ │ ├── assertion-arguments.md
│ │ ├── hooks-order.md
│ │ ├── max-asserts.md
│ │ ├── no-async-fn-without-await.md
│ │ ├── no-duplicate-modifiers.md
│ │ ├── no-identical-title.md
│ │ ├── no-ignored-test-files.md
│ │ ├── no-import-test-files.md
│ │ ├── no-incorrect-deep-equal.md
│ │ ├── no-inline-assertions.md
│ │ ├── no-nested-tests.md
│ │ ├── no-only-test.md
│ │ ├── no-skip-assert.md
│ │ ├── no-skip-test.md
│ │ ├── no-todo-implementation.md
│ │ ├── no-todo-test.md
│ │ ├── no-unknown-modifiers.md
│ │ ├── prefer-async-await.md
│ │ ├── prefer-power-assert.md
│ │ ├── prefer-t-regex.md
│ │ ├── test-title-format.md
│ │ ├── test-title.md
│ │ ├── use-t-throws-async-well.md
│ │ ├── use-t-well.md
│ │ ├── use-t.md
│ │ ├── use-test.md
│ │ └── use-true-false.md
│ └── readme.md
├── it_IT
├── code-of-conduct.md
├── contributing.md
├── docs
│ ├── common-pitfalls.md
│ ├── recipes
│ │ ├── babelrc.md
│ │ ├── browser-testing.md
│ │ ├── code-coverage.md
│ │ ├── debugging-with-chrome-devtools.md
│ │ ├── debugging-with-vscode.md
│ │ ├── debugging-with-webstorm.md
│ │ ├── endpoint-testing.md
│ │ ├── isolated-mongodb-integration-tests.md
│ │ ├── jspm-systemjs.md
│ │ ├── precompiling-with-webpack.md
│ │ ├── react.md
│ │ ├── typescript.md
│ │ ├── vue.md
│ │ ├── watch-mode.md
│ │ └── when-to-use-plan.md
│ └── specs
│ │ └── 001 - Improving language support.md
├── maintaining.md
└── readme.md
├── ja_JP
├── code-of-conduct.md
├── contributing.md
├── docs
│ └── recipes
│ │ ├── code-coverage.md
│ │ ├── endpoint-testing.md
│ │ └── when-to-use-plan.md
└── readme.md
├── ko_KR
├── docs
│ ├── 01-writing-tests.md
│ ├── 02-execution-context.md
│ ├── 03-assertions.md
│ ├── 04-snapshot-testing.md
│ ├── 05-command-line.md
│ ├── 06-configuration.md
│ ├── 07-test-timeouts.md
│ ├── 08-common-pitfalls.md
│ └── recipes
│ │ ├── babel.md
│ │ ├── browser-testing.md
│ │ ├── code-coverage.md
│ │ ├── debugging-with-chrome-devtools.md
│ │ ├── endpoint-testing.md
│ │ ├── es-modules.md
│ │ ├── passing-arguments-to-your-test-files.md
│ │ ├── puppeteer.md
│ │ ├── splitting-tests-ci.md
│ │ ├── typescript.md
│ │ ├── watch-mode.md
│ │ └── when-to-use-plan.md
├── maintaining.md
└── readme.md
├── pl_PL
├── code-of-conduct.md
├── contributing.md
├── docs
│ ├── 01-writing-tests.md
│ ├── 02-execution-context.md
│ ├── 03-assertions.md
│ ├── 04-snapshot-testing.md
│ ├── 05-command-line.md
│ ├── 06-configuration.md
│ ├── 07-test-timeouts.md
│ ├── 08-common-pitfalls.md
│ ├── recipes
│ │ ├── babel.md
│ │ ├── browser-testing.md
│ │ ├── code-coverage.md
│ │ ├── debugging-with-chrome-devtools.md
│ │ ├── debugging-with-vscode.md
│ │ ├── debugging-with-webstorm.md
│ │ ├── endpoint-testing-with-mongoose.md
│ │ ├── endpoint-testing.md
│ │ ├── es-modules.md
│ │ ├── flow.md
│ │ ├── isolated-mongodb-integration-tests.md
│ │ ├── passing-arguments-to-your-test-files.md
│ │ ├── puppeteer.md
│ │ ├── react.md
│ │ ├── test-setup.md
│ │ ├── testing-with-selenium-webdriverjs.md
│ │ ├── typescript.md
│ │ ├── vue.md
│ │ ├── watch-mode.md
│ │ └── when-to-use-plan.md
│ └── support-statement.md
├── maintaining.md
└── readme.md
├── pt_BR
├── code-of-conduct.md
├── contributing.md
├── docs
│ └── recipes
│ │ ├── code-coverage.md
│ │ ├── endpoint-testing.md
│ │ └── when-to-use-plan.md
└── readme.md
├── readme.md
├── ru_RU
├── code-of-conduct.md
├── contributing.md
├── docs
│ └── recipes
│ │ ├── browser-testing.md
│ │ ├── code-coverage.md
│ │ ├── endpoint-testing.md
│ │ ├── typescript.md
│ │ ├── watch-mode.md
│ │ └── when-to-use-plan.md
└── readme.md
└── zh_CN
├── code-of-conduct.md
├── contributing.md
├── docs
└── recipes
│ ├── browser-testing.md
│ ├── code-coverage.md
│ ├── endpoint-testing.md
│ ├── typescript.md
│ ├── watch-mode.md
│ └── when-to-use-plan.md
└── readme.md
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = tab
5 | end_of_line = lf
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 |
10 | [*.md]
11 | trim_trailing_whitespace = false
12 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/es_ES/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traductor**
3 |
4 | Esta es la traducción del archivo [code-of-conduct.md](https://github.com/avajs/ava/blob/main/.github/CODE_OF_CONDUCT.md). Aquí hay un [enlace](https://github.com/avajs/ava/compare/4111f9483f2ff6a158b603735a712eee3ab074c4...main#diff-d3030a18b089fdb1fbfabf6e75e4aef0) a las diferencias con la rama master de AVA (Si al hacer clic en el enlace no se encuentran modificaciones en el archivo `code-of-conduct.md`, será por que la traducción está actualizada).
5 | ___
6 | # Código de Conducta para Contribuyentes
7 |
8 | Traducciones: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/code-of-conduct.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/code-of-conduct.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/code-of-conduct.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/code-of-conduct.md), [Portugués](https://github.com/avajs/ava-docs/blob/main/pt_BR/code-of-conduct.md)
9 |
10 | Como contribuyentes y administradores de este proyecto, y en el interés de fomentar una comunidad abierta y acogedora, nos comprometemos a respetar a todas las personas que colaboran reportando errores, solicitando nuevas funcionalidades, actualizando documentación, generando *pull requests*, entre otras actividades.
11 |
12 | Nos comprometemos a hacer que la participación en este proyecto sea una experiencia libre de acoso para todos, independientemente de su experiencia, género, identidad y expresión de género, orientación sexual, discapacidad, apariencia física, dimensión corporal, raza, etnia, edad, religión o nacionalidad.
13 |
14 | Ejemplos de comportamiento inaceptable por participantes son:
15 |
16 | * El uso de lenguaje o imágenes sexuales
17 | * Ataques personales
18 | * Comentarios insultantes o despectivos (*trolling*)
19 | * Publicación de información privada de terceros sin su consentimiento, como direcciones físicas o electrónicas
20 | * Conducta deshonesta o no profesional
21 |
22 | Administradores del proyecto tienen el derecho y la responsabilidad de eliminar, editar o rechazar comentarios, *commits*, código, ediciones de documentación, *issues*, y otras contribuciones que no están alineadas con este Código de Conducta, o de prohibir temporal o permanentemente a cualquier colaborador cuyo comportamiento sea inapropiado, amenazante, ofensivo o perjudicial.
23 |
24 | Con la adopción de este Código de Conducta, los administradores se comprometen a aplicar de manera justa y consistente estos principios a todos los aspectos de la gestión de este proyecto. Los administradores que no sigan o que no hagan cumplir este Código de Conducta pueden ser eliminados de forma permanente del equipo administrador.
25 |
26 | Este código de conducta aplica, tanto a los espacios del proyecto como a espacios públicos, donde un individuo está representando al proyecto o su comunidad.
27 |
28 | Ejemplos de abuso, acoso u otro comportamiento inaceptable pueden ser reportados al administrador del proyecto en sindresorhus@gmail.com. Todas las quejas serán revisadas e investigadas, generando un resultado apropiado a las circunstancias. Los administradores tienen la obligación de mantener la confidencialidad de la persona que reporte el incidente.
29 |
30 | Este Código de Conducta es una adaptación del [Contributor Covenant](http://contributor-covenant.org), versión 1.3.0, disponible en [http://contributor-covenant.org/version/1/3/0/es/](http://contributor-covenant.org/version/1/3/0/es/)
31 |
--------------------------------------------------------------------------------
/es_ES/docs/02-execution-context.md:
--------------------------------------------------------------------------------
1 | # Contexto de ejecución (argumento `t`)
2 |
3 | Cada prueba o hook es llamado en un contexto de ejecución. Por convención se llama `t`.
4 |
5 | ```js
6 | const test = require('ava');
7 |
8 | test('mi prueba exitosa', t => {
9 | t.pass();
10 | });
11 | ```
12 |
13 | Cada prueba o hook recibe un objeto diferente. Este objeto contiene [aserciones] (./ 03-assertions.md) así como tambien métodos y propiedades que se enumeran a continuación.
14 |
15 | ## `t.title`
16 |
17 | Titulo de la prueba.
18 |
19 | ## `t.context`
20 |
21 | Contiene el estado compartido de los hooks.
22 |
23 | ## `t.passed`
24 |
25 | Si una prueba pasa. Este valor solamente tiene un valor correcto en los hooks `test.afterEach()` y `test.afterEach.always()`.
26 |
27 | ## `t.end()`
28 |
29 | Finaliza la prueba. Funciona solamente con `test.cb()`.
30 |
31 | ## `t.log(...values)`
32 |
33 | Registra los valores contextualmente junto con el resultado de la prueba en lugar de imprimirlos inmediatamente a "stdout". Se comporta como `console.log`, pero sin soporte para tokens de marcador de posición (placeholders).
34 |
35 | ## `t.plan(count)`
36 |
37 | Planifica cuántas aserciones hay en la prueba. La prueba fallará si el recuento de aserciones real no coincide con el número de aserciones planificadas. Consulte [Planificación de afirmaciones](./03-assertions.md#assertion-planning).
38 |
39 | ## `t.teardown(fn)`
40 |
41 | Registra la función `fn` que se ejecutará una vez finalizada la prueba. Puede registrar varias funciones y se ejecutarán en orden †. Puede utilizar funciones asincrónicas: solo se ejecutará una a la vez.
42 |
43 | No puede realizar aserciones usando el objeto `t` o registrar funciones adicionales desde dentro de` fn`.
44 |
45 | Tampoco puede usar `t.teardown ()` en los hooks.
46 |
47 | † En la próxima versión de AVA, cambiaremos esto para que las funciones de desmontaje (teardown) se ejecuten en orden inverso.
48 | La última función registrada se llamará primero. Puede optar por este comportamiento ahora habilitando el experimento `reverseTeardowns`.
49 |
50 | **`package.json`**:
51 |
52 | ```json
53 | {
54 | "ava": {
55 | "nonSemVerExperiments": {
56 | "reverseTeardowns": true
57 | }
58 | }
59 | }
60 | ```
61 |
62 | **`ava.config.js`**:
63 |
64 | ```js
65 | export default {
66 | nonSemVerExperiments: {
67 | reverseTeardowns: true
68 | }
69 | }
70 | ```
71 |
72 | ## `t.timeout(ms)`
73 |
74 | Establece un tiempo de espera para la ejecución de la prueba, en milisegundos. La prueba fallará si se excede este tiempo de espera. El tiempo de espera se restablece cada vez que se realiza una aserción.
75 |
--------------------------------------------------------------------------------
/es_ES/docs/04-snapshot-testing.md:
--------------------------------------------------------------------------------
1 | # Pruebas usando snapshots
2 |
3 | AVA permite realizar pruebas usando snapshots, [presentadas por Jest](https://facebook.github.io/jest/docs/snapshot-testing.html), usando su interface de [aserciones](./03-assertions.md). Puedes tomar un snapshot de cualquier valor, así como de los elementos de React:
4 |
5 | ```js
6 | // Your component
7 | const HelloWorld = () =>
Hello World...!
;
8 |
9 | export default HelloWorld;
10 | ```
11 |
12 | ```js
13 | // Your test
14 | const test = require('ava');
15 | const render = require('react-test-renderer');
16 | const HelloWorld = require('.');
17 |
18 | test('HelloWorld component', t => {
19 | const tree = render.create().toJSON();
20 | t.snapshot(tree);
21 | });
22 | ```
23 |
24 | [Prueba este proyecto de ejemplo.](https://github.com/avajs/ava-snapshot-example)
25 |
26 | Los snapshots se almacenan junto con tus archivos de prueba. Si tus pruebas estan en una carpeta `test` o `tests` los snapshots seran guardados en una carpeta `snapshots`. Si sus pruebas están en una carpeta `__tests__`, entonces se almacenarán en una carpeta `__snapshots__`.
27 |
28 | Digamos que tienes `~/project/test/main.js` que contiene aserciones sobre snapshots. AVA creará dos archivos:
29 |
30 | * `~/project/test/snapshots/main.js.snap`
31 | * `~/project/test/snapshots/main.js.md`
32 |
33 | El primer archivo contiene el snapshot como tal y es necesario para futuras comparaciones. El segundo archivo contiene un *snapshot report*. Este se regenera cuando actualizan los snapshots. Si lo subes a tu versional de codigo fuente, puedes chequear las diferencias para ver los cambios en tu snapshot.
34 |
35 | AVA te mostrará por qué falló la verificacion de tu snapshot:
36 |
37 |
38 |
39 | Entonces puedes verificar tu código. Si el cambio fue intencional, puede usar la bandera `--update-snapshots` (o` -u`) para actualizar los snapshots:
40 |
41 | ```console
42 | $ ava --update-snapshots
43 | ```
44 |
45 | Puede especificar una ubicación fija para almacenar los snapshot en la [configuración `package.json`] de AVA (./06-configuration.md):
46 |
47 | **`package.json`:**
48 |
49 | ```json
50 | {
51 | "ava": {
52 | "snapshotDir": "custom-directory"
53 | }
54 | }
55 | ```
56 |
57 | Los archivos de snapshots se guardarán en una estructura de directorio que refleja la de tus archivos de prueba.
58 |
59 | Si estás ejecutando AVA contra archivos de prueba precompilados, AVA intentará mapeará el origen para determinar la ubicación de los archivos originales. Los snapshots se almacenarán junto a estos archivos, siguiendo las mismas reglas como si AVA hubiera ejecutado los archivos originales directamente.
60 | Esto es genial si estás escribiendo pruebas en TypeScript (mira nuestra [receta de TypeScript] (./recipes/typescript.md)).
61 |
--------------------------------------------------------------------------------
/es_ES/docs/recipes/browser-testing.md:
--------------------------------------------------------------------------------
1 | # Configurar AVA para ejecutar tests en el navegador
2 |
3 | AVA no soporta ejecutar tests en el navegador, [todavía](https://github.com/avajs/ava/issues/24). Algunas librerías requieren globales especifícos para el navegador (`window`, `document`, `navigator`, etc).
4 | Un ejemplo de esto es React, al menos si quieres usar ReactDOM.render y simular eventos con ReactTestUtils.
5 |
6 | Esta guía funciona para cualquier librería que necesita un entorno de navegador simulado.
7 |
8 | ## Instalar jsdom
9 |
10 | Instalar [jsdom](https://github.com/tmpvar/jsdom).
11 |
12 | > Una implementación en JavaScript de los estándares WHATWG DOM y HTML, para usar con node.js
13 |
14 | ```
15 | $ npm install --save-dev jsdom
16 | ```
17 |
18 | ## Configurar jsdom
19 |
20 | Crea un archivo de ayuda y guárdalo en el directorio `test/helpers`. De esta forma AVA no lo considera como un test.
21 |
22 | `test/helpers/setup-browser-env.js`:
23 |
24 | ```js
25 | global.document = require('jsdom').jsdom('');
26 | global.window = document.defaultView;
27 | global.navigator = window.navigator;
28 | ```
29 |
30 | ## Configurar tests para que usen jsdom
31 |
32 | Configura AVA para que requiera (`require`) el archivo de ayuda antes de cada test.
33 |
34 | `package.json`:
35 |
36 | ```json
37 | {
38 | "ava": {
39 | "require": [
40 | "./test/helpers/setup-browser-env.js"
41 | ]
42 | }
43 | }
44 | ```
45 |
46 | ## Disfruta!
47 |
48 | Escribe tus tests y disfruta del objeto window simulado.
49 |
50 | `test/my.react.test.js`:
51 |
52 | ```js
53 | import test from 'ava';
54 | import React from 'react';
55 | import {render} from 'react-dom';
56 | import {Simulate} from 'react-addons-test-utils';
57 | import sinon from 'sinon';
58 | import CustomInput from './components/custom-input.jsx';
59 |
60 | test('Input calls onBlur', t => {
61 | const onUserBlur = sinon.spy();
62 | const input = render(
63 | React.createElement(CustomInput, onUserBlur),
64 | div
65 | );
66 |
67 | Simulate.blur(input);
68 |
69 | t.true(onUserBlur.calledOnce);
70 | });
71 | ```
72 |
--------------------------------------------------------------------------------
/es_ES/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traductor**
3 |
4 | Esta es la traducción del archivo [endpoint-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md). Aquí hay un [enlace](https://github.com/avajs/ava/compare/4111f9483f2ff6a158b603735a712eee3ab074c4...main#diff-aee54ab6a703c02779edb3ebbb35e96f) a las diferencias con la rama master de AVA (Si al hacer clic en el enlace no se encuentran modificaciones en el archivo `endpoint-testing.md`, será por que la traducción está actualizada).
5 | ___
6 | # Testando un Endpoint
7 |
8 | Traducciones: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/endpoint-testing.md), [Français](endpoint-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/recipes/endpoint-testing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/endpoint-testing.md), [Portugués](https://github.com/avajs/ava-docs/blob/main/pt_BR/docs/recipes/endpoint-testing.md)
9 |
10 | AVA no trae un método integrado para testar endpoints, pero puedes usar cualquier biblioteca de aserción para ello. Vamos a usar [`supertest-as-promised`](https://github.com/WhoopInc/supertest-as-promised).
11 |
12 | Puesto que las pruebas se ejecutan concurrentemente, es mejor crear una instancia de servidor nueva para cada test, porque si hace referencia a la misma instancia podría mutar entre tests. Esto se puede lograr con 'test.beforeEach' y 't.context', o simplemente con una factoría:
13 |
14 | ```js
15 | function makeApp() {
16 | const app = express();
17 | app.post('/signup', signupHandler);
18 | return app;
19 | }
20 | ```
21 |
22 | A continuación, tan solo inyecta tu instancia de servidor en el supertest. El único consejo es usar una promesa o la sintaxis async/await en vez del método `end` de supertest:
23 |
24 | ```js
25 | test('signup:Success', async t => {
26 | t.plan(2);
27 |
28 | const res = await request(makeApp())
29 | .post('/signup')
30 | .send({email: 'ava@rocks.com', password: '123123'});
31 |
32 | t.is(res.status, 200);
33 | t.is(res.body.email, 'ava@rocks.com');
34 | });
35 | ```
36 |
--------------------------------------------------------------------------------
/es_ES/docs/recipes/typescript.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traductor**
3 |
4 | Esta es la traducción del archivo [typescript.md](https://github.com/avajs/ava/raw/main/typescript.md). Aquí hay un [enlace](https://github.com/avajs/ava/compare/8e2f3dca177a4283ad882596d3c1425cabb998ef...main#diff-60cce07a584082115d230f2e3d571ad6) a las diferencias con la rama master de AVA (Si al hacer clic en el enlace no se encuentran modificaciones en el archivo `typescript.md`, será por que la traducción está actualizada).
5 | ___
6 | # TypeScript
7 |
8 | Traducciones: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/typescript.md),
9 | [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/typescript.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/recipes/typescript.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/typescript.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/typescript.md)
10 |
11 | AVA viene de serie con un fichero TypeScript con las definiciones. Esto permite a los desarrolladores usar TypeScript para escribir tests.
12 |
13 | ## Configuración
14 |
15 | Primero instala [TypeScript](https://github.com/Microsoft/TypeScript).
16 |
17 | ```
18 | $ npm install --save-dev typescript
19 | ```
20 |
21 | Crea un fichero [`tsconfig.json`](https://github.com/Microsoft/TypeScript/wiki/tsconfig.json). Este fichero especifica al compilador las opciones necesarias para compilar el proyecto o el fichero de tests.
22 |
23 | ```json
24 | {
25 | "compilerOptions": {
26 | "module": "commonjs",
27 | "target": "es2015"
28 | }
29 | }
30 | ```
31 |
32 | Añade un script `test` en el fichero `package.json`. Primero compilará el proyecto y luego ejecutará AVA.
33 |
34 | ```json
35 | {
36 | "scripts": {
37 | "test": "tsc && ava"
38 | }
39 | }
40 | ```
41 |
42 |
43 | ## Añadir tests
44 |
45 | Crea un fichero `test.ts`.
46 |
47 | ```ts
48 | import test from 'ava';
49 |
50 | async function fn() {
51 | return Promise.resolve('foo');
52 | }
53 |
54 | test(async (t) => {
55 | t.is(await fn(), 'foo');
56 | });
57 | ```
58 |
59 |
60 | ## Ejecutar los tests
61 |
62 | ```
63 | $ npm test
64 | ```
65 |
--------------------------------------------------------------------------------
/fr_FR/docs/02-execution-context.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [02-execution-context.md](https://github.com/avajs/ava/blob/main/docs/02-execution-context.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-bc6837223adbc4778415cdfd8ae668260afd34f3a562e5070cc25f536c5ded0a) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `02-execution-context.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Contexte d'exécution (argument `t`)
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/02-execution-context.md)
9 |
10 | Chaque test ou hook est appelé avec un contexte d'exécution. Par convention, il s'appelle `t`.
11 |
12 | ```js
13 | import test from 'ava';
14 |
15 | test('mon test passe', t => {
16 | t.pass();
17 | });
18 | ```
19 |
20 | Chaque test ou hook reçoit un objet différent. Il contient les [assertions](./03-assertions.md) ainsi que les méthodes et les propriétés énumérées ci-dessous.
21 |
22 | ## `t.title`
23 |
24 | Le titre du test.
25 |
26 | ## `t.context`
27 |
28 | Contient l'état partagé des hooks.
29 |
30 | ## `t.passed`
31 |
32 | Lorsqu'il est utilisé dans les hooks `test.aftereach ()` ou `test.aftereach.always ()`, cela vous indique si le test est passé. Lorsqu'il est utilisé dans un test lui-même (y compris les fonctions de nettoyage), cela reste `true` jusqu'à ce qu'une assertion échoue, que le test s'est terminé par une erreur, ou qu'une fonction de nettoyage a provoqué une erreur. Cette valeur n'a aucune signification dans d'autres hooks.
33 |
34 | ## `t.log(...values)`
35 |
36 | Enregistre les valeurs contextuellement à côté du résultat du test au lieu de les imprimer immédiatement dans `stdout`. Se comporte un peu comme `console.log`, mais sans le support des littéraux de gabarits.
37 |
38 | ## `t.plan(count)`
39 |
40 | Planifie le nombre d'assertions dans le test. Le test échouera si le nombre d'assertions réel ne correspond pas au nombre d'assertions planifiées. Voir [planification des assertions](./03-assertions.md#planification-dassertion).
41 |
42 | ## `t.teardown(fn)`
43 |
44 | Enregistre la fonction `fn` qui sera exécutée après la fin du test. Vous pouvez enregistrer plusieurs fonctions. Elles seront exécutées dans l'ordre inverse, de sorte que la dernière fonction enregistrée sera exécutée en premier. Vous pouvez utiliser des fonctions asynchrones : une seule sera exécutée à la fois.
45 |
46 | Vous ne pouvez pas effectuer d'assertions en utilisant l'objet `t` ou enregistrer des fonctions supplémentaires à l'intérieur de `fn`.
47 |
48 | Vous ne pouvez pas non plus utiliser `t.teardown()` dans les hooks.
49 |
50 | ## `t.timeout(ms)`
51 |
52 | Définit un délai d'expiration pour le test, en millisecondes. Le test échouera si ce délai est dépassé. Le délai d'attente est réinitialisé chaque fois qu'une assertion est faite.
53 |
--------------------------------------------------------------------------------
/fr_FR/docs/04-snapshot-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [04-snapshot-testing.md](https://github.com/avajs/ava/blob/main/docs/04-snapshot-testing.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-4393cc239e3dbd4a27a2947be85a7bad4310a5dfa35c343e56f79baffe8d48fc) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `04-snapshot-testing.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Test d'instantané
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/04-snapshot-testing.md)
9 |
10 | AVA prend en charge les tests instantanés, [comme présentés par Jest](https://jestjs.io/fr/docs/snapshot-testing), à travers son interface [Assertions](./03-assertions.md). Vous pouvez faire un instantané de n'importe quelle valeur.
11 |
12 | Les instantanés sont stockés aux côtés de vos fichiers de test. Si vos tests se trouvent dans un dossier `test` ou `tests`, les instantanés seront stockés dans un dossier `snapshots`. Si vos tests se trouvent dans un dossier `__tests__` alors ils seront stockés dans un dossier `__snapshots__`.
13 |
14 | Si nous avons un `~/project/test/main.js` qui contient des assertions d'instantané. AVA créera deux fichiers :
15 |
16 | * `~/project/test/snapshots/main.js.snap`
17 | * `~/project/test/snapshots/main.js.md`
18 |
19 | Le premier dossier contient l'instantané réel et est requis pour les comparaisons futures. Le deuxième fichier contient votre *rapport d'instantané*. Il est régénéré lorsque vous mettez à jour vos instantanés. Si vous le confiez au contrôle des sources, vous pouvez le comparer pour voir les modifications apportées à votre instantané.
20 |
21 | AVA montrera pourquoi votre assertion d'instantané a échoué :
22 |
23 |
24 |
25 | Vous pouvez ensuite vérifier votre code. Si le changement était intentionnel, vous pouvez utiliser l'option `--update-snapshots` (ou `-u`) pour mettre à jour vos instantanés :
26 |
27 | ```console
28 | $ ava --update-snapshots
29 | ```
30 |
31 | Si vous avez besoin de mettre à jour les instantanés pour un test particulier, vous pouvez utiliser `--update-snapshots` avec par exemple `--match` ou `.only()` pour sélectionner le test.
32 |
33 | Vous pouvez définir un emplacement fixe pour stocker les fichiers d'instantanés dans la configuration d'AVA [inclus dans le `package.json`](./06-configuration.md) :
34 |
35 | **`package.json` :**
36 |
37 | ```json
38 | {
39 | "ava": {
40 | "snapshotDir": "custom-directory"
41 | }
42 | }
43 | ```
44 |
45 | Les fichiers instantanés seront enregistrés dans une arborescence qui reflète celle de vos fichiers de test.
46 |
47 | Si vous utilisez AVA avec des fichiers de test précompilés, AVA essayera d'utiliser les source maps pour déterminer l'emplacement des fichiers d'origine. Les instantanés seront stockés à côté de ces fichiers, en suivant les mêmes règles que si AVA avait exécuté les fichiers originaux directement. C'est bien si vous écrivez vos tests en TypeScript (consultez notre [recette TypeScript](./recipes/typescript.md)).
48 |
--------------------------------------------------------------------------------
/fr_FR/docs/07-test-timeouts.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [07-test-timeouts.md](https://github.com/avajs/ava/blob/main/docs/07-test-timeouts.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-359d7f196adb7d5fcf884234506213692106ed86f073ed3533d718e4c89b0375) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `07-test-timeouts.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Timeouts des tests
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/07-test-timeouts.md)
9 |
10 | [](https://stackblitz.com/github/avajs/ava/tree/main/examples/timeouts?file=test.js&terminal=test&view=editor)
11 |
12 | Le délai de AVA se comporte différemment des autres frameworks de test. AVA réinitialise un minuteur après chaque test, cela oblige les tests à s'arrêter, si aucun nouveau résultat de test est reçu dans le délai imparti. Cela peut être utilisé pour gérer les tests bloqués.
13 |
14 | Le délai d'expiration par défaut est de 10 secondes.
15 |
16 | Vous pouvez configurer un délai (timeout) via l'[option en ligne de commande](./05-command-line.md) `--timeout` ou dans la [configuration](./06-configuration.md). Ils peuvent être définis de manière qu'ils soient lisibles :
17 |
18 | ```console
19 | npx ava --timeout=10s # 10 secondes
20 | npx ava --timeout=2m # 2 minutes
21 | npx ava --timeout=100 # 100 millisecondes
22 | ```
23 |
24 | ### `t.timeout(ms, message?)`
25 |
26 | Les délais peuvent également être définis individuellement pour chaque test. Ces délais sont réinitialisés chaque fois qu'une assertion est faite. Le test échoue s'il faut plus de `ms` pour qu'une assertion soit faite ou que le test soit terminé.
27 |
28 | ```js
29 | test('foo', t => {
30 | t.timeout(100); // 100 millisecondes
31 | // Ecrivez ici vos assertions
32 | });
33 | ```
34 |
35 | Une chaîne de caractères d'un message facultative peut être fournie. Cela peut être utile si votre test dépend d'une autre configuration qui peut ne pas avoir été achevée :
36 |
37 | ```js
38 | test('foo', t => {
39 | t.timeout(100, 'Assure que la base de données a démarré'); // 100 millisecondes
40 | // Ecrivez ici vos assertions
41 | });
42 | ```
43 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/babel.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [babel.md](https://github.com/avajs/ava/blob/main/docs/recipes/babel.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-012bb93393257e9f0c08e4808d0925fcb3c7ebbf9178186ce1493afee8f2af69) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `babel.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Configuration de Babel avec AVA
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/babel.md)
9 |
10 | Vous pouvez activer la prise en charge de Babel en installant [`@babel/register`](https://babeljs.io/docs/en/babel-register) et `@babel/core`, et ensuite dans la configuration de AVA, en exigeant `@babel/register` :
11 |
12 | **`package.json` :**
13 |
14 | ```json
15 | {
16 | "ava": {
17 | "require": [
18 | "@babel/register"
19 | ]
20 | }
21 | }
22 | ```
23 |
24 | `@babel/register` est compatible uniquement avec CommonJS. Il intercepte l'appel `require()` et compile les fichiers à la volée. Cela compilera les fichiers source, les helpers et les tests.
25 |
26 | Pour plus d'informations, visitez la [documentation Babel](https://babeljs.io/docs/en/babel-register).
27 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/code-coverage.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [code-coverage.md](https://github.com/avajs/ava/blob/main/docs/recipes/code-coverage.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-6cb4ccf1c34425b96a5b584514e057f0bfbd27e99656fc4ad49b0d4f5c63ac17) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `code-coverage.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Couverture de code
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/code-coverage.md), [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/code-coverage.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/code-coverage.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/code-coverage.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/docs/recipes/code-coverage.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/code-coverage.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/code-coverage.md)
9 |
10 | Utilisez [`8`] pour calculer la couverture de code de vos tests.
11 |
12 | Tout d'abord, installez [`c8`] :
13 |
14 | ```
15 | $ npm install --save-dev c8
16 | ```
17 |
18 | Le plus simple, exécutez AVA à travers [`c8`]. Dans notre fichier `package.json` :
19 |
20 | ```json
21 | {
22 | "scripts": {
23 | "test": "c8 ava"
24 | }
25 | }
26 | ```
27 |
28 | Vous souhaitez exclure le répertoire `coverage` du contrôle des sources. En supposant que vous utilisez Git, ajoutez ce qui suit à votre fichier `.gitignore` :
29 |
30 | ```
31 | coverage
32 | ```
33 |
34 | [`c8`]: https://github.com/bcoe/c8
35 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/debugging-with-chrome-devtools.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [debugging-with-chrome-devtools.md](https://github.com/avajs/ava/blob/main/docs/recipes/debugging-with-chrome-devtools.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-f5e363bb05df566efcd9000a18ff662f283a921b4f0e1bcf15e4a46560b663ff) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `debugging-with-chrome-devtools.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Débogage des tests avec Chrome DevTools
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/debugging-with-chrome-devtools.md)
9 |
10 | Vous pouvez déboguer vos tests en utilisant [Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools).
11 |
12 | Ouvrez Chrome, puis accédez à . Cliquez sur le lien *Open dedicated DevTools for Node* dans la section *Devices*.
13 |
14 | Dans la fenêtre *DevTools for Node*, naviguez vers *Sources* et dans la colonne de gauche, sélectionnez *Filesystem*. Ajoutez votre répertoire de projet à l'espace de travail. Assurez-vous d'accorder l'autorisation.
15 |
16 | Exécutez maintenant un fichier de test spécifique :
17 |
18 | ```console
19 | $ npx ava debug test.js
20 | ```
21 |
22 | Les DevTools devraient se connecter automatiquement et vos tests s'exécuteront. Utilisez DevTools pour définir des points d'arrêt ou utilisez le mot clé `debugger`.
23 |
24 | Exécutez avec l'option `--break` pour vous assurer que les DevTools atteignent un point d'arrêt juste avant le chargement du fichier de test :
25 |
26 | ```console
27 | $ inspect node_modules/ava/profile.js some/test/file.js
28 | ```
29 |
30 | Par défaut, l'inspecteur écoute sur `127.0.0.1:9229`. Vous pouvez personnaliser l'hôte et le port :
31 |
32 | ```console
33 | npx ava debug --host 0.0.0.0 --port 9230 test.js
34 | ```
35 |
36 | Vous devrez ajouter une connexion pour ce port dans l'onglet *Connection*.
37 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/debugging-with-webstorm.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [debugging-with-webstorm.md](https://github.com/avajs/ava/blob/main/docs/recipes/debugging-with-webstorm.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-282fbdcc6c13d7c58c36f8d0f802b7a13e32fbc8b305951ff9bde13376c97e7e) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `debugging-with-webstorm.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Débogage des tests avec WebStorm
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/debugging-with-webstorm.md)
9 |
10 | **Cette recette est obsolète.**
11 |
12 | ---
13 |
14 | Depuis la version 2016.2, [WebStorm](https://www.jetbrains.com/webstorm/) et les autres IDE de JetBrains (IntelliJ IDEA Ultimate, PHPStorm, PyCharm Professional et RubyMine avec le plugin Node.js installé) permettent de faire du débogage des tests AVA.
15 |
16 |
17 | ## Installation en utilisant Node.js
18 |
19 | Ajoutez une nouvelle *Node.js Run/Debug configuration* : sélectionnez `Edit Configurations...` depuis la liste déroulante en haut à droite, puis cliquez `+` et sélectionnez *Node.js*.
20 |
21 | Dans le champ `JavaScript file`, renseignez le chemin vers AVA dans le répertoire `node_modules` du projet : `node_modules/.bin/ava` sur macOS et Linux ou `node_modules/.bin/ava.cmd` sur Windows.
22 |
23 | Dans `Application parameters` passez les options du CLI que vous utilisez et les fichiers de test que vous souhaitez déboguer, par exemple `--verbose test.js`.
24 |
25 | Dans `Node parameters`, passez l'option `--inspect-brk` pour activer l'inspecteur de Node.
26 |
27 | Sauvez la configuration.
28 |
29 | ## Installation en utilisant npm
30 |
31 | Exécutez `npx @ava/init` dans le répertoire de votre projet pour ajouter AVA à votre `package.json`.
32 |
33 | Votre `package.json` ressemblera à quelque chose comme cela :
34 |
35 | ```json
36 | {
37 | "name": "awesome-package",
38 | "scripts": {
39 | "test": "ava"
40 | },
41 | "devDependencies": {
42 | "ava": "^0.20.0"
43 | }
44 | }
45 | ```
46 |
47 | Ajoutez une nouvelle *npm Run/Debug configuration* : sélectionnez `Edit Configurations...` depuis la liste déroulante en haut à droite, puis cliquez `+` et sélectionnez *npm*.
48 |
49 | Utilisez les paramètres de configurations suivants :
50 |
51 | - `package.json`: Le chemin du fichier `package.json` de votre projet
52 | - `Command`: `test`
53 |
54 | Votre IDE exécutera alors `npm run test` et donc appellera `node_modules/.bin/ava` et la configuration AVA que vous avez spécifiée dans votre package.json.
55 |
56 | Dans `Node parameters`, passez `--inspect-brk`.
57 |
58 | N'oubliez pas de sélectionner un interpréteur Node.js.
59 |
60 | Sauvez la configuration.
61 |
62 | ## Débogage
63 |
64 | Définissez des breakpoints dans le code.
65 |
66 | Appuyez sur le bouton `Debug` à côté de la liste des configurations en haut à droite. Le *Debug tool window* apparaît. Une fois que breakpoint est atteint, vous pouvez évaluer les variables et parcourir le code. Lors du débogage de plusieurs fichiers de test, vous pouvez basculer entre les processus en utilisant la liste déroulante dans le volet Frames.
67 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [endpoint-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-efa0df6e15dc5a83e221dd3df4ea71b65f14ae5b61b31e17354efd36f4358519) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `endpoint-testing.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Tester un endpoint
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md), [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/endpoint-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/endpoint-testing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/endpoint-testing.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/docs/recipes/endpoint-testing.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/endpoint-testing.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/endpoint-testing.md)
9 |
10 | [](https://stackblitz.com/github/avajs/ava/tree/main/examples/endpoint-testing?file=test.js&terminal=test&view=editor)
11 |
12 | AVA n'a pas de méthodes internes pour tester les endpoints, mais vous pouvez utiliser n'importe quel client HTTP de votre choix, par exemple [`got`](https://github.com/sindresorhus/got). Vous devrez également démarrer un serveur HTTP, de préférence sur un port unique, afin de pouvoir exécuter des tests en parallèle. Pour cela, nous recommandons [`test-listen`](https://github.com/zeit/test-listen).
13 |
14 | Étant donné que les tests sont exécutés simultanément, il est préférable de créer une nouvelle instance de serveur au moins pour chaque fichier de test, voire même pour chaque test. Ceci peut être accompli avec les hooks `test.before()` et `test.beforeEach()` et `t.context`. Si vous démarrez votre serveur à l’aide d’un hook `test.before()`, vous devez vous assurer d’exécuter vos tests en série.
15 |
16 | Découvrez l'exemple ci-dessous :
17 |
18 | ```js
19 | import http from 'http';
20 | import test from 'ava';
21 | import got from 'got';
22 | import listen from 'test-listen';
23 | import app from '../app';
24 |
25 | test.before(async t => {
26 | t.context.server = http.createServer(app);
27 | t.context.prefixUrl = await listen(t.context.server);
28 | });
29 |
30 | test.after.always(t => {
31 | t.context.server.close();
32 | });
33 |
34 | test.serial('get /user', async t => {
35 | const {email} = await got('user', {prefixUrl: t.context.prefixUrl}).json();
36 | t.is(email, 'ava@rocks.com');
37 | });
38 | ```
39 |
40 | D'autres bibliothèques pourraient vous être utiles :
41 |
42 | - [`supertest`](https://github.com/visionmedia/supertest)
43 | - [`get-port`](https://github.com/sindresorhus/get-port)
44 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/es-modules.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [es-modules.md](https://github.com/avajs/ava/blob/main/docs/recipes/es-modules.md). Voici un [lien](https://github.com/avajs/ava/compare/f09742f7baab7d44a48f1e3cee8f4b22deecf6f4...main#diff-6dd0fb3751d5b8d129d7e5c516e1842107286df168e7c2a66a56ecb24be6c67f) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `es-modules.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Utilisation des ES modules dans AVA
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/es-modules.md)
9 |
10 | AVA 4 prend en charge les modules ES.
11 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/isolated-mongodb-integration-tests.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [isolated-mongodb-integration-tests.md](https://github.com/avajs/ava/blob/main/docs/recipes/isolated-mongodb-integration-tests.md). Voici un [lien](https://github.com/avajs/ava/compare/79b2ea30c125f44e4d47bdafdeec351cddb5911a...main#diff-2b49a4116302a910c3ee7721ca0cdd5b6172074c7c0447401c080ce2456ee7c9) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `isolated-mongodb-integration-tests.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Configuration d'AVA pour les tests d'intégration isolés de MongoDB
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/isolated-mongodb-integration-tests.md)
9 |
10 | Comment exécuter les bases de données MongoDB à usage unique dans vos tests AVA avec une isolation pour chaque test. Pour cela, on utilise `mongomem` qui est disponible sur [npm](https://www.npmjs.com/package/mongomem).
11 |
12 | Pour cela, on utilise [`MongoMem`](https://github.com/CImrie/mongomem) qui vous permet de gérer rapidement un serveur temporaire MongoDB localement. Il utilise temporairement un stockage de fichiers qui sera détruit lorsque le serveur s'arrêtera.
13 |
14 |
15 | ## Installez un serveur MongoDB en mémoire (MongoMem)
16 |
17 | A la racine de votre application, exécutez :
18 |
19 | ```console
20 | $ npm install --save-dev mongomem
21 | ```
22 |
23 |
24 | ## Utilisation de MongoMem
25 |
26 | Dans votre fichier de test, importez le module et exécuter le serveur.
27 |
28 | **Assurez-vous d'exécuter le serveur au début de votre fichier et en dehors des cas de test.**
29 |
30 | ```js
31 | import test from 'ava';
32 | import {MongoDBServer} from 'mongomem';
33 |
34 | test.before('start server', async t => {
35 | await MongoDBServer.start();
36 | })
37 |
38 | test('some feature', async t => {
39 | const connectionString = await MongoDBServer.getConnectionString();
40 |
41 | // connectionString === 'mongodb://localhost:27017/3411fd12-b5d6-4860-854c-5bbdb011cb93'
42 | // utilisez `connectionString` pour se connecter à la base de données avec un client de votre choix. Regardez ci-dessous pour une utilisation avec Mongoose.
43 | });
44 | ```
45 |
46 |
47 | ## Nettoyage
48 |
49 | Après avoir exécuté vos tests, vous devez inclure une méthode `test.after.always` pour nettoyer le serveur MongoDB. Cela supprimera tous les fichiers temporaires utilisés par le serveur lors de l'exécution.
50 |
51 | Ceci est normalement nettoyé par votre système d'exploitation, mais il est recommandé de le faire manuellement.
52 |
53 | ```js
54 | test.after.always('cleanup', t => {
55 | MongoDBServer.tearDown(); // Nettoie les fichiers temporaires de stockage
56 | });
57 | ```
58 |
59 |
60 | ## Débogage
61 |
62 | Si le serveur ne semble pas démarrer, vous pouvez définir l'option `MongoDBServer.debug = true;` avant d'appeler `MongoDBServer.start()`. Cela permettra au serveur MongoDB d'afficher des erreurs de connexion ou d'autorisation de fichier lors de son démarrage. Comme il vérifie et choisit un port disponible pour exécuter le serveur, les erreurs sont donc susceptibles d'être liées aux autorisations de fichier.
63 |
64 | ## Extra : configuration et utilisation dans Mongoose
65 |
66 | [Mongoose](https://mongoosejs.com) est un robuste Object-Document-Mapper (ODM) pour MongoDB. Reportez-vous à sa documentation pour débuter avec Mongoose.
67 |
68 | Pour utiliser efficacement Mongoose avec AVA, consultez les [documents d'intégration Mongoose](endpoint-testing-with-mongoose.md).
69 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/passing-arguments-to-your-test-files.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [passing-arguments-to-your-test-files.md](https://github.com/avajs/ava/blob/main/docs/recipes/passing-arguments-to-your-test-files.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-0fec390b042c2bb40f272fed2d1bd695f95995a60764bb7f3801f58babfe8cd0) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `passing-arguments-to-your-test-files.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Passer des arguments à vos fichiers de test
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/passing-arguments-to-your-test-files.md)
9 |
10 | Vous pouvez passer des arguments à ligne de commande pour vos fichiers de test. Utilisez l'argument `--` pour les séparer des arguments de AVA :
11 |
12 | ```js
13 | // test.js
14 | import test from 'ava';
15 |
16 | test('argv', t => {
17 | t.deepEqual(process.argv.slice(2), ['--hello', 'world']);
18 | });
19 | ```
20 |
21 | ```console
22 | $ npx ava -- --hello world
23 | ```
24 |
25 | Vous avez besoin de deux arguments `--` si vous invoquez AVA via un script `npm test` :
26 |
27 | ```json
28 | {
29 | "scripts": {
30 | "test": "ava"
31 | }
32 | }
33 | ```
34 |
35 | ```console
36 | $ npm test -- -- --hello world
37 | ```
38 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/puppeteer.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [puppeteer.md](https://github.com/avajs/ava/blob/main/docs/recipes/puppeteer.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-6e1e8222bd9f948401f5a793dfe3f3f871e805a6d009426d82a098799fc19f7e) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `puppeteer.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Test d'applications Web à l'aide de Puppeteer
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/puppeteer.md)
9 |
10 | ## Les dépendances
11 |
12 | - [Puppeteer](https://github.com/GoogleChrome/puppeteer) : `npm install --save-dev puppeteer`
13 |
14 | ## Configuration
15 |
16 | La première étape consiste à configurer un helper pour configurer l'environnement :
17 |
18 | `./test/_withPage.js`
19 |
20 | ```js
21 | import puppeteer from 'puppeteer';
22 |
23 | module.exports = async (t, run) => {
24 | const browser = await puppeteer.launch();
25 | const page = await browser.newPage();
26 | try {
27 | await run(t, page);
28 | } finally {
29 | await page.close();
30 | await browser.close();
31 | }
32 | }
33 | ```
34 |
35 | ## Exemple d'utilisation
36 |
37 | `./test/main.js`
38 |
39 | ```js
40 | import test from 'ava';
41 | import withPage from './_withPage';
42 |
43 | const url = 'https://google.com';
44 |
45 | test('le titre de la page doit contenir "Google"', withPage, async (t, page) => {
46 | await page.goto(url);
47 | t.true((await page.title()).includes('Google'));
48 | });
49 |
50 | test('la page doit contenir un élément avec le sélecteur `#hplogo`', withPage, async (t, page) => {
51 | await page.goto(url);
52 | t.not(await page.$('#hplogo'), null);
53 | });
54 |
55 | test('le formulaire de recherche doit correspondre au snapshot', withPage, async (t, page) => {
56 | await page.goto(url);
57 | const innerHTML = await page.evaluate(form => form.innerHTML, await page.$('#searchform'));
58 | t.snapshot(innerHTML);
59 | });
60 | ```
61 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/splitting-tests-ci.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [splitting-tests-ci.md](https://github.com/avajs/ava/blob/main/docs/recipes/splitting-tests-ci.md). Voici un [lien](https://github.com/avajs/ava/compare/c299fdb425c7078a098e26d5fbe95b09d7320343...main#diff-e73642919435e90af62b7d834d4596d2552c29f2f783035c2b43556ad87bf454) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `splitting-tests-ci.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Découpage des tests dans le CI
7 |
8 | AVA détecte automatiquement si votre environnement CI prend en charge les constructions en parallèle en utilisant [ci-parallel-vars](https://www.npmjs.com/package/ci-parallel-vars). Lorsque la prise en charge des constructions en parallèle est détectée, AVA trie tous les fichiers de test détectés par nom, et les divise en morceaux. Chaque machine CI est assignée à un morceau (sous-ensemble) des tests, et ensuite chaque morceau est exécuté en parallèle.
9 |
10 | Pour désactiver cette fonctionnalité, mettez `utilizeParallelBuilds` à `false` dans votre [configuration AVA](/fr_FR/docs/06-configuration.md#options).
11 |
12 | Pour mieux répartir les tests sur les machines, vous pouvez configurer une fonction de comparaison personnalisée :
13 |
14 | **`ava.config.js` :**
15 |
16 | ```js
17 | import fs from 'node:fs';
18 |
19 | // En supposant que 'test-data.json' a la structure suivante :
20 | // {
21 | // 'tests/test1.js': { order: 1 },
22 | // 'tests/test2.js': { order: 0 }
23 | // }
24 | const testData = JSON.parse(fs.readFileSync('test-data.json', 'utf8'));
25 |
26 | export default {
27 | sortTestFiles: (file1, file2) => testData[file1].order - testData[file2].order,
28 | };
29 | ```
30 |
31 | ## Découpage des tests sur GitHub Actions
32 |
33 | Bien que GitHub Actions ne prenne pas en charge les constructions en parallèle avec AVA, vous pouvez le configurer manuellement en utilisant une matrice :
34 |
35 | **`.github/workflows/test.yml`:**
36 |
37 | ```yml
38 | on: push
39 | jobs:
40 | test:
41 | strategy:
42 | # N'annule pas les tests si cela échoue
43 | fail-fast: false
44 | # Exécute 4 jobs en parallèle, chacun exécutant un sous-ensemble de la totalité des tests
45 | matrix:
46 | node_index: [0, 1, 2, 3]
47 | total_nodes: [4]
48 |
49 | runs-on: ubuntu-latest
50 | steps:
51 | # Consulte le code et effectue des étapes de configuration
52 | # ...
53 |
54 | - name: Test
55 | run: npx ava
56 | env:
57 | CI_NODE_INDEX: ${{ matrix.node_index }}
58 | CI_NODE_TOTAL: ${{ matrix.total_nodes }}
59 | ```
60 |
--------------------------------------------------------------------------------
/fr_FR/docs/recipes/vue.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [vue.md](https://github.com/avajs/ava/blob/main/docs/recipes/vue.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-da520a78ba1e2ca77e222dc26ab93529528ac720ea37001e03df3b6b5d1421d7) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `vue.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Tester les composants Vue.js
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/recipes/vue.md)
9 |
10 | ## Dépendances
11 |
12 | - [Require extension hooks](https://github.com/jackmellis/require-extension-hooks) :
13 | - `npm i --save-dev require-extension-hooks require-extension-hooks-vue require-extension-hooks-babel@beta`
14 |
15 | - [jsdom-global](https://github.com/rstacruz/jsdom-global/blob/master/README.md)
16 | - `npm i --save-dev jsdom jsdom-global`
17 |
18 | - Facultatif : [babel-plugin-webpack-alias-7](https://github.com/shortminds/babel-plugin-webpack-alias-7) si vous voulez utiliser les [alias de webpack](https://webpack.js.org/configuration/resolve/#resolve-alias) ou les utiliser dans vos fichiers source
19 | - `npm i --save-dev babel-plugin-webpack-alias-7`
20 |
21 | ## Configuration
22 |
23 | La première étape consiste à mettre en place un helper pour configurer l'environnement afin de transpiler les fichiers `.vue` et exécuter dans un navigateur comme environnement.
24 |
25 | **`package.json` :**
26 |
27 | ```json
28 | {
29 | "ava": {
30 | "require": [
31 | "./test/_setup.js"
32 | ]
33 | }
34 | }
35 | ```
36 |
37 | ```js
38 | // ./test/_setup.cjs
39 |
40 | // Configuration de JSDom.
41 | const jsdomGlobal = require('jsdom-global');
42 | jsdomGlobal();
43 |
44 | // Corrige l'objet Date, voir .
45 | window.Date = Date
46 |
47 | // Configuration de l'environnement navigateur
48 | const hooks = require('require-extension-hooks');
49 | const Vue = require('vue');
50 |
51 | // Configuration de Vue.js pour enlever production tip
52 | Vue.config.productionTip = false;
53 |
54 | // Configuration des fichiers vue pour être traités par `require-extension-hooks-vue`
55 | hooks('vue').plugin('vue').push();
56 | // Configuration des fichiers vue et js pour être traités par `require-extension-hooks-babel`
57 | hooks(['vue', 'js']).exclude(({filename}) => filename.match(/\/node_modules\//)).plugin('babel').push();
58 | ```
59 |
60 | **Remarque :** Si vous utilisez _babel-plugin-webpack-alias-7_, vous devez aussi exclure votre fichier webpack, par exemple `filename.includes(/\/node_modules\//) || filename.includes('webpack.config.test.js')`
61 |
62 | ## Exemple de test instantané
63 |
64 | ```js
65 | const test = require('ava');
66 | const Vue = require('vue');
67 | const Component = require('component.vue');
68 |
69 | test('renders', t => {
70 | const vm = new Vue(Component).$mount();
71 | const tree = {
72 | $el: vm.$el.outerHTML
73 | };
74 | t.snapshot(tree);
75 | });
76 | ```
77 |
78 | ## Rapport de couverture de code
79 |
80 | Suivez la [recette couverture de code](code-coverage.md), en ajoutant en plus l'extension `.vue`, pour que la config de `c8` traite les fichiers `.vue`.
81 |
82 | ```json
83 | {
84 | "c8": {
85 | "extension": [
86 | ".js",
87 | ".vue"
88 | ]
89 | }
90 | }
91 | ```
92 |
--------------------------------------------------------------------------------
/fr_FR/docs/support-statement.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [support-statement.md](https://github.com/avajs/ava/blob/main/docs/support-statement.md). Voici un [lien](https://github.com/avajs/ava/compare/b208d143ad852dc95aa8b44eed94ac1f404a25f4...main#diff-dd0cfd1cf854eda55e1a756ec3518eb4c85f24719a66c0fddfc6b1797c5d320b) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `support-statement.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Les versions Node.js supportées
7 |
8 | Traductions : [English](https://github.com/avajs/ava/blob/main/docs/support-statement.md)
9 |
10 | AVA prend en charge la dernière version de toute version majeure [prise en charge par Node.js](https://github.com/nodejs/Release#release-schedule).
11 |
12 | Le *Support* signifie que nous exécutons notre suite de tests sous les versions de Node.js spécifiées et acceptons les pull requests pour corriger les bogues. (à condition que les bogues ne soient pas connus dans Node.js car ils seront fixés de manière imminente). Par conséquent, *l'abandon du support* signifie que nous supprimerons ces versions de Node.js depuis notre matrice de test et nous n'accepterons plus les pull requests spécifiques pour corriger les bogues sur ces versions.
13 |
14 | Lorsque nous abandonnerons la prise en charge d'une version majeure couverte par LTS, nous augmenterons la version majeure d'AVA.
15 |
16 | Nous abandonnerons le support des versions Node.js impaires (par exemple `11` ou `13`) *sans augmenter* le numéro de version majeur de AVA.
17 |
18 | Nous essayons d'éviter la suppression *accidentelle* du support des versions de Node.js qui ne sont pas les dernières. Si une telle rupture se produit, nous acceptons les pull requests pour restaurer les fonctionnalités. Nous pourrions décider de désapprouver la version AVA incriminée et augmenter à la place le numéro de version majeur de AVA.
19 |
20 | À chaque fois que nous augmentons le numéro de version majeur d'AVA, nous *abandonnerons* explicitement le support des versions non-récentes de Node.js. Cela nous assure de pouvoir compter sur des API rétroportées ou sur la disponibilité de versions V8 plus récentes dans les versions ultérieures de Node.js, que ce soit dans AVA lui-même ou dans l'une de nos dépendances.
21 |
22 | Nous pouvons abandonner le support pour une version de Node.js, dans une pré-version-pour-une-version-majeure, si cette nouvelle version de AVA est supposée devenir stable autour ou après la date de fin de vie de la version Node.js en question.
23 |
24 | Les fonctionnalités expérimentales sélectionnées via la configuration `nonSemVerExperiments` peuvent être modifiées ou supprimées à tout moment.
25 |
--------------------------------------------------------------------------------
/fr_FR/maintaining.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [maintaining.md](https://github.com/avajs/ava/blob/main/maintaining.md). Voici un [lien](https://github.com/avajs/ava/compare/c8f31a39ca7a2b13a5b3c85c5b1467da2ecc5c7a...main#diff-af603132939e2fa7a0294894ba3231d6e800fd3ef8c54bc83780229d436ff4d5) vers les différences avec le master de AVA (Si en cliquant sur le lien, vous ne trouvez pas le fichier `maintaining.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Maintenance
7 |
8 | ## Conduite
9 |
10 | **Soyez gentil avec tout le monde.** Lisez et adhérez au [Code de Conduite](code-of-conduct.md).
11 |
12 | ## Test
13 |
14 | * `npm test` : Vérifie le code (Lint) et exécute tous les tests avec une couverture de code
15 | * `npx tap test-tap/fork.js --bail` : Exécute un fichier de test spécifique et s'arrête au premier échec (utile quand on cherche des bugs).
16 | * `npx test-ava test/{file}.js` : Exécute des tests auto-hébergés.
17 |
18 | ## CI
19 |
20 | * Les tests échouent parfois sous Windows. Lisez attentivement les erreurs.
21 | * Au moins un job Windows doit réussir.
22 | * Tous les autres jobs doivent passer.
23 |
24 | ## Mise à jour des dépendances
25 |
26 | * Assurez-vous que les nouvelles versions des dépendances soient compatibles avec nos versions Node.js prises en charge.
27 | * Laissez la dépendance TypeScript en l'état pour éviter toute rupture accidentelle.
28 | * Ouvrez un PR avec les mises à jour et ne fusionnez que lorsque le CI réussit (voir la section précédente).
29 |
30 | ## Mise à jour de TypeScript
31 |
32 | TypeScript lui-même ne suit pas SemVer. Par conséquent, il se peut que nous devions apporter des modifications à la définition de type qui, techniquement, annulent les modifications pour les utilisateurs ayant une version plus ancienne de TypeScript. C'est OK, mais nous devrions en être conscients.
33 |
34 | Mettez à jour la dépendance TypeScript uniquement lorsque cela est vraiment nécessaire. Cela permet d'éviter les ruptures accidentelles. Par exemple, nous ne nous appuierons pas accidentellement sur les nouvelles fonctionnalités de TypeScript.
35 |
36 | Lorsqu'on parle d'utiliser les nouvelles fonctionnalités de TypeScript, ça pourrait être considéré comme un changement radical. Cela doit être évalué au cas par cas.
37 |
38 | ## Pull requests
39 |
40 | - Les nouvelles fonctionnalités doivent être livrées avec des tests et de la documentation.
41 | - Assurez vous que le [guide de contribution](contributing.md) est respecté.
42 | - Faites un squash des commits avant de merger.
43 |
44 | ## Expérimentations
45 |
46 | * Commencez par implémenter des modifications contenant des ruptures en tant qu'expérimentation, elles doivent nécessiter l'adhésion.
47 | * Expédiez rapidement les nouvelles fonctionnalités en les considérant comme une expérimentation nécessitant l'adhésion.
48 |
49 | ## Processus de version
50 |
51 | * Mettez à jour les dépendances (voir la section précédente).
52 | * Si [nécessaire](docs/support-statement.md), mettez à jour le champ `engines` dans `package.json`.
53 | * Supprimez les versions non prises en charge (ou sur le point de l'être) de Node.js.
54 | * Lorsque vous effectuez une modification majeure de la version, veillez à exiger les dernières versions de chaque version de Node.js prise en charge.
55 | * Publier une nouvelle version en utilisant [`np`](https://github.com/sindresorhus/np) avec un numéro de version selon [SemVer](https://semver.org).
56 | * Ecrivez une [note de version](https://github.com/avajs/ava/releases/new) en suivant le style des notes des versions précédentes.
57 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/new-rule.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [new-rule.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/new-rule.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-87082626c4b6b893d7071e2be655874b88869aebcfb2bfa71bae54c7df0a330c) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `new-rule.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Création d'une nouvelle règle
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/new-rule.md)
9 |
10 | ## Prérequis
11 |
12 | - [Lisez les docs de ESLint sur la création d'une nouvelle règle.](https://eslint.org/docs/developer-guide/working-with-rules)
13 | - Consulter les commits des règles précédemment ajoutées pour vous aider. Par exemple, la [règle `no-async-fn-without-await`](https://github.com/avajs/eslint-plugin-ava/commit/a443d7a9c94165f42749938e6b491a7c10749b6c).
14 |
15 | ## Astuce
16 |
17 | Utilisez le [site `astexplorer`](https://astexplorer.net) avec l'analyseur `espree` et la transformation `ESLint v4` pour créer de manière interactive l'implémentation initiale de la règle. Il vous permet d'inspecter l'AST complet que vous obtiendrez avec ESLint et vous pouvez même voir le résultat de votre implémentation pour corriger automatiquement.
18 |
19 | ## Les étapes
20 |
21 | - Allez dans le répertoire `test` et dupliquez le fichier `no-todo-test.js`, renommez le avec le nom de votre règle. Ensuite, écrivez quelques tests avant de commencer à implémenter la règle.
22 | - Allez dans le répertoire `rules` et dupliquez le fichier `no-todo-test.js`, renommez le avec le nom de votre règle. Ensuite, commencez l'implémentation logique de la nouvelle règle.
23 | - Ajouter le bon [`meta.type`](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics) à la règle.
24 | - Allez dans le répertoire `docs/rules` et dupliquez le fichier `no-todo-test.md`, renommez le avec le nom de votre règle. Ensuite écrivez la documentation.
25 | - Ajouter la règle par ordre alphabétique dans :
26 | - [La config recommandée](https://github.com/avajs/eslint-plugin-ava/blob/0ded4b5c3cd09504e846309760566c9499a24196/index.js#L19)
27 | - [La config recommandée dans le readme](https://github.com/avajs/eslint-plugin-ava/blame/0ded4b5c3cd09504e846309760566c9499a24196/readme.md#L35)
28 | - [La liste des règles dans le readme](https://github.com/avajs/eslint-plugin-ava/blame/0ded4b5c3cd09504e846309760566c9499a24196/readme.md#L73)\
29 | *(La description doit être la même que l'entête du fichier de documentation).*
30 | - Exécutez `$ npm test` pour s'assurer que les tests passent.
31 | - Exécutez `$ npm run integration` pour re-exécuter les règles dans de vrais projets afin de s'assurer que votre règle n'échoue dans le code du monde réel.
32 | - Ouvrez une pull request avec un titre qui correspond exactement à ce format `` Add `nom-règle` rule ``, par exemple, `` Add `no-unused-properties` rule ``.
33 | - La description de la pull request doit inclure l'issue qu'elle corrige, par exemple, `Fixes #123`.
34 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/assertion-arguments.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [assertion-arguments.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/assertion-arguments.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-9595412d72d85e04b16a023e18302b498cb57d6b9141ac533a45664003b038bc) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `assertion-arguments` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Imposer le passage d'arguments corrects aux assertions
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/assertion-arguments.md)
9 |
10 | Impose le passage du bon nombre d'arguments aux méthodes d'assertion comme `t.is ()`. Cette règle peut aussi imposer ou interdire l'utilisation des messages d'assertion.
11 |
12 | Les messages d'assertion sont des arguments factultatifs qui peuvent être fournis lors de l'appel d'assertion afin d'améliorer le message d'erreur si l'affirmation échoue.
13 |
14 | Cette règle tente également d'imposer le passage des valeurs actuelles avant les valeurs attendues. Si exactement un des deux premiers arguments d'une assertion à deux arguments est une expression statique telle que `{a: 1}`, alors l'expression statique doit être positionné en second. (`t.regex()` et `t.notRegex()` sont exclus de cette vérification, car leur argument `contents` ou leur argument `regex` pourrait plausiblement être la valeur actuelle ou attendue). Si l'argument d'une assertion à un argument est une relation binaire telle que `'static' === dynamic`, une vérification similaire est effectuée sur ses côtés gauche et droit. Les erreurs de ce type sont généralement corrigibles.
15 |
16 | ## Échoue
17 |
18 | ```js
19 | const test = require('ava');
20 |
21 | test('1', t => {
22 | t.is(value); // Pas assez d'arguments
23 | t.is(value, expected, message, extra); // Trop d'arguments
24 | t.is(value, expected, false); // Le message d'assertion n'est pas une chaîne
25 | });
26 |
27 | /* eslint ava/assertion-arguments: ["error", {"message": "always"}] */
28 | test('2', t => {
29 | t.true(array.includes(value));
30 | });
31 |
32 | /* eslint ava/assertion-arguments: ["error", {"message": "never"}] */
33 | test('3', t => {
34 | t.true(array.includes(value), 'value is not in array');
35 | });
36 | ```
37 |
38 | ## Passe
39 |
40 | ```js
41 | const test = require('ava');
42 |
43 | test('1', t => {
44 | t.is(value, expected);
45 | t.is(value, expected, message);
46 | });
47 |
48 | /* eslint ava/assertion-arguments: ["error", {"message": "always"}] */
49 | test('2', t => {
50 | t.true(array.includes(value), 'value is not in array');
51 | });
52 |
53 | /* eslint ava/assertion-arguments: ["error", {"message": "never"}] */
54 | test('3', t => {
55 | t.true(array.includes(value));
56 | });
57 | ```
58 |
59 | ## Options
60 |
61 | Cette règle prend en charge les options suivantes :
62 |
63 | `message`: Un string qui peut être `"always"` ou `"never"`. S'il est défini à `"always"`, toutes les assertions devront avoir un message d'assertion message. S'il est défini à `"never"`, aucune assertion ne doit avoir un message d'assertion. Si ce n'est pas renseigné, aucun rapport sur le message d'assertion sera faite.
64 |
65 | Vous pouvez définir l'option dans la configuration de cette manière :
66 |
67 | ```js
68 | "ava/assertion-arguments": ["error", {"message": "always"}]
69 | ```
70 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/hooks-order.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [hooks-order.md.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/hooks-order.md.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/7542453058c30ebbc79c7bfeb689492fce226d8f...main#diff-7475dc463133f15a5a23f4d1ceb1aa3e7c467857a7568f926d1de69fb1ce908b) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `hooks-order.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Imposer l'ordre des hooks de test
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/hooks-order.md)
9 |
10 | Les hooks doivent être placés avant les tests et dans le bon ordre sémantique :
11 |
12 | - `test.before(…);`
13 | - `test.after(…);`
14 | - `test.after.always(…);`
15 | - `test.beforeEach(…);`
16 | - `test.afterEach(…);`
17 | - `test.afterEach.always(…);`
18 | - `test(…);`
19 |
20 | Cette règle est réparable tant qu'aucun autre code ne se trouve entre les hooks qui doivent être réorganisés.
21 |
22 | ## Échoue
23 |
24 | ```js
25 | const test = require('ava');
26 |
27 | test.after(t => {
28 | doFoo();
29 | });
30 |
31 | test.before(t => {
32 | doFoo();
33 | });
34 |
35 | test('foo', t => {
36 | t.true(true);
37 | });
38 | ```
39 |
40 | ```js
41 | const test = require('ava');
42 |
43 | test('foo', t => {
44 | t.true(true);
45 | });
46 |
47 | test.before(t => {
48 | doFoo();
49 | });
50 | ```
51 |
52 | ## Passe
53 |
54 | ```js
55 | const test = require('ava');
56 |
57 | test.before(t => {
58 | doFoo();
59 | });
60 |
61 | test.after(t => {
62 | doFoo();
63 | });
64 |
65 | test.after.always(t => {
66 | doFoo();
67 | });
68 |
69 | test.beforeEach(t => {
70 | doFoo();
71 | });
72 |
73 | test.afterEach(t => {
74 | doFoo();
75 | });
76 |
77 | test.afterEach.always(t => {
78 | doFoo();
79 | });
80 |
81 | test('foo', t => {
82 | t.true(true);
83 | });
84 | ```
85 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/max-asserts.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [max-asserts.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/max-asserts.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-01a069e556e28c486d139a3458114fd7334c2a056f50481339a458577a0d2aa9) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `max-asserts.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Limiter le nombre d'assertions dans un test
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/max-asserts.md)
9 |
10 | Limite la quantité d'assertions dans un test afin d'appliquer le découpage des gros tests en plusieurs plus petits.
11 |
12 | Les assertions passées (skip) sont comptés.
13 |
14 | ## Échoue
15 |
16 | ```js
17 | /*eslint ava/max-asserts: ["error", 5]*/
18 | const test = require('ava');
19 |
20 | test('getSomeObject devrait définir le nom du joueur', t => {
21 | const object = lib.getSomeObject();
22 |
23 | t.is(typeof object, 'object');
24 | t.is(typeof object.player, 'object');
25 | t.is(object.player.firstName, 'Luke');
26 | t.is(object.player.lastName, 'Skywalker');
27 | t.is(typeof object.opponent, 'object');
28 | t.is(object.opponent.firstName, 'Darth');
29 | t.is(object.opponent.lastName, 'Vader');
30 | });
31 | ```
32 |
33 | ## Passe
34 |
35 | ```js
36 | const test = require('ava');
37 |
38 | test('getSomeObject devrait définir le nom du joueur', t => {
39 | const object = lib.getSomeObject();
40 |
41 | t.is(typeof object, 'object');
42 | t.is(typeof object.player, 'object');
43 | t.is(object.player.firstName, 'Luke');
44 | t.is(object.player.lastName, 'Skywalker');
45 | });
46 |
47 | test('getSomeObject devrait définir le nom du joueur', t => {
48 | const object = lib.getSomeObject();
49 |
50 | t.is(typeof object, 'object');
51 | t.is(typeof object.opponent, 'object');
52 | t.is(object.opponent.firstName, 'Darth');
53 | t.is(object.opponent.lastName, 'Vader');
54 | });
55 | ```
56 |
57 | ## Options
58 |
59 | La règle prend une option, un nombre, qui est le nombre maximum d'assertions pour chaque test. La valeur par défaut est 5.
60 |
61 | Vous pouvez définir l'option dans la configuration comme ceci :
62 |
63 | ```js
64 | "ava/max-asserts": ["error", 5]
65 | ```
66 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-async-fn-without-await.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-async-fn-without-await.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-async-fn-without-await.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-53a3ae911fe8bd0587b8ff5153577004dea7644b96d6a0cf894ca1a7f6ca8771) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-async-fn-without-await.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que les tests async utilisent `await`
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-async-fn-without-await.md)
9 |
10 | AVA est livré avec une prise en charge intégré des [fonctions async](http://www.2ality.com/2016/02/async-functions.html) (async/await). Cela permet d'écrire des tests plus courts et plus clairs.
11 |
12 | Déclarer un test async sans utiliser le mot-clé `await` signifie soit qu'une promesse n'est pas attendue comme prévu ou que la fonction aurait pu être déclarée comme une fonction régulière, ce qui est source de confusion et c'est plus lent.
13 |
14 | Cette règle signale une erreur quand il trouve un test async qui n'utilise pas le mot-clé `await`.
15 |
16 | ## Échoue
17 |
18 | ```js
19 | const test = require('ava');
20 |
21 | test('foo', async t => {
22 | return foo().then(res => {
23 | t.is(res, 1);
24 | });
25 | });
26 | ```
27 |
28 | ## Passe
29 |
30 | ```js
31 | const test = require('ava');
32 |
33 | test('foo', async t => {
34 | t.is(await foo(), 1);
35 | });
36 | ```
37 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-duplicate-modifiers.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-duplicate-modifiers.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-duplicate-modifiers.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/2f8a22677fc542e71f344afcef687d63cfa5f1bb...main#diff-ac99af7555fdc135598c0ab9cd7d0ae32bc12a11394dec14379a56aa2e51755d) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-duplicate-modifiers.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer qu'aucun test n'a de modificateur en doublon
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-duplicate-modifiers.md)
9 |
10 | Interdit l'utilisation de [modificateur de test](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/01-writing-tests.md) en doublon.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test.only.only(t => {});
18 | test.serial.serial(t => {});
19 | test.beforeEach.beforeEach(t => {});
20 | ```
21 |
22 | ## Passe
23 |
24 | ```js
25 | const test = require('ava');
26 |
27 | test.only(t => {});
28 | test.serial(t => {});
29 | test.beforeEach(t => {});
30 | ```
31 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-identical-title.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-identical-title.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-identical-title.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-6d716ac64f662c61633a212f113b741efe1087433d172d6b5069ed9795cbeae2) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-identical-title.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que chaque test a un titre différent
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-identical-title.md)
9 |
10 | Interdit les tests avec des titres identiques car il est difficile de les différencier.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test('foo', t => {
18 | t.pass();
19 | });
20 |
21 | test('foo', t => {
22 | t.pass();
23 | });
24 | ```
25 |
26 | ## Passe
27 |
28 | ```js
29 | const test = require('ava');
30 |
31 | test('foo', t => {
32 | t.pass();
33 | });
34 |
35 | test('bar', t => {
36 | t.pass();
37 | });
38 | ```
39 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-ignored-test-files.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-ignored-test-files.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-ignored-test-files.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-0de18f519aaa500ed2e199666148950c8dcd5dfd8b2dc81785818e88ecdb8fb4) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-ignored-test-files.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer qu'aucun test ne soit écrit dans des fichiers ignorés
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-ignored-test-files.md)
9 |
10 | Cette règle vérifiera que les fichiers qui créent des tests sont traités comme des fichiers de test par AVA. Il examinera à partir de la racine du projet pour être dans le dossier le plus proche contenant un fichier `package.json`, et ne fera rien s'il n'en trouve pas. Les fichiers de test dans `node_modules` ne seront pas vérifiés car ils sont ignorés par ESLint.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | // Fichier : test/_helper.js
16 | // Invalide car c'est un helper
17 | const test = require('ava');
18 |
19 | test('foo', t => {
20 | t.pass();
21 | });
22 |
23 | // Fichier : lib/foo.js
24 | // Invalide car ce n'est pas un fichier de test
25 | const test = require('ava');
26 |
27 | test('foo', t => {
28 | t.pass();
29 | });
30 | ```
31 |
32 | ## Passe
33 |
34 | ```js
35 | // Fichier : test/foo.js
36 | const test = require('ava');
37 |
38 | test('foo', t => {
39 | t.pass();
40 | });
41 | ```
42 |
43 | ## Options
44 |
45 | Cette règle prend en charge les options suivantes :
46 |
47 | * `extensions` : un tableau des extensions des fichiers reconnus par AVA en tant que fichiers tests ou helpers. Remplace *les deux configurations* `babel.extensions` *et* `extensions` utilisées par AVA.
48 | * `files` : un tableau de glob patterns pour sélectionner les fichiers de test. Remplace la configuration `files` utilisées par AVA.
49 | * `helpers` : un tableau de glob patterns pour sélectionner les fichiers de helper. Remplace la configuration `helpers` utilisées par AVA.
50 |
51 | Consultez aussi la [configuration de AVA](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/06-configuration.md#options).
52 |
53 | Vous pouvez définir l'option de cette manière :
54 |
55 | ```js
56 | "ava/no-ignored-test-files": ["error", {"files": ["lib/**/*.test.js", "utils/**/*.test.js"]}]
57 | ```
58 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-import-test-files.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-import-test-files.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-import-test-files.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-c26e96c5421817d5241b2075b652d8eb666e5a2ec15aeca3f3090b8e2d877c94) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-import-test-files.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer qu'aucun fichier de test n'est importé de n'importe où
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-import-test-files.md)
9 |
10 | Cette règle vérifiera que vous n'importez aucun fichier de test. Il considèrera la racine du projet avec le dossier le plus proche contenant un fichier `package.json` et ne fera rien s'il ne peut pas en trouver un. Les fichiers de test dans `node_modules` ne seront pas vérifiés car ils sont ignorés par ESLint.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | // Fichier : src/index.js
16 | // Invalide car *.test.js est considéré comme un fichier de test.
17 | const tests = require('./index.test.js');
18 | ```
19 |
20 | ```js
21 | // Fichier : src/index.js
22 | // Invalide car n'importe quel fichier dans __tests__ est considéré comme un fichier de test
23 | const tests = require('./__tests__/index.js');
24 |
25 | test('foo', t => {
26 | t.pass();
27 | });
28 | ```
29 |
30 | ## Passe
31 |
32 | ```js
33 | // Fichier : src/index.js
34 | const sinon = require('sinon');
35 |
36 | ```
37 |
38 | ```js
39 | // Fichier : src/index.js
40 | const utils = require('./utils');
41 | ```
42 |
43 | ## Options
44 |
45 | Cette règle prend en charge les options suivantes :
46 |
47 | * `extensions` : un tableau des extensions des fichiers reconnus par AVA en tant que fichiers tests ou helpers. Remplace *les deux configurations* `babel.extensions` *et* `extensions` utilisées par AVA.
48 | * `files` : un tableau de glob patterns pour sélectionner les fichiers de test. Remplace la configuration `files` utilisées par AVA.
49 |
50 | Consultez aussi la [configuration de AVA](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/06-configuration.md#options).
51 |
52 | Vous pouvez définir l'option de cette manière :
53 |
54 | ```js
55 | "ava/no-import-test-files": ["error", {"files": ["lib/**/*.test.js", "utils/**/*.test.js"]}]
56 | ```
57 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-incorrect-deep-equal.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-incorrect-deep-equal.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-incorrect-deep-equal.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-07f9cd788860446801712fd4887dc16fa82d43bdb9885d67d15f7cd5710f4dd4) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-incorrect-deep-equal` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Éviter d'utiliser `deepEqual` avec des primitives
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-incorrect-deep-equal.md)
9 |
10 | Les assertions `deepEqual` et `notDeepEqual` sont inutiles lors de la comparaison de primitives. Utilisez à la place `is` ou `not`.
11 |
12 | Cette règle est réparable.
13 |
14 | ## Échoue
15 |
16 | ```js
17 | t.deepEqual(expression, 'foo');
18 | t.deepEqual(expression, 1);
19 | t.deepEqual(expression, `foo${bar}`);
20 | t.deepEqual(expression, null);
21 | t.deepEqual(expression, undefined);
22 | t.notDeepEqual(expression, undefined);
23 | ```
24 |
25 | ## Passe
26 |
27 | ```js
28 | t.is(expression, 'foo');
29 |
30 | t.deepEqual(expression, otherExpression);
31 | t.deepEqual(expression, {});
32 | t.deepEqual(expression, []);
33 | t.notDeepEqual(expression, []);
34 | ```
35 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-inline-assertions.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-inline-assertions.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-inline-assertions.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-80ed70193196d1b08810a13abb23bc14b7e07bd648081258c965192d2fbe4443) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-inline-assertions` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que les assertions ne sont pas appelées depuis des fonctions fléchées sur une ligne
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-inline-assertions.md)
9 |
10 | L'implémentation du test ne doit pas consister uniquement en une assertion sur une ligne, car les assertions ne renvoient pas de valeur et leur affichage sur une ligne rend également les tests moins lisibles.
11 |
12 | Cette règle est réparable. Il encapsulera l'assertion entre accolades `{}`. Il ne fera aucun espace ou changement de style.
13 |
14 | ## Échoue
15 |
16 | ```js
17 | const test = require('ava');
18 | test('foo', t => t.true(fn()));
19 | ```
20 |
21 | ## Passe
22 |
23 | ```js
24 | const test = require('ava');
25 | test('foo', t => {
26 | t.true(fn());
27 | });
28 | ```
29 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-nested-tests.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-nested-tests.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-nested-tests.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-6383a972100eb6ef808f4aea8959b38bad794e4810e23086b3488452def8f022) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-nested-tests.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer qu'aucun test soit imbriqué
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-nested-tests.md)
9 |
10 | Dans AVA, vous ne pouvez pas imbriquer des tests, c'est à dire créer des tests à l'intérieur d'autres tests. Cela va conduire à un comportement étrange.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test('foo', t => {
18 | const result = foo();
19 | t.true(result.foo);
20 |
21 | test('bar', t => {
22 | t.true(result.bar);
23 | });
24 | });
25 | ```
26 |
27 | ## Passe
28 |
29 | ```js
30 | const test = require('ava');
31 |
32 | test('foo', t => {
33 | const result = foo();
34 | t.true(result.foo);
35 | });
36 |
37 | test('bar', t => {
38 | const result = foo();
39 | t.true(result.bar);
40 | });
41 | ```
42 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-only-test.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-only-test.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-only-test.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-98bea2b47c96d645e4cddc93895fb0a4d7a4ecedd9513bd8def7d4d0305df9ae) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-only-test.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer qu'aucun `test.only()` soit présent
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-only-test.md)
9 |
10 | Il est facile d'exécuter un unique test avec `test.only()` et puis de l'oublier. Il est visible dans les résultats, mais on peut encore facilement le manquer. En oubliant d'enlever `.only`, cela signifie que seul ce test dans le fichier complet s'exécutera, et si on ne fait rien, ceci peut permettre de glisser de sérieux bugs dans votre code.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test.only('test 1', t => {
18 | t.pass();
19 | });
20 |
21 | // test 2 ne s'exécutera pas
22 | test('test 2', t => {
23 | t.pass();
24 | });
25 | ```
26 |
27 | ## Passe
28 |
29 | ```js
30 | const test = require('ava');
31 |
32 | test('test 1', t => {
33 | t.pass();
34 | });
35 |
36 | // test 2 s'exécutera
37 | test('test 2', t => {
38 | t.pass();
39 | });
40 | ```
41 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-skip-assert.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-skip-assert.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-skip-assert.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-a3233e68087574562bec60844745aa58638faba21b1a9da717153c2efdf80667) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-skip-assert.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer qu'aucune assertion soit passée (skip)
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-skip-assert.md)
9 |
10 | C'est facile de sauter une assertion avec `t.skip.xyz()` et de l'oublier.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test('un titre', t => {
18 | t.skip.is(1, 1);
19 | });
20 | ```
21 |
22 | ## Passe
23 |
24 | ```js
25 | const test = require('ava');
26 |
27 | test('un titre', t => {
28 | t.is(1, 1);
29 | });
30 | ```
31 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-skip-test.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-skip-test.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-skip-test.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-5cf09f15e5cd3e69d32bed8f0c541206d34637767d6274bdcd3de11de2df9385) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-skip-test.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer qu'aucun test soit passé (skip)
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-skip-test.md)
9 |
10 | Il est facile de faire sauter un test avec `test.skip()`, puis de l'oublier. Il est visible dans les résultats, mais on peut encore facilement le manquer.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test('foo', t => {
18 | t.pass();
19 | });
20 |
21 | test.skip('bar', t => {
22 | t.pass();
23 | });
24 | ```
25 |
26 | ## Passe
27 |
28 | ```js
29 | const test = require('ava');
30 |
31 | test('foo', t => {
32 | t.pass();
33 | });
34 |
35 | test('bar', t => {
36 | t.pass();
37 | });
38 | ```
39 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-todo-implementation.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-todo-implementation.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-todo-implementation.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-7974944ece5b24286aad0085b8bf91b3988044d79ab69c75ebd606a6065578a7) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-todo-implementation.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que `test.todo()` n'a pas une fonction d'implémentation
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-todo-implementation.md)
9 |
10 | [`test.todo()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/01-writing-tests.md#les-tests-fictifs-todo) est destiné aux futurs tests. Il n’est pas destiné à recevoir une fonction pour implémenter le test qu'on lui donne, AVA lancera une erreur. Si vous avez ajouté une implémentation, vous vouliez sans doute supprimer le modificateur `.todo`.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test.todo('title', t => {
18 | // ...
19 | });
20 | ```
21 |
22 | ## Passe
23 |
24 | ```js
25 | const test = require('ava');
26 |
27 | test.todo('title');
28 |
29 | test('title2', t => {
30 | // ...
31 | });
32 | ```
33 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-todo-test.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-todo-test.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-todo-test.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-f00e52a4fc7d00f25b55f4063ced0302166ed1ea09cd7f7fcb9cfc1a02ffdf13) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-todo-test.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer qu'aucun `test.todo()` soit utilisé
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-todo-test.md)
9 |
10 | Interdit l'utilisation de `test.todo()`. Vous pouvez effectuer cette opération pour seulement embarquer des fonctionnalités avec des spécifications entièrement écrites et qui passent.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test.todo('quelques tests');
18 | ```
19 |
20 | ## Passe
21 |
22 | ```js
23 | const test = require('ava');
24 |
25 | test('quelques tests', t => {
26 | // quelques implémentations
27 | });
28 | ```
29 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/no-unknown-modifiers.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [no-unknown-modifiers.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-unknown-modifiers.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/2f8a22677fc542e71f344afcef687d63cfa5f1bb...main#diff-938c307e29702701f0a0409aa6b0bdc45a11013751ca0c736e8d8b2a162ada70) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `no-unknown-modifiers.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Empêcher l'utilisation de modificateurs de test inconnus
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/no-unknown-modifiers.md)
9 |
10 | Empêche l'utilisation de [modificateurs de test inconnus](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/01-writing-tests.md).
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test.onlu(t => {});
18 | test.seril(t => {});
19 | test.beforeeach(t => {});
20 | test.unknown(t => {});
21 | ```
22 |
23 | ## Passe
24 |
25 | ```js
26 | const test = require('ava');
27 |
28 | test.only(t => {});
29 | test.serial(t => {});
30 | test.beforeEach(t => {});
31 | ```
32 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/prefer-async-await.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [prefer-async-await.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/prefer-async-await.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-570eb0e2454a90668c01e2de527292f162168b302a9cbf2e769b2bdbbcf90499) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `prefer-async-await.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Préférer l'utilisation de async/await au lieu de retourner une Promesse
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/prefer-async-await.md)
9 |
10 | AVA est livré avec une prise en charge des fonctions async (async/await). Cela vous permet d'écrire des tests courts et clairs.
11 |
12 | Cette règle signale une erreur quand il trouve un test qui retourne une expression qui ressemble à une promesse (contenant un appel `.then()`), qui pourrait être simplifiée en utilisant la syntaxe async/await.
13 |
14 | ## Échoue
15 |
16 | ```js
17 | const test = require('ava');
18 |
19 | test('foo', t => {
20 | return foo().then(res => {
21 | t.is(res, 1);
22 | });
23 | });
24 | ```
25 |
26 | ## Passe
27 |
28 | ```js
29 | const test = require('ava');
30 |
31 | test('foo', async t => {
32 | t.is(await foo(), 1);
33 | });
34 | ```
35 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/prefer-power-assert.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [prefer-power-assert.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/prefer-power-assert.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-fe8033f9589d5fecab65926d436fa69c6744f4cb7858406ef6a6ce65226854cb) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `prefer-power-assert.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Autoriser uniquement l'utilisation des assertions qui n'ont pas d'alternatives dans power-assert
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/prefer-power-assert.md)
9 |
10 | - [`t.assert()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#assertvalue-message)
11 | - [`t.deepEqual()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#deepequalvalue-expected-message)
12 | - [`t.notDeepEqual()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#notdeepequalvalue-expected-message)
13 | - [`t.like()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#likevalue-selector-message)
14 | - [`t.throws()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#throwsfn-expected-message)
15 | - [`t.notThrows()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#notthrowsfn-message)
16 | - [`t.pass()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#passmessage)
17 | - [`t.fail()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#failmessage)
18 |
19 | Utile pour les personnes voulant complètement comprendre la puissance de [power-assert](https://github.com/power-assert-js/power-assert).
20 |
21 | ## Échoue
22 |
23 | ```js
24 | const test = require('ava');
25 |
26 | test('foo', t => {
27 | t.truthy(foo);
28 | t.falsy(foo);
29 | t.true(foo === bar);
30 | t.false(foo === bar);
31 | t.is(foo, bar);
32 | t.not(foo, bar);
33 | t.regex(foo, bar);
34 | t.ifError(error);
35 | });
36 | ```
37 |
38 | ## Passe
39 |
40 | ```js
41 | const test = require('ava');
42 |
43 | test('foo', t => {
44 | t.assert(foo === bar);
45 | t.deepEqual(foo, bar);
46 | t.notDeepEqual(foo, bar);
47 | t.throws(foo);
48 | t.notThrows(bar);
49 | });
50 | ```
51 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/prefer-t-regex.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [prefer-t-regex.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/prefer-t-regex.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-db2e0f769ab68ca3027b6a3726ae1b6ec141a56aae3215e72462b9fefacd0d46) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `prefer-t-regex.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Préférer l'utilisation de `t.regex()` au lieu de tests d'expressions régulières
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/prefer-t-regex.md)
9 |
10 | L'[assertion `t.regex()`](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/03-assertions.md#regexcontents-regex-message) de AVA peut tester une chaîne par rapport à une expression régulière.
11 |
12 | Cette règle imposera l'utilisation de `t.regex()` au lieu d'utiliser manuellement `RegExp#test()`, ce qui rendra votre code plus clair et produira un meilleure affichage lors d'un échec.
13 |
14 | Cette règle est réparable. Cela remplacera l'utilisation de `RegExp#test()`, `String#match()`, ou `String#search()` avec `t.regex()`.
15 |
16 | ## Échoue
17 |
18 | ```js
19 | const test = require('ava');
20 |
21 | test('main', t => {
22 | t.true(/\w+/.test('foo'));
23 | });
24 | ```
25 |
26 | ```js
27 | const test = require('ava');
28 |
29 | test('main', t => {
30 | t.truthy('foo'.match(/\w+/));
31 | });
32 | ```
33 |
34 | ## Passe
35 |
36 | ```js
37 | const test = require('ava');
38 |
39 | test('main', async t => {
40 | t.regex('foo', /\w+/);
41 | });
42 | ```
43 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/test-title-format.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [test-title-format.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/test-title-format.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-09bf6de604c58c6cd691ae47508dd7e3eaf64e9c446131949ad1ea3f7b176923) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `test-title-format.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que les titres de test ont un certain format
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/test-title-format.md)
9 |
10 | Cette règle est utile lorsque vous souhaitez vous assurer que tous les titres de test correspondent à un format commun pour améliorer la lisibilité lorsque les tests échouent.
11 |
12 | Par exemple, des titres comme `'Should throw when invalid.'`, `'Should fail when called.'` ou `'Should pass when using any number.'` pourrait être appliqué avec le motif suivant `'^Should (pass|fail|throw) when [\\w ]+\\.$'` (Notez les échappés `\`).
13 |
14 | ## Échoue
15 |
16 | ```js
17 | /* eslint ava/test-title-format: ["error", {format: "^Devrait"}] */
18 | const test = require('ava');
19 |
20 | test('Ne commence pas par `Devrait`', t => {
21 | t.pass();
22 | });
23 | ```
24 |
25 | ```js
26 | /* eslint ava/test-title-format: ["error", {format: "\\.$"}] */
27 | const test = require('ava');
28 |
29 | test('Ne se termine pas par un point', t => {
30 | t.pass();
31 | });
32 | ```
33 |
34 | ## Passe
35 |
36 | ```js
37 | /* eslint ava/test-title-format: ["error", {format: "^Devrait"}] */
38 | const test = require('ava');
39 |
40 | test('Devrait passer les tests', t => {
41 | t.pass();
42 | });
43 |
44 | test('Devrait se comporter comme prévu', t => {
45 | t.pass();
46 | });
47 | ```
48 |
49 | ```js
50 | /* eslint ava/test-title-format: ["error", {format: "\\.$"}] */
51 | const test = require('ava');
52 |
53 | test('Se termine par un point.', t => {
54 | t.pass();
55 | });
56 | ```
57 |
58 | ## Options
59 |
60 | Cette règle prend en charge les options suivantes :
61 |
62 | `format` : Une chaîne d'expression régulière qui doit correspondre aux titres des tests.
63 |
64 | Vous pouvez définir l'option de cette manière :
65 |
66 | ```json
67 | "ava/test-title-format": [
68 | "error",
69 | {
70 | "format": "^Should"
71 | }
72 | ]
73 | ```
74 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/test-title.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [test-title.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/test-title.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-23d161c2b190dc8b21da4a6a68578bc5f9d7d1f9523039677e170e9c6747afc0) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `test-title.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que les tests ont un titre
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/test-title.md)
9 |
10 | Les tests devraient avoir un titre. La version [v1.0.1](https://github.com/avajs/ava/releases/tag/v1.0.1) de AVA et supérieure l'applique à l'exécution.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test(t => {
18 | t.pass();
19 | });
20 | ```
21 |
22 | ## Passe
23 |
24 | ```js
25 | const test = require('ava');
26 |
27 | test('foo', t => {
28 | t.pass();
29 | });
30 | ```
31 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/use-t-throws-async-well.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [use-t-throws-async-well.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-t-throws-async-well.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/eea71c3eddb5608b04e07fcb48da8acdafff1525...main#diff-b5be2c5b59a3767d881be8cd0e969c9b43b8be07fd3202366cd302ae9d6369e0) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `use-t-throws-async-well.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que `t.throwsAsync()` et `t.notThrowsAsync()` sont attendus
7 |
8 | Lorsque vous utilisez les assertions `t.throwsAsync()` et `t.notThrowsAsync()`, vous devez attendre la promesse qu'elles renvoient. Si la fonction de test se termine avant que les assertions soient faites, le test échouera.
9 |
10 | Cette règle est corrigible à l'intérieur des fonctions `async`. Cela inséra `await` avant `t.throwsasync()` et `t.notthrorsasync()`.
11 |
12 | ## Échoue
13 |
14 | ```js
15 | import test from 'ava';
16 |
17 | test('main', t => {
18 | t.throwsAsync(somePromise);
19 | t.notThrowsAsync(somePromise);
20 | });
21 | ```
22 |
23 | ## Passe
24 |
25 | ```js
26 | import test from 'ava';
27 |
28 | test('main', t => {
29 | await t.throwsAsync(somePromise);
30 | await t.notThrowsAsync(somePromise);
31 | const p = t.throwsAsync(somePromise);
32 | t.throwsAsync(somePromise).then(…);
33 | });
34 | ```
35 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/use-t-well.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [use-t-well.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-t-well.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-eef782cbcc5b495f41ea81eab8af21e986f56bafb1fe515f041fe9e22fe7cf57) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `use-t-well.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # Empêcher une mauvaise utilisation de `t`
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-t-well.md)
9 |
10 | Empêche l'utilisation de méthodes d'assertion inconnues et empêche d'accéder à des méthodes différentes des assertions et de `.context`, ainsi que certaines utilisations incorrectes connues de `t`.
11 |
12 | Cette règle est réparable de façon partielle. Il peut corriger la plupart des noms de méthodes d'assertion mal orthographiés et des usages incorrects de `.skip`.
13 |
14 | ## Échoue
15 |
16 | ```js
17 | const test = require('ava');
18 |
19 | test('main', t => {
20 | t(value); // `t` n'est pas une fonction
21 | t.depEqual(value, [2]); // Mal orthographié : `.deepEqual` en `.depEqual`, réparable
22 | t.contxt.foo = 100; // Mal orthographié : `.context` en `.contxt`, réparable
23 | t.deepEqual.skip.skip(); // Trop d'utilisations enchaînées de `.skip`, réparable
24 | t.skip.deepEqual(1, 1); //Le modificateur `.skip` doit être le dernier de la chaîne, réparable
25 | t.foo = 1000; // Membre `.foo` inconnu. Utilisez à la place `.context.foo`
26 | t.deepEqual.is(value, value); // Ne peut pas chainer des méthodes d'assertion
27 | t.skip(); // Manque la méthode d'assertion
28 | });
29 | ```
30 |
31 | ## Passe
32 |
33 | ```js
34 | const test = require('ava');
35 |
36 | test('main', t => {
37 | t.deepEqual(value, [2]);
38 | t.context.a = 100;
39 | require(`fixtures/${t.title}`);
40 | t.deepEqual.skip();
41 | });
42 | ```
43 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/use-t.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [use-t.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-t.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/c1cd7da74ac55abee856637c8bb75b385a444d1a...main#diff-19886e7d1ec7c93e9c2c06314561e8cdecc24ef445c2c7cca8b6a84b9798d73f) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `use-t.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que les fonctions de test utilisent `t` comme paramètre
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-t.md)
9 |
10 | La convention veut que le paramètre dans la fonction de test de AVA soit nommé `t`. La plupart des règles dans `eslint-plugin-ava` sont basées sur cette hypothèse.
11 |
12 | ### Échoue
13 |
14 | ```js
15 | const test = require('ava');
16 |
17 | test('foo', foo => { // Nom incorrect
18 | t.pass();
19 | });
20 | ```
21 |
22 | ### Passe
23 |
24 | ```js
25 | const test = require('ava');
26 |
27 | test('foo', () => {
28 | // ...
29 | });
30 |
31 | test('bar', t => {
32 | t.pass();
33 | });
34 | ```
35 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/use-test.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [use-test.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-test.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/9cd3fdf6b0b3a8fc9fc6a4a65aab297318d56226...main#diff-a19be9217f57aebf39df7fd205b406cbe0448a78f716fc8ea0cb64afcb171e90) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `use-test.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que AVA est importé avec la variable nommée `test`
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-test.md)
9 |
10 | La convention est d'importer AVA et de l'affecter à une variable nommée `test`. La plupart des règles dans `eslint-plugin-ava` sont basées sur cette hypothèse.
11 | Dans un fichier TypeScript (`.ts` ou `.tsx`), AVA peut être assigné à une variable nommée `anyTest` afin de définir les types de `t.context` (Consultez [Typage de t.context](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/typescript.md#typage-de-tcontext)). Les importations de type unique (`import type ... from 'ava'`) ne sont pas lintées.
12 |
13 | ### Échoue
14 |
15 | ```js
16 | var ava = require('ava');
17 | let ava = require('ava');
18 | const ava = require('ava');
19 | import ava from 'ava';
20 | ```
21 |
22 | ### Passe
23 |
24 | ```js
25 | var test = require('ava');
26 | let test = require('ava');
27 | const test = require('ava');
28 | import test from 'ava';
29 |
30 | var test = require('foo');
31 | const test = require('foo');
32 | ```
33 |
34 | ```ts
35 | import anyTest from 'ava';
36 | import type {TestInterface} from 'ava';
37 |
38 | const test = anyTest as TestInterface<{foo: string}>;
39 | ```
40 |
--------------------------------------------------------------------------------
/fr_FR/related/eslint-plugin-ava/docs/rules/use-true-false.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Note du traducteur**
3 |
4 | C'est la traduction du fichier [use-true-false.md](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-true-false.md). Voici un [lien](https://github.com/avajs/eslint-plugin-ava/compare/dee1802d39e22aec0915d5067062356f5abfbd84...main#diff-520f376c66c8580d078bea36fe8bbdb816bd0837658556786ba19576de57f882) vers les différences avec le master de eslint-plugin-ava (Si en cliquant sur le lien, vous ne trouvez pas le fichier `use-true-false.md` parmi les fichiers modifiés, vous pouvez donc en déduire que la traduction est à jour).
5 | ___
6 | # S'assurer que `t.true()`/`t.false()` sont utilisés à la place de `t.truthy()`/`t.falsy()`
7 |
8 | Traductions : [English](https://github.com/avajs/eslint-plugin-ava/blob/main/docs/rules/use-true-false.md)
9 |
10 | `t.true()` et `t.false()` sont plus strict que `t.truthy()` et `t.falsy`.
11 | Par exemple : si vous avez une fonction `foo()` qui retourne normalement `true`, mais retourne soudainement à la place `1`, `t.truthy(foo())` ne pourra pas attraper ce changement, alors que ce serait le cas avec `t.true(foo())`.
12 | Cette règle impose l'utilisation de `t.true()`/`t.false()` lorsque l'expression testée est connue pour retourner une valeur booléenne.
13 |
14 | ### Échoue
15 |
16 | ```js
17 | const test = require('ava');
18 |
19 | test('foo', t => {
20 | t.truthy(value < 2);
21 | t.truthy(value === 1);
22 | t.truthy([1, 2, 3].includes(value));
23 | t.falsy(!value);
24 | t.truthy(!!value);
25 | t.truthy(Array.isArray(value));
26 | });
27 | ```
28 |
29 | ### Passe
30 |
31 | ```js
32 | const ava = require('ava');
33 |
34 | test('foo', t => {
35 | t.true(value < 2);
36 | t.true(value === 1);
37 | t.true([1, 2, 3].includes(value));
38 | t.false(!value);
39 | t.true(!!value);
40 | t.true(Array.isArray(value));
41 | });
42 | ```
43 |
--------------------------------------------------------------------------------
/it_IT/docs/recipes/debugging-with-chrome-devtools.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traduttore**
3 |
4 | Questa è la traduzione del file [debugging-with-chrome-devtools.md](https://github.com/avajs/ava/blob/main/docs/recipes/debugging-with-chrome-devtools.md). Qui c'è il [link](https://github.com/avajs/ava/compare/c09462c3e515c41da8177a3d9ba5fb0f19759653...main#diff-7621c4f96f622506986f9cf7a125d6a1) dove si confrontano le differenze tra commit di riferimento di questa traduzione e l'ultimo commit di AVA sul branch master (Se si clicca sul link, e non si vede il file `debugging=with-chrome-devtools.md` nella lista dei file modificati, questa traduzione è aggiornata).
5 | ___
6 | # Fare debugging con i Chrome DevTools
7 |
8 | Traduzioni:
9 | [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/debugging-with-chrome-devtools.md),
10 | [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/debugging-with-chrome-devtools.md)
11 |
12 | Usa [inspect-process](https://github.com/jaridmargolin/inspect-process) per lanciare una sessione di debugging con i Chrome DevTools.
13 |
14 | ```console
15 | $ npm install --global inspect-process
16 | ```
17 |
18 | ```console
19 | $ inspect node_modules/ava/profile.js some/test/file.js
20 | ```
21 |
--------------------------------------------------------------------------------
/it_IT/docs/recipes/debugging-with-vscode.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traduttore**
3 |
4 | Questa è la traduzione del file [debugging-with-vscode.md](https://github.com/sindresorhus/ava/blob/master/docs/recipes/debugging-with-vscode.md). Qui c'è il [link](https://github.com/avajs/ava/compare/c09462c3e515c41da8177a3d9ba5fb0f19759653...main#diff-a3927068f3a0ffbbdf1b02fbd401b146) dove si confrontano le differenze tra commit di riferimento di questa traduzione e l'ultimo commit di AVA sul branch master (Se si clicca sul link, e non si vede il file `debugging-with-vscode.md` nella lista dei file modificati, questa traduzione è aggiornata).
5 | ___
6 | # Fare debugging dei test con Visual Studio Code
7 |
8 | Translations: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/debugging-with-vscode.md)
9 | [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/debugging-with-vscode.md)
10 |
11 | ## Setup
12 |
13 | Sulla barra a lato di VSCode clicca su `Debug`.
14 |
15 | Aggiungi una nuova configurazione cliccando sul campo a fianco del tasto verde `Debug`, poi clicca su `Add configuration`. Si aprirà un file `launch.json` con tutte le impostazioni per il debug.
16 |
17 | Aggiungi il seguente all'oggetto `configurations`:
18 |
19 | ```json
20 | {
21 | "type": "node",
22 | "request": "launch",
23 | "name": "Avvia AVA test",
24 | "program": "${workspaceRoot}/node_modules/ava/profile.js",
25 | "args": [
26 | "${file}"
27 | ]
28 | }
29 | ```
30 |
31 | Dopo aver aggiunto la configurazione salva il file.
32 |
33 | ## Debug
34 |
35 | > **Nota:** Il file su cui vuoi fare il debug deve essere aperto e attivo in VSCode
36 |
37 | > **Nota:** I breakpoint in VSCode possono non funzionare correttamente a volte (in particolare quando si tratta di codice async). L'istruzione `debugger;` funziona sempre correttamente.
38 |
39 | Aggiungi il breakpoint nel codice **o** aggiungere l'istruzione `debugger;` nel punto in cui si vuole fermare l'esecuzione.
40 |
41 | Clicca il tasto verde `Debug` accanto alla lista delle configurazioni, in alto a sinistra del pannello `Debug` in VSCode. Una volta che l'esecuzione si fermerà al punto in cui si è impostato il breakpoint sarà possibile guardare i valori delle variabili ed eseguire il codice riga per riga.
--------------------------------------------------------------------------------
/it_IT/docs/recipes/debugging-with-webstorm.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traduttore**
3 |
4 | Questa è la traduzione del file [debugging-with-webstorm.md](https://github.com/sindresorhus/ava/blob/master/docs/recipes/debugging-with-webstorm.md). Qui c'è il [link](https://github.com/avajs/ava/compare/c09462c3e515c41da8177a3d9ba5fb0f19759653...main#diff-1fb9cdb432e04d416229256c338f1a06) dove si confrontano le differenze tra commit di riferimento di questa traduzione e l'ultimo commit di AVA sul branch master (Se si clicca sul link, e non si vede il file `debugging-with-webstorm.md` nella lista dei file modificati, questa traduzione è aggiornata).
5 | ___
6 | # Fare debugging con WebStorm
7 |
8 | Traduzioni:
9 | [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/debugging-with-webstorm.md),
10 | [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/debugging-with-webstorm.md)
11 |
12 | Dalla versione 2016.2, [WebStorm](https://www.jetbrains.com/webstorm/) e altri IDE JetBrains (IntelliJ IDEA Ultimate, PHPStorm, PyCharm Professional, e RubyMine con il plugin Node.js installato) ti permettono di fare debugging dei test AVA.
13 |
14 | ## Setup con Node.js
15 |
16 | Aggiungi una nuova *Configurazione Run/Debug per Node.js*: seleziona `Modifica Configurazioni...` dal menù a tendina in alto a destra, poi clicca su `+` e seleziona *Node.js*.
17 |
18 | Nel campo `Javascript file` scrivi il `path` relativo all'installazione di AVA nella cartella `node_modules`: `node_modules/.bin/ava` per macOS e Linux oppure `node_modules/.bin/ava.cmd` per Windows.
19 |
20 | Nel campo `Parametri applicazione` scrivi i `flag` CLI che vuoi usare per i file di test di cui vuoi fare il debug, ad esempio `--verbose test.js`.
21 |
22 | Salva la configurazione.
23 |
24 | ## Setup con npm
25 |
26 | Esegui `ava --init` nella cartella del tuo progetto per aggiungere AVA al tuo `package.json`.
27 |
28 | Il file `package.json` sarà quindi simile al seguente:
29 |
30 | ```json
31 | {
32 | "name": "awesome-package",
33 | "scripts": {
34 | "test": "ava"
35 | },
36 | "devDependencies": {
37 | "ava": "^0.20.0"
38 | }
39 | }
40 | ```
41 |
42 | Aggiungi una *nuova configurazione di debug per `npm`*: seleziona `Edit Configurations` dal menù a tendina in alto a destra, clicca `+` e seleziona *`npm`*.
43 |
44 | Usa i seguenti parametri di configurazione:
45 |
46 | - `package.json`: percorso per il file `package.json` del tuo progetto
47 | - `Command`: `test`
48 |
49 | Il tuo IDE eseguirà `npm run test` chiamando `node_modules/.bin/ava` e la configurazione da te inserita nel `package.json`.
50 |
51 | Non dimenticare di selezionare l'interprete Node.js.
52 |
53 | Salva la configurazione.
54 |
55 | ## Debug
56 |
57 | Imposta i breakpoints nel codice.
58 |
59 | Clicca il bottone verde `Debug` vicino alla lista delle configurazioni in alto a destra. La *finestra di debug* comparirà ed una volta che il breakpoint verrà raggiunto, potrai ispezionare le variabile ed eseguire il codice riga per riga. Quando si fa debugging più file di testing, puoi anche saltare tra processi utilizzando il menù a tendina nel pannello *Frames*.
60 |
--------------------------------------------------------------------------------
/it_IT/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traduttore**
3 |
4 | Questa è la traduzione del file [endpoint-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md). Qui c'è il [link](https://github.com/avajs/ava/compare/c09462c3e515c41da8177a3d9ba5fb0f19759653...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9) dove si confrontano le differenze tra commit di riferimento di questa traduzione e l'ultimo commit di AVA sul branch master (Se si clicca sul link, e non si vede il file `endpoint-testing.md` nella lista dei file modificati, questa traduzione è aggiornata).
5 | ___
6 | # Test di endpoint
7 |
8 | Traduzioni: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/endpoint-testing.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/endpoint-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/endpoint-testing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/endpoint-testing.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/docs/recipes/endpoint-testing.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/endpoint-testing.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/endpoint-testing.md)
9 |
10 | AVA non ha un metodo nativo per il test di endpoint, ma puoi utilizzare un'altra libreria si asserzione per questo. In questo esempio utilizzeremo [`supertest`](https://github.com/visionmedia/supertest).
11 |
12 | Poichè i test saranno eseguiti in concorrenza, è meglio creare una nuova instanza del server per ciascun file di test, poichè se utilizzassimo sempre la stessa istanza, questa potrebbe cambiare il suo stato tra un test e l'altro. Questo si può fare utilizzando `test.beforeEach` e `t.context`, o semplicemente con una funzione factory:
13 |
14 | ```js
15 | function makeApp() {
16 | const app = express();
17 | app.post('/signup', signupHandler);
18 | return app;
19 | }
20 | ```
21 |
22 | Poi, iniettiamo l'istanza server in supertest. L'unica particolarità da tenere a mente è quella di usare una Promise o async/await invece del metodo `end` di supertest:
23 |
24 | ```js
25 | test('signup:Success', async t => {
26 | t.plan(2);
27 |
28 | const res = await request(makeApp())
29 | .post('/signup')
30 | .send({email: 'ava@rocks.com', password: '123123'});
31 |
32 | t.is(res.status, 200);
33 | t.is(res.body.email, 'ava@rocks.com');
34 | });
35 | ```
36 |
--------------------------------------------------------------------------------
/it_IT/docs/recipes/jspm-systemjs.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traduttore**
3 |
4 | Questa è la traduzione del file [jspm-systemjs.md](https://github.com/sindresorhus/ava/blob/master/docs/recipes/jspm-systemjs.md). Qui c'è il [link](https://github.com/avajs/ava/compare/c09462c3e515c41da8177a3d9ba5fb0f19759653...main#diff-e1128fe3361ff27e14e2ebec6c6ff362) dove si confrontano le differenze tra commit di riferimento di questa traduzione e l'ultimo commit di AVA sul branch master (Se si clicca sul link, e non si vede il file `jspm-systemjs.md` nella lista dei file modificati, questa traduzione è aggiornata).
5 | ___
6 | # JSPM e SystemJS per ES2015
7 |
8 | Traduzioni: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/jspm-systemjs.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/jspm-systemjs.md)
9 |
10 | Per usare AVA con JSPM si richiede l'utilizzo di un loader speciale per far funzionare correttamente l'istruzione `import` dei pacchetti JSPM. Lo scopo del loader è quello di permettere di eseguire i test senza pre-compilare il tuo progetto JSPM.
11 |
12 | ## Setup
13 |
14 | Questa ricetta è stata testata unicamente con JSPM v.0.17.0-beta.22 ma dovrebbe funzionare con ogni versione di JSPM v0.17 e forse anche con le versioni v0.16.
15 |
16 | ### Babel
17 |
18 | Configura il file `.babelrc` per eseguire AVA se non l'hai ancora fatto. Puoi avere configurazioni aggiuntive nei tui file di configurazione JSPM per sovrascrivere queste impostazioni durante la fase di assemblamento (bundling) e compilazione.
19 |
20 | ```json
21 | {
22 | "presets": ["es2015", "stage-2"]
23 | }
24 | ```
25 |
26 | Puoi trovare maggiori informazioni su come configurare Babel con AVA nella ricetta [babelrc](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/babelrc.md).
27 |
28 | ### Helper JSPM Loader
29 |
30 | Come prima cosa installa il [loader JSPM per AVA](https://github.com/skorlir/ava-jspm-loader) come una dipendenza dev.
31 |
32 | ```
33 | $ npm install --save-dev ava-jspm-loader
34 | ```
35 |
36 | Aggiorna anche la tua configurazione AVA nel `package.json` per usare il loader JSPM.
37 |
38 | ```json
39 | {
40 | "ava": {
41 | "require": [
42 | "babel-register",
43 | "ava-jspm-loader"
44 | ]
45 | }
46 | }
47 | ```
48 |
49 | NOTA: se usi `async`/`await` nel tuo codice sorgente (non nei tuoi file di test!) avrai bisogno di installare `babel-polyfill` da `npm` e aggiungerli al tuo Array di `require`.
50 |
51 | ### File test di esempio
52 |
53 | Per tutti i tuoi file nel progetto avrai bisogno di utilizzare `System.import`. Quindi se hai chiamato il tuo progetto `app` e vuoi importare il tuo file `main.js` in un file di test dovrai importare il file in queto modo `import main from 'app/main'`.
54 |
55 | ```js
56 | import test from 'ava';
57 | import main from 'app/main'; // Maps to your JSPM config for "app/main.js"
58 | import BigNumber from 'bignumber.js'; // In jspm_packages
59 |
60 | function fn() {
61 | return Promise.resolve(new BigNumber('1234567890.123456789'));
62 | }
63 |
64 | test('example test', async t => {
65 | t.is((await fn()).toString(), '1234567890.123456789');
66 | });
67 | ```
--------------------------------------------------------------------------------
/it_IT/docs/recipes/typescript.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traduttore**
3 |
4 | Questa è la traduzione del file [typescript.md](https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md). Qui c'è il [link](https://github.com/avajs/ava/compare/c09462c3e515c41da8177a3d9ba5fb0f19759653...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9) dove si confrontano le differenze tra commit di riferimento di questa traduzione e l'ultimo commit di AVA sul branch master (Se si clicca sul link, e non si vede il file `typescript.md` nella lista dei file modificati, questa traduzione è aggiornata).
5 | ___
6 | # TypeScript
7 |
8 | Traduzioni: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/typescript.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/typescript.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/typescript.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/typescript.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/typescript.md)
9 |
10 | AVA è dotato nativamente con un file definitione TypeScript. Questo permette agli sviluppatori di utilizzare TypeScript per scrivere i test.
11 |
12 | ## Configurazione
13 |
14 | Come prima cosa installa il [TypeScript](https://github.com/Microsoft/TypeScript) (se è già installato, controlla che la versione sia 2.1 o successiva).
15 |
16 | ```
17 | $ npm install --save-dev typescript
18 | ```
19 |
20 | Crea un file [`tsconfig.json`](https://github.com/Microsoft/TypeScript/wiki/tsconfig.json). Questo file serve per le opzioni del compilatore richieste per la compilazione del progetto o dei file di test.
21 |
22 | ```json
23 | {
24 | "compilerOptions": {
25 | "module": "commonjs",
26 | "target": "es2015"
27 | }
28 | }
29 | ```
30 |
31 | Aggiungi uno script `test` nel file `package.json`. Questo servirà a compilare prima il progetto e poi eseguire AVA.
32 |
33 | ```json
34 | {
35 | "scripts": {
36 | "test": "tsc && ava"
37 | }
38 | }
39 | ```
40 |
41 |
42 | ## Aggiungi i test
43 |
44 | Crea un file `test.ts`.
45 |
46 |
47 | ```ts
48 | import test from 'ava';
49 |
50 | async function fn() {
51 | return Promise.resolve('foo');
52 | }
53 |
54 | test(async (t) => {
55 | t.is(await fn(), 'foo');
56 | });
57 | ```
58 |
59 | ## Attivare [`context`](https://github.com/avajs/ava#test-context)
60 |
61 | Il tipo predefinito di `t.context` è [`any`](https://www.typescriptlang.org/docs/handbook/basic-types.html#any). AVA espone un'interfaccia `RegisterContextual` da utilizzare per applicare il tipo specifico a `t.context`. Questo può aiutare a rintracciare errori a tempo di compilazione:
62 |
63 | ```ts
64 | import * as ava from 'ava';
65 |
66 | function contextualize(getContext: () => T): ava.RegisterContextual {
67 | ava.test.beforeEach(t => {
68 | Object.assign(t.context, getContext());
69 | });
70 |
71 | return ava.test;
72 | }
73 |
74 | const test = contextualize(() => ({ foo: 'bar' }));
75 |
76 | test.beforeEach(t => {
77 | t.context.foo = 123; // error: Type '123' is not assignable to type 'string'
78 | });
79 |
80 | test.after.always.failing.cb.serial('very long chains are properly typed', t => {
81 | t.context.fooo = 'a value'; // error: Property 'fooo' does not exist on type '{ foo: string }'
82 | });
83 |
84 | test('an actual test', t => {
85 | t.deepEqual(t.context.foo.map(c => c), ['b', 'a', 'r']); // error: Property 'map' does not exist on type 'string'
86 | });
87 | ```
88 |
89 | ## Esegui i test
90 |
91 | ```
92 | $ npm test
93 | ```
94 |
--------------------------------------------------------------------------------
/it_IT/docs/recipes/vue.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota del traduttore**
3 |
4 | Questa è la traduzione del file [vue.md](https://github.com/sindresorhus/ava/blob/master/docs/recipes/vue.md). Qui c'è il [link](https://github.com/avajs/ava/compare/c09462c3e515c41da8177a3d9ba5fb0f19759653...main#diff-09533a825d46c23878919cd6e9bb1182) dove si confrontano le differenze tra commit di riferimento di questa traduzione e l'ultimo commit di AVA sul branch master (Se si clicca sul link, e non si vede il file `vue.md` nella lista dei file modificati, questa traduzione è aggiornata).
5 | ___
6 | # Testare componenti Vue.js
7 |
8 | Traduzioni: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/vue.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/vue.md)
9 |
10 | ## Dipendenze
11 |
12 | - [Estensione per gli hook require](https://github.com/jackmellis/require-extension-hooks):
13 | - `npm i --save-dev require-extension-hooks require-extension-hooks-vue require-extension-hooks-babel`
14 |
15 | - [browser-env](browser-testing.md)
16 | - `npm i --save-dev browser-env`
17 |
18 | ## Setup
19 |
20 | Il primo passo consiste nell'impostare un helper per configurare l'ambiente per la traspilazione dei file `.vue` e la simulazione di un ambiente browser:
21 |
22 | ```json
23 | {
24 | "ava": {
25 | "babel": "inherit",
26 | "require": [
27 | "./test/helpers/setup.js"
28 | ]
29 | }
30 | }
31 | ```
32 |
33 | ```js
34 | // ./test/helpers/setup.js
35 |
36 | // Setup browser environment
37 | require('browser-env')();
38 | const hooks = require('require-extension-hooks');
39 | const Vue = require('vue');
40 |
41 | // Setup Vue.js to remove production tip
42 | Vue.config.productionTip = false;
43 |
44 | // Setup vue files to be processed by `require-extension-hooks-vue`
45 | hooks('vue').plugin('vue').push();
46 | // Setup vue and js files to be processed by `require-extension-hooks-babel`
47 | hooks(['vue', 'js']).plugin('babel').push();
48 | ```
49 |
50 | Puoi trovare maggiori informazioni su come configurare Babel con AVA nella ricetta [babelrc](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/babelrc.md).
51 |
52 | ## Snapshot test semplice
53 |
54 | ```js
55 | import test from 'ava';
56 | import Vue from 'vue';
57 | import Component from 'component.vue';
58 |
59 | test('renders', t => {
60 | const vm = new Vue(Component).$mount();
61 | const tree = {
62 | $el: vm.$el.outerHTML
63 | };
64 | t.snapshot(tree);
65 | });
66 | ```
67 |
68 | ## Report di code coverage
69 |
70 | Come primo passo segui la ricetta [code coverage]
71 | Follow the [coverage reporting recipe](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/code-coverage.md), poi aggiungi l'estensione `.vue` alla configurazione di `nyc` per instrumentare i file `.vue`.
72 |
73 | ```json
74 | {
75 | "nyc": {
76 | "extension": [
77 | ".js",
78 | ".vue"
79 | ]
80 | }
81 | }
82 | ```
--------------------------------------------------------------------------------
/ja_JP/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | ___
2 | **訳注**
3 |
4 | これは[code-of-conduct.md](https://github.com/avajs/ava/blob/main/.github/CODE_OF_CONDUCT.md)の日本語訳です。こちらがAVAのmasterブランチとの差分の[リンク](https://github.com/avajs/ava/compare/93af8d8d2cb48fe0d2c4ede3c92964a295f60cb6...main#diff-d3030a18b089fdb1fbfabf6e75e4aef0)になります(このリンクをクリックして、`code-of-conduct.md`に変更点が見当たらなければ、この翻訳が最新であることを意味します)。
5 | ___
6 |
7 | # コントリビューターの行動規範
8 |
9 | このプロジェクトのコントリビューターやメンテナーとして、オープンで友好的
10 | コミュニティの利益のために、私たちはissueを報告したり、機能のリクエストしたり、
11 | ドキュメントを更新したり、プルリクエストやパッチを送ったり、また、その他の活動を
12 | する全ての人々を尊重することを誓います。
13 |
14 | 私たちは、経験の違いや性別、性別のアイデンティティや表現、性的指向、障害、
15 | 個人的外観、体格、人種、民族、年齢、宗教、国籍などに関係なく、皆にとって
16 | ハラスメントのないプロジェクトにすることにコミットします。
17 |
18 |
19 | 参加者による容認できない行動の例は以下のようなものです。
20 |
21 |
22 | * 性的な言葉や画像を使用
23 | * 個人攻撃
24 | * 挑発や侮辱/軽蔑的なコメント
25 | * 公的または私的なハラスメント
26 | * 許可なく住所やメールアドレスといった、他人の個人情報の公開
27 | * その他の非論理的、または職業上の規則に反した振る舞い
28 |
29 | プロジェクトのメンテナーは、行動規範に沿わないコメント、コード、ウィキ、issue、
30 | コントリビューター等を削除、編集、拒否する、または、その他の不適切と判断できる
31 | 、脅迫、攻撃、不為等の振る舞いをするコントリビューターを一時的でも永久にでも
32 | 追放する権利と義務を持ちます。
33 |
34 | この行動規範を採用することによって、プロジェクトのメンテナーは、プロジェクトの
35 | 運営の全ての側面に公平に一貫してこれらの原則を適用することを彼ら自身に確約します。
36 | 行動規範に従わない、実施しないプロジェクトメンテナーはプロジェクトチームから
37 | 永久に追放されます。
38 |
39 | この行動規範は、プロジェクト内と、公的な場で個人がこのプロジェクトかこの
40 | コミュニティを代表する場合の両方に適用されます。
41 |
42 | 虐待や嫌がらせの例、あるいは受け入れられない振る舞いは、sindresorhus@gmail.com
43 | でプロジェクトメンテナに連絡することで、報告されます。全ての申し立ては、確認、
44 | 調査され、必要と認められ、適切な事情があるという結果になるでしょう。メンテナは
45 | 争いの報告者に関して機密性の維持を義務付けられます。
46 |
47 |
48 |
49 | この行動規範は、[Contributor Covenant][homepage]のバージョン1.3.0を改変したものであり、
50 | バージョン1.3.0については[http://contributor-covenant.org/version/1/3/0/][version]で確認できます。
51 |
52 |
53 | [homepage]: http://contributor-covenant.org
54 | [version]: http://contributor-covenant.org/version/1/3/0/
55 |
--------------------------------------------------------------------------------
/ja_JP/contributing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **訳注**
3 |
4 | これは[contributing.md](https://github.com/avajs/ava/blob/main/.github/CONTRIBUTING.md)の日本語訳です。こちらがAVAのmasterブランチとの差分の[リンク](https://github.com/avajs/ava/compare/93af8d8d2cb48fe0d2c4ede3c92964a295f60cb6...main#diff-cc4aac3e9be04e0413c9520f223b493c)になります(このリンクをクリックして、`contributing.md`に変更点が見当たらなければ、この翻訳が最新であることを意味します)。
5 | ___
6 |
7 | # AVAにコントリビュートするために
8 |
9 | ✨ AVAにコントリビュートしてくれてありがとう! ✨
10 |
11 | このプロジェクトは[コントリビューターの行動規範](code-of-conduct.md)に基づいてリリースされます。プロジェクトに参加することにより、この行動規範に従うことを同意することになります。
12 |
13 | 翻訳: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/contributing.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/contributing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/contributing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/contributing.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/contributing.md)
14 |
15 | ## どうやってコントリビュートできますか?
16 |
17 | ### ドキュメントの改善
18 |
19 | AVAのユーザーとして、ドキュメントを改善することは完璧に私たちの手助けになります。タイポの修正、エラーの修正、より良い説明、より多くの例、など。改善できることについてissueを作成してください。[私たちのドキュメントを翻訳するのを手伝ってください。](https://github.com/avajs/ava-docs)何でもいいです。このドキュメントの改善でも。
20 |
21 | ### issueの改善
22 |
23 | いくつかのissueは、情報が足りなかったり、バグの再現ができない、または単に間違って作成されています。これを解決しやすくするために手伝ってください。issueの処理に対してたくさんの時間がかかりますが、この時間はバグの修正や機能追加に費やせるはずです。
24 |
25 | ### issueでフィードバックをください
26 |
27 | 私たちはいつもissueトラッカーでより多くの意見や議論を求めています。それはAVAの将来の方向性に影響を与える良い機会となっています。
28 |
29 | ### チャットで話しましょう
30 |
31 | [チャット](https://gitter.im/avajs/ava)があります。参加して、話しかけて、みんなを手助けしてください。
32 |
33 | ### issueを作成
34 |
35 | - issueトラッカーはissueのためのものです。サポートが必要なら[chat](https://gitter.im/avajs/ava)か[Stack Overflow](https://stackoverflow.com/questions/tagged/ava)を利用してください。
36 | - issueを作成する前にissueトラッカーで検索してください。
37 | - 最新バージョンのAVAを使用しているか確認してください。
38 | - 明確で叙述的な見出しをつけてください。
39 | - 可能な限りの情報を含めてください: issueを再現する手順、エラーメッセージ、Node.jsのバージョン、OS、など。
40 | - issueを書くのに多くの時間をかけてください。私たちはより多くの時間をかけます。
41 | - [最善のissueの報告はテストが失敗することで証明することです。](https://twitter.com/sindresorhus/status/579306280495357953)
42 |
43 | ### プルリクエストの提出
44 |
45 | - 不要な作業をしてしまわないように、小さくない変更は最初にissueで議論するのが一番良いことが多いです。
46 | - 大きなタスクであれば、フィードバックを可能な限り早く得るためにコミュニティに作業を見えるようにするべきです。アイディアを実現するのに必要最小限のことが完了したらすぐプルリクエストを出してください。この段階で完璧である必要も100%の状態である必要もありません。[WIP]プレフィックスを見出しに追加して、これからまだ必要なことを記述してください。そうすることで、詳細について小うるさくしなくても、また、すでにあなたが分かっている改善点を指摘しなくてもいいとレビューアーに知らせることになります。
47 | - 新たな機能はテストとドキュメントを含めてください。
48 | - 関連性のない変更を含まないでください。
49 | - プルリクエストを送る前に`$ npm test`を実行することでlintとテストを行ってください。
50 | - masterからではなく[トピックブランチ](https://github.com/dchelimsky/rspec/wiki/Topic-Branches)からプルリクエストを作成してください。
51 | - プルリクエストとコミットには明確で叙述的な見出しを使用してください。
52 | - なぜプルリクエストを確認すべきなのか納得のいく理由を書いてください。私たちを納得させるのはあなたの役目です。"なぜ"それが必要なのかと、使用例を見せてください。
53 | - あなたのプルリクエストに対して変更を求めることもあると思います。その場合新たに他のプルリクエストを作る必要は全くありません。[すでに存在するプルリクエストを更新してください。](https://github.com/RichardLitt/knowledge/blob/master/github/amending-a-commit-guide.md)
54 |
--------------------------------------------------------------------------------
/ja_JP/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **訳注**
3 |
4 | これは[endpoint-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md)の日本語訳です。こちらがAVAのmasterブランチとの差分の[リンク](https://github.com/avajs/ava/compare/93af8d8d2cb48fe0d2c4ede3c92964a295f60cb6...main#diff-aee54ab6a703c02779edb3ebbb35e96f)になります(このリンクをクリックして、`endpoint-testing.md`に変更点が見当たらなければ、この翻訳が最新であることを意味します)。
5 | ___
6 |
7 | # エンドポイントのテスト
8 |
9 | AVAはエンドポイントのテストのためのビルトインメソッドを持っていませんが、どのようなアサーションライブラリでも一緒に利用できます。[`supertest-as-promised`](https://github.com/WhoopInc/supertest-as-promised)を使ってみましょう。
10 |
11 | テストを直列で実行するので、同じインスタンスを参照するとテスト間でお互いに打ち消しうるために、テスト毎に新たなサーバーインスタンスを作成するのがベストです。これは、`test.beforeEach`や`t.context`、もしくは単純にファクトリー関数で実現できます。
12 |
13 | ```js
14 | function makeApp() {
15 | const app = express();
16 | app.post('/signup', signupHandler);
17 | return app;
18 | }
19 | ```
20 |
21 | 次に、supertestにサーバーインスタンスを挿入します。唯一の落とし穴は、supertestの`end`メソッドの代わりにpromiseかasync/awaitの構文を使用することです:
22 |
23 | ```js
24 | test('signup:Success', async t => {
25 | t.plan(2);
26 |
27 | const res = await request(makeApp())
28 | .post('/signup')
29 | .send({email: 'ava@rocks.com', password: '123123'});
30 |
31 | t.is(res.status, 200);
32 | t.is(res.body.email, 'ava@rocks.com');
33 | });
34 | ```
35 |
--------------------------------------------------------------------------------
/ko_KR/docs/02-execution-context.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [02-execution-context.md](https://github.com/avajs/ava/blob/main/docs/02-execution-context.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # 실행 컨텍스트 (`t` 인자)
8 |
9 | 각 테스트, hook들은 실행 컨텍스트(execution context)와 함께 호출됩니다.
10 |
11 | 실행 컨텍스트란, 컨벤션으로 `t`라고 이름 지어진 인자입니다.
12 |
13 | ```js
14 | import test from 'ava';
15 |
16 | test('my passing test', t => {
17 | t.pass();
18 | });
19 | ```
20 |
21 | 각각의 테스트, hook들은 서로 다른 객체를 넘겨 받습니다.
22 |
23 | 해당 객체는 [단언문](./03-assertions.md)(assertions)을 메서드 및 프로퍼티 형태로 포함하고 있습니다.
24 |
25 | 해당 메서드와 프로퍼티들은 아래와 같습니다.
26 |
27 | ## `t.title`
28 |
29 | 테스트 타이틀.
30 |
31 | ## `t.context`
32 |
33 | hook들 간 공유되는 상태.
34 |
35 | ## `t.passed`
36 |
37 | `test.afterEach()`, `test.afterEach.always()` hook들을 사용할 때, 해당 테스트가 통과(pass) 되었는지를 나타냅니다.
38 |
39 | 테스트 자체에서 사용될 땐 (teardown 함수들을 포함해) 이것은 단언문(assertions)이 실패하거나, 테스트가 에러를 던지면서 끝나거나, teardown 함수가 에러를 일으킬 때 까지 `true`로 남아 있습니다.
40 |
41 | 이 값은 다른 hook들에선 아무 의미도 갖지 않습니다.
42 |
43 | ## `t.log(...values)`
44 |
45 | 즉시 `stdout`에 출력하는 게 아니라, 문맥에 맞게 테스트 결과와 함께 기록 합니다.
46 |
47 | `console.log`처럼 다소 비슷하게 작동하지만, placeholder token은 지원하지 않습니다.
48 |
49 | ## `t.plan(count)`
50 |
51 | 몇 개의 단언문들이 테스트에서 실행되어야 하는지 설정합니다.
52 |
53 | `count`개의 단언문이 실제로 실행되지 않았다면 테스트가 실패할 것입니다.
54 |
55 | [단언문 계획하기](./03-assertions.md#plan-단언문-사용하기)를 참조하세요.
56 |
57 | ## `t.teardown(fn)`
58 |
59 | 테스트가 끝나고 실행될 `fn` 함수를 등록합니다.
60 |
61 | 여러 개의 함수들을 등록할 수 있습니다.
62 |
63 | 등록된 함수들은 역순으로 실행될 것입니다. 즉, 가장 마지막에 등록된 함수가 가장 먼저 실행됩니다.
64 |
65 | 비동기 함수를 사용할 수 있습니다: 한 번에 하나의 함수가 처리됩니다.
66 |
67 | 해당 함수 내부에서 `t` 객체로 단언문을 실행하거나, 추가 함수를 등록할 수 없습니다.
68 |
69 | 또한 hook에서도 `t.teardown()`을 사용할 수 없습니다.
70 |
71 | ## `t.timeout(ms)`
72 |
73 | milliseconds 단위로, 테스트에 대한 타임아웃을 설정합니다.
74 |
75 | 해당 테스트는 `ms`가 지난 후 실패하게 됩니다.
76 |
77 | 각 단언문들이 실행될 때 마다 타임아웃 값(`ms`)은 리셋됩니다.
78 |
--------------------------------------------------------------------------------
/ko_KR/docs/04-snapshot-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [04-snapshot-testing.md](https://github.com/avajs/ava/blob/main/docs/04-snapshot-testing.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # 스냅샷 테스팅
8 |
9 | AVA는 [Jest에서 도입된 스냅샷 테스팅](https://facebook.github.io/jest/docs/snapshot-testing.html)을 지원합니다.
10 |
11 | 해당 기능은 [단언문 인터페이스](./03-assertions.md)를 통해 사용할 수 있습니다. 어떤 값이든 스냅샷을 찍어 놓을 수 있습니다.
12 |
13 | 스냅샷은 테스트 파일과 함께 저장됩니다.
14 |
15 | 테스트 파일들이 `test`나, `tests` 폴더에 있다면, 스냅샷들은 `snapshots` 폴더에 저장됩니다.
16 |
17 | 테스트 파일들이 `__tests__` 폴더에 있다면, 스냅샷들은 `__snapshots__` 폴더에 저장됩니다.
18 |
19 | 스냅샷 단언문을 포함하는 `~/project/test/main.js` 테스트 파일이 있다고 가정해봅시다.
20 |
21 | AVA는 두 개의 파일을 만들 것 입니다:
22 |
23 | * `~/project/test/snapshots/main.js.snap`
24 | * `~/project/test/snapshots/main.js.md`
25 |
26 | 첫 번째 파일은 실질적인 스냅샷 파일로, 미래에 비교를 위해 사용됩니다.
27 |
28 | 두 번째 파일은 *스냅샷 리포트*를 포함합니다.
29 |
30 | 이 파일은 스냅샷이 업데이트 될 때 재생성됩니다.
31 |
32 | 만약 소스 컨트롤에 커밋한다면, 해당 파일로 스냅샷에 대한 변경 사항을 비교해 볼 수 있습니다.
33 |
34 | AVA는 스냅샷 단언문이 실패한 이유를 보여줍니다. :
35 |
36 |
37 |
38 | 그럼 코드를 확인해보면 됩니다.
39 |
40 | 만약 스냅샷 파일들의 변화가 의도된 것이라면, `--update-snapshots` (또는 `-u`) 플래그를 사용해 스냅샷들을 업데이트 할 수 있습니다.
41 |
42 | ```console
43 | $ ava --update-snapshots
44 | ```
45 |
46 | 만약 특정 테스트들을 위해 스냅샷을 업데이트 할 필요가 있다면, `--update-snapshots` 플래그와 함께 `--match` 플래그를 사용하거나 `.only()`를 사용해 테스트를 선택하세요.
47 |
48 | [`package.json` 설정](./06-configuration.md)에 스냅샷 파일들을 저장할 위치를 지정할 수 있습니다.
49 |
50 | **`package.json`:**
51 |
52 | ```json
53 | {
54 | "ava": {
55 | "snapshotDir": "custom-directory"
56 | }
57 | }
58 | ```
59 |
60 | 스냅샷 파일은 테스트 파일들의 경로를 반영한 디렉터리 구조에 저장될 것입니다.
61 |
62 | precompile된 테스트 파일에 대해 AVA를 실행하는 경우, AVA는 원본 파일들의 위치를 확인하기 위해 소스 맵(source map)을 사용하려 할 것입니다.
63 |
64 | 스냅샷 파일들은 해당 소스 맵 파일들과 함께 저장될 것입니다. 이 때에도 AVA가 직접 원본 파일들을 실행했을 때와 같은 룰을 따릅니다.
65 |
66 | 이것은 타입스크립트로 테스트를 작성할 때 아주 유용합니다. (참조: [타입스크립트 레시피](./recipes/typescript.md))
67 |
--------------------------------------------------------------------------------
/ko_KR/docs/07-test-timeouts.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [07-test-timeouts.md](https://github.com/avajs/ava/blob/main/docs/07-test-timeouts.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # Timeout 테스트
8 |
9 | [](https://stackblitz.com/github/avajs/ava/tree/main/examples/timeouts?file=test.js&terminal=test&view=editor)
10 |
11 | AVA의 timeout는 다른 테스트 프레임워크의 timeout과 다르게 작동합니다.
12 |
13 | AVA는 매 테스트 종료 후 타이머를 리셋하며, 지정된 timeout 내에 새 테스트 결과가 수신되지 않은 경우 테스트를 강제로 종료합니다.
14 |
15 | 이것은 정지된 테스트를 처리하는데 사용될 수 있습니다.
16 |
17 | timeout 값은 기본으로 10초로 지정됩니다.
18 |
19 | timeout 값을 `--timeout` [command line option](./05-command-line.md) 인자로 넘겨주거나, [configuration](./06-configuration.md)에 설정할 수 있습니다.
20 |
21 | 이것은 읽기 쉬운(human-readable) 방식으로 지정될 수 있습니다:
22 |
23 | ```console
24 | npx ava --timeout=10s # 10 초
25 | npx ava --timeout=2m # 2 분
26 | npx ava --timeout=100 # 100 밀리 초
27 | ```
28 |
29 | ### `t.timeout(ms, message?)`
30 |
31 | 각 테스트에 대해 개별적으로 제한 시간을 설정할 수도 있습니다. timeout은 단언문이 실행될 때마다 재설정됩니다.
32 |
33 | 단언문이 생성되거나 테스트가 완료되는데 `ms` 이상의 시간이 소요될 경우 테스트가 실패합니다.
34 |
35 | ```js
36 | test('foo', t => {
37 | t.timeout(100); // 100 밀리 초
38 | // 여기에 단언문을 작성하세요.
39 | });
40 | ```
41 |
42 | timeout에 메시지 문자열을 제공할 수도 있습니다.
43 |
44 | 이 기능은 당신의 테스트가 아직 완료되지 않았을 수 있는 다른 설정에 의존하는 경우에 유용할 수 있습니다.
45 |
46 | ```js
47 | test('foo', t => {
48 | t.timeout(100, 'make sure database has started'); // 100 밀리 초
49 | // 여기에 단언문을 작성하세요.
50 | });
51 | ```
52 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/babel.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [babel.md](https://github.com/avajs/ava/blob/main/docs/recipes/babel.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # AVA에서 바벨 설정하기
8 |
9 | `@babel/register`, `@babel/core` 패키지를 설치하여 바벨을 활성화 할 수 있습니다.
10 |
11 | AVA 설정의 `@babel/register`에 아래 설정을 추가하세요.
12 |
13 | **`package.json`:**
14 |
15 | ```json
16 | {
17 | "ava": {
18 | "require": [
19 | "@babel/register"
20 | ]
21 | }
22 | }
23 | ```
24 |
25 | `@babel/register`는 CommonJS와만 호환됩니다.
26 |
27 | 해당 패키지는 require 호출을 가로채 소스 파일들을 실행 중(on the fly)에 컴파일합니다.
28 |
29 | 이것은 source, helper, test 파일들을 컴파일할 것입니다.
30 |
31 | [`Babel 문서`](https://babeljs.io/docs/en/babel-register)에서 더 많은 정보를 알아보세요.
32 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/browser-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [browser-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/browser-testing.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 | # 브라우저 테스팅을 위해 AVA 설정하기
7 |
8 | 전체 번역 문서들: [English](https://github.com/avajs/ava/raw/main/docs/recipes/browser-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/recipes/browser-testing.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/browser-testing.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/browser-testing.md), [한국어](https://github.com/avajs/ava-docs/blob/main/ko_KR/docs/recipes/browser-testing.md)
9 |
10 | AVA는 [아직](https://github.com/avajs/ava/issues/24) 브라우저에서 테스트를 실행하는 방법을 지원하지 않고 있습니다. 몇 가지 라이브러리는 브라우저 특정 전역 변수를 요구합니다. (`window`, `document`, `navigator`, 등) 예를 들면 React가 있습니다. 아마 최소한 ReactDOM.render를 사용하고 ReactTestUtils를 통해 이벤트를 시뮬레이션하고 싶을 것입니다.
11 |
12 | 이 레시피는 모킹된 브라우저 환경을 필요로하는 모든 라이브러리에서 작동합니다.
13 |
14 | ## jsdom 설치
15 |
16 | [jsdom](https://github.com/tmpvar/jsdom)을 설치합니다.
17 |
18 | > WHATWG DOM과 HTML 표준의 JavaScript 구현입니다. node.js와 함께 사용할 수 있습니다.
19 |
20 | ```
21 | $ npm install --save-dev jsdom
22 | ```
23 |
24 | ## jsdom 설정하기
25 |
26 | `test/helpers` 폴더에 헬퍼 파일을 만듭니다. 이 폴더에 넣으면 AVA가 테스트로 오인하지 않도록 해줍니다.
27 |
28 | `test/helpers/setup-browser-env.js`:
29 |
30 | ```js
31 | global.document = require('jsdom').jsdom('');
32 | global.window = document.defaultView;
33 | global.navigator = window.navigator;
34 | ```
35 |
36 | ## 테스트가 jsdom을 사용하도록 설정하기
37 |
38 | AVA가 각각의 헬퍼 파일을 테스트 파일로 `require` 하도록 설정합니다.
39 |
40 | `package.json`:
41 |
42 | ```json
43 | {
44 | "ava": {
45 | "require": [
46 | "./test/helpers/setup-browser-env.js"
47 | ]
48 | }
49 | }
50 | ```
51 |
52 | ## 즐기세요!
53 |
54 | 테스트를 작성하고 모킹된 window 객체를 즐깁니다.
55 |
56 | `test/my.react.test.js`:
57 |
58 | ```js
59 | import test from 'ava';
60 | import React from 'react';
61 | import {render} from 'react-dom';
62 | import {Simulate} from 'react-addons-test-utils';
63 | import sinon from 'sinon';
64 | import CustomInput from './components/custom-input.jsx';
65 |
66 | test('Input appelle onBlur', t => {
67 | const onUserBlur = sinon.spy();
68 | const input = render(
69 | React.createElement(CustomInput, onUserBlur),
70 | div
71 | );
72 |
73 | Simulate.blur(input);
74 |
75 | t.true(onUserBlur.calledOnce);
76 | });
77 | ```
78 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/code-coverage.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [code-coverage.md](https://github.com/avajs/ava/blob/main/docs/recipes/code-coverage.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # 코드 커버리지
8 |
9 | [`c8`]을 사용해 테스트의 코드 커버리지를 계산하세요.
10 |
11 | 아래 명령어로 [`c8`]을 설치하세요.
12 |
13 | ```
14 | $ npm install --save-dev c8
15 | ```
16 |
17 | 가장 단순하게는, [`c8`]을 통해 AVA를 실행할 수 있습니다. 당신의 `package.json` 파일에 아래처럼 `c8 ava`을 추가하세요.
18 |
19 | ```json
20 | {
21 | "scripts": {
22 | "test": "c8 ava"
23 | }
24 | }
25 | ```
26 |
27 | 소스 컨트롤에서 `coverage` 디렉토리를 제거하고 싶다면, git을 사용 중인 경우 `.gitignore`에 아래 라인을 추가하세요.
28 |
29 | ```
30 | coverage
31 | ```
32 |
33 | [`c8`]: https://github.com/bcoe/c8
34 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/debugging-with-chrome-devtools.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [debugging-with-chrome-devtools.md](https://github.com/avajs/ava/blob/main/docs/recipes/debugging-with-chrome-devtools.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # Chrome DevTools로 테스트 디버깅하기
8 |
9 | [Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools)를 사용하여 테스트를 디버그할 수 있습니다.
10 |
11 | Chrome을 열고, 로 이동하세요.
12 |
13 | *Devices* 섹션의 *Open dedicated DevTools for Node* 링크를 클릭하세요.
14 |
15 | *DevTools for Node* 창에서, *Sources*로 이동하고, 왼쪽 열들 중 *Filesystem*을 클릭하세요.
16 |
17 | 작업 영역에 프로젝트 디렉토리를 추가하세요. 적절한 권한을 부여해야 함을 유의하세요.
18 |
19 | 이제 특정 테스트 파일을 실행합니다.
20 |
21 | ```console
22 | npx ava debug test.js
23 | ```
24 |
25 | DevTools가 자동으로 연결되고 당신의 테스트가 실행될 것입니다.
26 |
27 | DevTools를 사용하여 중단점을 설정하거나 `debugger` 키워드를 사용하세요.
28 |
29 | 테스트 파일이 로드되기 바로 전에 DevTools가 중단점에 도달하도록 하려면 `--break` 옵션과 함께 실행하세요.
30 |
31 | ```console
32 | npx ava debug --break test.js
33 | ```
34 |
35 | 기본적으로 inspector는 `127.0.0.1:9229`에서 대기(listens on)합니다.
36 |
37 | 호스트와 포트를 사용자 정의할 수 있습니다.
38 |
39 | ```console
40 | npx ava debug --host 0.0.0.0 --port 9230 test.js
41 | ```
42 |
43 | *Connection* 탭에서 이 포트에 대한 연결을 추가해야 합니다.
44 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [endpoint-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # 엔드 포인트 테스팅 (Endpoint testing)
8 |
9 | [](https://stackblitz.com/github/avajs/ava/tree/main/examples/endpoint-testing?file=test.js&terminal=test&view=editor)
10 |
11 | AVA는 엔드 포인트를 테스트하기 위한 빌트인 기능을 지원하지 않지만, 원하는 HTTP 클라이언트 (예, [`got`](https://github.com/sindresorhus/got))를 선택해 사용할 수 있습니다.
12 |
13 | 또한 테스트를 병렬로 실행할 수 있도록 고유한 포트에서 HTTP 서버를 시작해야 합니다.
14 |
15 | 이를 위해 [`test-listen`](https://github.com/zeit/test-listen) 라이브러리를 추천합니다.
16 |
17 | 테스트가 동시에(concurrently) 실행되므로 각 테스트에 대해, 또는 적어도 각 테스트 파일들에 대해 새 서버 인스턴스를 만드는 것이 가장 좋습니다.
18 |
19 | 이것은 `test.before()`, `test.beforeEach()` hook 및 `t.context`를 사용해 달성될 수 있습니다.
20 |
21 | `test.before()` hook을 사용하여 서버를 시작할 경우, 테스트가 연속적으로(serially) 실행됨을 보장해야 합니다.
22 |
23 | 아래의 예제를 확인하세요.:
24 |
25 | ```js
26 | const http = require('http');
27 | const test = require('ava');
28 | const got = require('got');
29 | const listen = require('test-listen');
30 | const app = require('../app');
31 |
32 | test.before(async t => {
33 | t.context.server = http.createServer(app);
34 | t.context.prefixUrl = await listen(t.context.server);
35 | });
36 |
37 | test.after.always(t => {
38 | t.context.server.close();
39 | });
40 |
41 | test.serial('get /user', async t => {
42 | const {email} = await got('user', {prefixUrl: t.context.prefixUrl}).json();
43 | t.is(email, 'ava@rocks.com');
44 | });
45 | ```
46 |
47 | 유용할 수 있는 다른 라이브러리들:
48 |
49 | - [`supertest`](https://github.com/visionmedia/supertest)
50 | - [`get-port`](https://github.com/sindresorhus/get-port)
51 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/es-modules.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [es-modules.md](https://github.com/avajs/ava/blob/main/docs/recipes/es-modules.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # AVA에서 ESM 사용하기
8 |
9 | AVA 4는 기본적으로 ES 모듈을 지원합니다.
10 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/passing-arguments-to-your-test-files.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [passing-arguments-to-your-test-files.md](https://github.com/avajs/ava/blob/main/docs/recipes/passing-arguments-to-your-test-files.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # 테스트 파일들에 인자(arguments) 넘겨주기
8 |
9 | 테스트 파일에 커맨드 라인 인자를 넘겨줄 수 있습니다.
10 |
11 | `--` argument terminator를 사용해, AVA의 인자와 당신의 인자를 분리하도록 하세요.
12 |
13 | ```js
14 | // test.js
15 | import test from 'ava';
16 |
17 | test('argv', t => {
18 | t.deepEqual(process.argv.slice(2), ['--hello', 'world']);
19 | });
20 | ```
21 |
22 | ```console
23 | $ npx ava -- --hello world
24 | ```
25 |
26 | 만약 `npm test` 스크립트 내부에서, AVA를 호출하려고 하는 경우, 두 개의 `--` argument terminators가 필요합니다.
27 |
28 | ```json
29 | {
30 | "scripts": {
31 | "test": "ava"
32 | }
33 | }
34 | ```
35 |
36 | ```console
37 | $ npm test -- -- --hello world
38 | ```
39 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/puppeteer.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [puppeteer.md](https://github.com/avajs/ava/blob/main/docs/recipes/puppeteer.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # Puppeteer를 사용해서 웹앱 테스트하기
8 |
9 | ## 의존성(dependencies) 설치
10 |
11 | - [Puppeteer](https://github.com/GoogleChrome/puppeteer): `npm install --save-dev puppeteer`
12 |
13 | ## 설정하기
14 |
15 | 첫 번째 단계는 환경을 구성할 helper를 설정하는 것입니다.
16 |
17 | `./test/_withPage.js`
18 |
19 | ```js
20 | import puppeteer from 'puppeteer';
21 |
22 | module.exports = async (t, run) => {
23 | const browser = await puppeteer.launch();
24 | const page = await browser.newPage();
25 | try {
26 | await run(t, page);
27 | } finally {
28 | await page.close();
29 | await browser.close();
30 | }
31 | }
32 | ```
33 |
34 | ## 사용 예제
35 |
36 | `./test/main.js`
37 |
38 | ```js
39 | import test from 'ava';
40 | import withPage from './_withPage';
41 |
42 | const url = 'https://google.com';
43 |
44 | test('page title should contain "Google"', withPage, async (t, page) => {
45 | await page.goto(url);
46 | t.true((await page.title()).includes('Google'));
47 | });
48 |
49 | test('page should contain an element with `#hplogo` selector', withPage, async (t, page) => {
50 | await page.goto(url);
51 | t.not(await page.$('#hplogo'), null);
52 | });
53 |
54 | test('search form should match the snapshot', withPage, async (t, page) => {
55 | await page.goto(url);
56 | const innerHTML = await page.evaluate(form => form.innerHTML, await page.$('#searchform'));
57 | t.snapshot(innerHTML);
58 | });
59 | ```
60 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/splitting-tests-ci.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [splitting-tests-ci.md](https://github.com/avajs/ava/blob/main/docs/recipes/splitting-tests-ci.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # CI에서 테스트 나누기
8 |
9 | AVA는 [ci-parallel-vars](https://www.npmjs.com/package/ci-parallel-vars)를 사용하여 자동으로 당신의 CI 환경이 병렬 빌드(parallel build)를 지원하는지 감지합니다.
10 | 병렬 빌드가 지원되는 경우, AVA는 모든 테스트 파일들의 이름을 정렬하고, 그것들을 청크들(chunks)로 나눕니다. 각 CI 머신들은 테스트의 부분 집합들을 할당 받고, 각 청크 (테스트) 들은 병렬로 실행됩니다.
11 |
12 | 테스트를 시스템 전체에 더 잘 분산하기 위해 comparator을 아래처럼 커스터마이징 할 수 있습니다.
13 |
14 | **`ava.config.js`:**
15 |
16 | ```js
17 | import fs from 'node:fs';
18 |
19 | // 'test-data.json' 파일의 구조가 아래와 같다고 가정:
20 | // {
21 | // 'tests/test1.js': { order: 1 },
22 | // 'tests/test2.js': { order: 0 }
23 | // }
24 | const testData = JSON.parse(fs.readFileSync('test-data.json', 'utf8'));
25 |
26 | export default {
27 | sortTestFiles: (file1, file2) => testData[file1].order - testData[file2].order,
28 | };
29 | ```
30 |
--------------------------------------------------------------------------------
/ko_KR/docs/recipes/watch-mode.md:
--------------------------------------------------------------------------------
1 | ___
2 | **역자주**
3 |
4 | 이 문서는 [watch-mode.md](https://github.com/avajs/ava/blob/main/docs/recipes/watch-mode.md)의 한국어 번역입니다. [이곳](https://github.com/avajs/ava/compare/71404c23302d825095659c70cb9a1b08251697ad...main#diff-0730bb7c2e8f9ea2438b52e419dd86c9)에서 AVA의 master 브랜치와 이 문서의 차이를 확인할 수 있습니다. (만약 차이가 없다면 문서가 최신 버전임을 의미합니다)
5 | ___
6 |
7 | # 감시 모드 (Watch mode)
8 |
9 | AVA는 지능형 감시 모드(watch mode)를 제공합니다.
10 |
11 | 변경되는 파일들을 감시하고, 변경된 파일에 영향을 받는 테스트들만 실행합니다.
12 |
13 | ## 감시 모드를 활성화하고 테스트 실행하기
14 |
15 | `--watch` 또는 `-w` 플래그를 사용하여 감시 모드를 활성화할 수 있습니다.
16 |
17 | ```console
18 | $ npx ava --watch
19 | ```
20 |
21 | 감시 모드 사용 시 통합 디버깅, TAP reporter를 사용할 수 없는 것에 유의해주세요.
22 |
23 | ## 요구 사항
24 |
25 | AVA는 [`chokidar`]를 파일 감시 라이브러리로 사용합니다.
26 |
27 | 설치하는 동안 optional dependencies가 실패한다는 경고가 표시되더라도 제대로 작동할 것 입니다.
28 |
29 | chokidar 설치 문제를 해결하려면 `chokidar` 다큐먼트의 *[Install Troubleshooting]* 섹션을 참조하십시오.
30 |
31 | ## 변경 무시하기
32 |
33 | 기본적으로 AVA는 `snap`, `ava.config.*` 확장자의 파일을 제외한 모든 파일의 변경 사항을 감시합니다.
34 |
35 | 그 외에도 [`ignore-by-default`] 패키지에서 [certain directories](https://github.com/novemberborn/ignore-by-default/blob/master/index.js) 내의 파일들을 무시합니다.
36 |
37 | [`package.json`, `ava.config.*` 파일의 `ava` 섹션][config]에서 `ignoredByWatcher` 키를 사용해, 무시할 파일의 패턴을 추가적으로 구성할 수 있습니다.
38 |
39 | 테스트가 디스크에 파일을 쓸 때 chokidar가 테스트를 재실행할 수 있습니다. 추가적인 무시 패턴을 설정하는 것이 이러한 문제를 방지하는데 도움을 줄 수 있습니다.
40 |
41 | ## 의존성 추적
42 |
43 | AVA는 테스트 파일들이 의존 중인 소스 파일들을 추적합니다.
44 |
45 | 이러한 의존성을 변경하면, 이에 의존 중인 테스트 파일들만 재실행됩니다.
46 |
47 | AVA는 어떤 테스트 파일이 변경된 소스 파일에 의존 중인지 결정할 수 없는 경우, 모든 테스트 파일을 재실행 합니다.
48 |
49 | 의존성 추적은 required된 모듈들에 대해서도 작동합니다.
50 |
51 | [`package.json`, `ava.config.*` 파일에 설정을 추가함으로써][config] 사용자 지정 확장 및 트랜스파일러도 지원됩니다.
52 |
53 | `fs` 모듈을 사용하여 액세스하는 파일은 추적되지 않습니다.
54 |
55 | ## 감시 모드와 `.only` 한정자
56 |
57 | `.only` 한정자는 감시 모드의 의존성 추적 알고리즘을 비활성화 시킵니다.
58 |
59 | 변경이 감지 되었을 때, 모든 `.only` 테스트들은, 해당 테스트가 의존 중인 소스 파일에 관계 없이 재실행될 것입니다.
60 |
61 | ## 감시 모드와 CI
62 |
63 | 감시 모드로 CI에서 AVA를 실행하면 다음과 같은 에러와 함께 실행이 종료될 것입니다.
64 |
65 | (`Error : Watch mode is not available in CI, as it prevents AVA from terminating.`).
66 |
67 | AVA는 CI에서 `--watch` (`-w`) 옵션과 함께 사용될 수 없습니다. CI에서 프로세스들은 종료되어야만 하고, `--watch` 옵션을 사용하면 AVA가 절대 종료되지 않을 것이기 때문입니다.
68 |
69 | ## 수동으로 모든 테스트 재실행하기
70 |
71 | 콘솔에서 r를 입력한 다음 Enter를 입력하면 모든 테스트를 빠르게 다시 실행할 수 있습니다.
72 |
73 | ## 스냅샷 업데이트
74 |
75 | 콘솔에 u를 입력한 다음 Enter를 입력하여 실패 중인(failing) 스냅샷을 업데이트할 수 있습니다.
76 |
77 | ## 디버깅
78 |
79 | 하나의 테스트만 실행될 것이라고 생각했을 때, watch 모드는 가끔 당황스럽게 모든 테스트를 재실행합니다.
80 |
81 | AVA의 추론을 보기 위해 디버그 모드를 활성화할 수 있습니다. 이 방법은 verbose reporter에 가장 적합할 것입니다.
82 |
83 | ```console
84 | $ DEBUG=ava:watcher npx ava --watch
85 | ```
86 |
87 | ## 감시 모드를 더 좋게 만들 수 있도록 도와주세요
88 |
89 | 감시 모드는 비교적 새로운 기능으로, 다소 조잡한 부분이 있을 수 있습니다.
90 |
91 | 당신이 만난 이슈를 [리포트](https://github.com/avajs/ava/issues) 해 주세요. 감사합니다!
92 |
93 | [`chokidar`]: https://github.com/paulmillr/chokidar
94 | [Install Troubleshooting]: https://github.com/paulmillr/chokidar#install-troubleshooting
95 | [`ignore-by-default`]: https://github.com/novemberborn/ignore-by-default
96 | [`.only` modifier]: ../01-writing-tests.md#running-specific-tests
97 | [config]: ../06-configuration.md
98 |
--------------------------------------------------------------------------------
/pl_PL/docs/02-execution-context.md:
--------------------------------------------------------------------------------
1 | # Kontekst wykonania (`t` argument)
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/02-execution-context.md)
4 |
5 | Każdy test lub hook jest wywoływany z kontekstem wykonania. Zgodnie z konwencją jest nazywany `t`.
6 |
7 | ```js
8 | const test = require('ava');
9 |
10 | test('my passing test', t => {
11 | t.pass();
12 | });
13 | ```
14 |
15 | Każdy test lub hook otrzymuje inny obiekt. Zawiera [asercje](./03-assertions.md), a także metody i właściwości wymienione poniżej.
16 |
17 | ## `t.title`
18 |
19 | Tytuł testu.
20 |
21 | ## `t.context`
22 |
23 | Zawiera stan współdzielony z hooks.
24 |
25 | ## `t.plan(count)`
26 |
27 | Zaplanuj, ile asercji jest w teście. Test zakończy się niepowodzeniem, jeśli faktyczna liczba asercji nie będzie zgodna z liczbą planowanych asercji. Zobacz [planowanie asercji](./03-assertions.md#assertion-planning).
28 |
29 | ## `t.end()`
30 |
31 | Zakończ test. Działa tylko z `test.cb()`.
32 |
33 | ## `t.log(...values)`
34 |
35 | Rejestruj wartości kontekstowo obok wyniku testu zamiast natychmiast je drukować do `stdout`. Zachowuje się trochę jak `console.log`, ale bez obsługi tokenów zastępczych.
36 |
37 | ## `t.timeout(ms)`
38 |
39 | Ustaw limit czasu testu w milisekundach. Test zakończy się niepowodzeniem, jeśli ten limit czasu zostanie przekroczony. Limit czasu jest resetowany przy każdej asercji.
40 |
--------------------------------------------------------------------------------
/pl_PL/docs/04-snapshot-testing.md:
--------------------------------------------------------------------------------
1 | # Testowanie snapshotów
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/04-snapshot-testing.md)
4 |
5 | AVA wspiera testowanie snapshotów (migawek), [zgodnie z wprowadzeniem od Jest](https://facebook.github.io/jest/docs/snapshot-testing.html), poprzez interfejs [Asercji](./03-assertions.md). Możesz wykonać snapshot dowolnej wartości, a także elementów React:
6 |
7 | ```js
8 | // Your component
9 | const HelloWorld = () => Hello World...!
;
10 |
11 | export default HelloWorld;
12 | ```
13 |
14 | ```js
15 | // Your test
16 | const test = require('ava');
17 | const render = require('react-test-renderer');
18 | const HelloWorld = require('.');
19 |
20 | test('HelloWorld component', t => {
21 | const tree = render.create().toJSON();
22 | t.snapshot(tree);
23 | });
24 | ```
25 |
26 | [Wypróbuj w tym przykładowym projekcie.](https://github.com/avajs/ava-snapshot-example)
27 |
28 | Snapshoty są przechowywane obok plików testowych. Jeśli twoje testy są w `test` lub folderze `tests`, snapshoty będą przechowywane w folderze `snapshots`. Jeśli twoje testy są w folderze `__tests__`, wtedy będą przechowywane w folderze `__snapshots__`.
29 |
30 | Powiedz, że masz `~/project/test/main.js` który zawiera snapshoty asercji. AVA utworzy dwa pliki:
31 |
32 | * `~/project/test/snapshots/main.js.snap`
33 | * `~/project/test/snapshots/main.js.md`
34 |
35 | Pierwszy plik zawiera rzeczywistą migawkę i jest wymagany do przyszłych porównań. Drugi plik zawiera twój *raport migawki*. Jest regenerowany po zaktualizowaniu migawek. Jeśli przekażesz go do kontroli źródła, możesz skorzystać z diff, aby zobaczyć zmiany w migawce.
36 |
37 | AVA pokaże, dlaczego asercja migawki nie powiodła się:
38 |
39 |
40 |
41 | Następnie możesz sprawdzić swój kod. Jeśli zmiana była zamierzona, możesz użyć `--update-snapshots` (lub `-u`) flagi, aby zaktualizować migawki:
42 |
43 | ```console
44 | $ ava --update-snapshots
45 | ```
46 |
47 | Możesz określić stałą lokalizację przechowywania plików migawek w AVA [konfiguracja `package.json`](./06-configuration.md):
48 |
49 | **`package.json`:**
50 |
51 | ```json
52 | {
53 | "ava": {
54 | "snapshotDir": "custom-directory"
55 | }
56 | }
57 | ```
58 |
59 | Pliki migawek zostaną zapisane w strukturze katalogów, która odzwierciedla strukturę plików testowych.
60 |
61 | Jeśli używasz AVA dla wstępnie skompilowanych plików testowych, AVA spróbuje użyć map źródłowych, aby ustalić lokalizację oryginalnych plików. Migawki będą przechowywane obok tych plików, zgodnie z tymi samymi regułami, jak gdyby AVA wykonał bezpośrednio oryginalne pliki. Jest to świetne, jeśli piszesz testy w TypeScript (zobacz naszą [formułę TypeScript](./recipes/typescript.md)).
62 |
--------------------------------------------------------------------------------
/pl_PL/docs/07-test-timeouts.md:
--------------------------------------------------------------------------------
1 | # Test timeoutów
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/07-test-timeouts.md)
4 |
5 | Limity czasu w AVA zachowują się inaczej niż w innych frameworkach testowych. AVA resetuje licznik czasu po każdym teście, zmuszając testy do zakończenia, jeśli nie otrzymano nowych wyników testu w określonym czasie. Można to wykorzystać do obsługi zablokowanych testów.
6 |
7 | Domyślny limit czasu to 10 sekund.
8 |
9 | Możesz skonfigurować limity czasu za pomocą `--timeout` [opcji wiersza poleceń](./05-command-line.md), lub w [konfiguracji](./06-configuration.md). Można je ustawić w sposób czytelny dla człowieka:
10 |
11 | ```console
12 | npx ava --timeout=10s # 10 seconds
13 | npx ava --timeout=2m # 2 minutes
14 | npx ava --timeout=100 # 100 milliseconds
15 | ```
16 |
17 | Limity czasu można również ustawić indywidualnie dla każdego testu. Limity czasu są resetowane za każdym razem, gdy dochodzi do asercji.
18 |
19 | ```js
20 | test('foo', t => {
21 | t.timeout(100); // 100 milliseconds
22 | // Write your assertions here
23 | });
24 | ```
25 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/babel.md:
--------------------------------------------------------------------------------
1 | # Konfiguracja Babel
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/babel.md)
4 |
5 | Możesz włączyć obsługę Babel, instalując `@ava/babel`, a następnie w ustawieniach konfiguracji AVA `babel` na `true`:
6 |
7 | **`package.json`:**
8 |
9 | ```json
10 | {
11 | "ava": {
12 | "babel": true
13 | }
14 | }
15 | ```
16 |
17 | Znajdź więcej na [`@ava/babel`](https://github.com/avajs/babel).
18 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/browser-testing.md:
--------------------------------------------------------------------------------
1 | # Konfigurowanie AVA do testowania w przeglądarce
2 |
3 | Tłumaczenia: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/browser-testing.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/browser-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/browser-testing.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/browser-testing.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/browser-testing.md)
4 |
5 | AVA nie obsługuje uruchamiania testów w przeglądarkach [jeszcze](https://github.com/avajs/ava/issues/24). Jednak biblioteki JavaScript wymagające specyficznych globalów dla przeglądarki (`window`, `document`, `navigator`, etc) nadal można przetestować za pomocą AVA, mockując te globale.
6 |
7 | Ten przepis działa na każdą bibliotekę, która potrzebuje zmockowanego środowiska przeglądarki.
8 |
9 | ## Zainstaluj browser-env
10 |
11 | > **❗️ Ważna uwaga**
12 | >
13 | >`browser-env` dodaje właściwości z okna `jsdom` przestrzeni nazw do globalnej przestrzeni nazw Node.js. Jest to wyraźnie [zalecane przeciwko](https://github.com/tmpvar/jsdom/wiki/Don't-stuff-jsdom-globals-onto-the-Node-global) od `jsdom`. Przeczytaj podlinkowaną stronę wiki i upewnij się, że rozumiesz ostrzeżenia. Jeśli nie masz wielu zależności, które również wymagają środowiska przeglądarki, to [`window`](https://github.com/lukechilds/window#universal-testing-pattern) może być lepszym rozwiązaniem.
14 |
15 | Instalacja [browser-env](https://github.com/lukechilds/browser-env).
16 |
17 | > Symuluje globalne środowisko przeglądarki przy użyciu jsdom.
18 |
19 | ```
20 | $ npm install --save-dev browser-env
21 | ```
22 |
23 | ## Ustaw browser-env
24 |
25 | Utwórz plik pomocniczy, poprzedzony znakiem podkreślenia. Dzięki temu AVA nie traktuje tego jako testu.
26 |
27 | `test/_setup-browser-env.js`:
28 |
29 | ```js
30 | const browserEnv = require('browser-env');
31 | browserEnv();
32 | ```
33 |
34 | Domyślnie, `browser-env` doda wszystkie globalne zmienne przeglądarki do globalnego zasięgu Node.js, tworząc pełne środowisko przeglądarki. Powinno to mieć dobrą zgodność z większością bibliotek front-end, jednak generalnie nie jest dobrym pomysłem tworzenie wielu zmiennych globalnych, jeśli nie jest to konieczne. Jeśli wiesz dokładnie, jakich globałów przeglądarki potrzebujesz, możesz przekazać ich tablicę.
35 |
36 | ```js
37 | const browserEnv = require('browser-env');
38 | browserEnv(['window', 'document', 'navigator']);
39 | ```
40 |
41 | Możesz ujawnić więcej zmiennych globalnych, przypisując je do obiektu `global`. Na przykład jQuery jest zazwyczaj dostępny za pośrednictwem zmiennej `$`:
42 |
43 | ```js
44 | const browserEnv = require('browser-env');
45 | const jQuery = require('jquery');
46 |
47 | browserEnv();
48 | global.$ = jQuery(window);
49 | ```
50 |
51 | ## Skonfiguruj testy do użycia browser-env
52 |
53 | Skonfiguruj AVA do `require` helpera przed każdym plikiem testowym.
54 |
55 | **`package.json`:**
56 |
57 | ```json
58 | {
59 | "ava": {
60 | "require": [
61 | "./test/_setup-browser-env.js"
62 | ]
63 | }
64 | }
65 | ```
66 |
67 | ## Enjoy!
68 |
69 | Napisz swoje testy i ciesz się zmockowanym środowiskiem przeglądarki.
70 |
71 | `test.js`:
72 |
73 | ```js
74 | const test = require('ava');
75 |
76 | test('Insert to DOM', t => {
77 | const div = document.createElement('div');
78 | document.body.appendChild(div);
79 |
80 | t.is(document.querySelector('div'), div);
81 | });
82 | ```
83 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/code-coverage.md:
--------------------------------------------------------------------------------
1 | # Pokrycie kodu
2 |
3 | Tłumaczenia: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/code-coverage.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/code-coverage.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/code-coverage.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/code-coverage.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/docs/recipes/code-coverage.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/code-coverage.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/code-coverage.md)
4 |
5 | Użyj [`nyc`] aby obliczyć zasięg kodu twoich testów.
6 |
7 | Najpierw zainstaluj [`nyc`]:
8 |
9 | ```
10 | $ npm install --save-dev nyc
11 | ```
12 |
13 | W najprostszym przypadku uruchom AVA [`nyc`]. W twoim pliku `package.json`:
14 |
15 | ```json
16 | {
17 | "scripts": {
18 | "test": "nyc ava"
19 | }
20 | }
21 | ```
22 |
23 | Możesz wykluczyć katalogi `.nyc_output` i `coverage` z kontroli źródła. Zakładając, że używasz Git, dodaj następujące elementy do swojego pliku `.gitignore`:
24 |
25 | ```
26 | .nyc_output
27 | coverage
28 | ```
29 |
30 | [`nyc`]: https://github.com/istanbuljs/nyc
31 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/debugging-with-chrome-devtools.md:
--------------------------------------------------------------------------------
1 | # Debuggowanie testów z Chrome DevTools
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/debugging-with-chrome-devtools.md)
4 |
5 | Możesz debugować swoje testy za pomocą [Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools).
6 |
7 | Otwórz Chrome, a następnie przejdź do . Kliknij link *Otwórz dedykowane narzędzia DevTools dla Node* w obrębie sekcji *Urządzenia*.
8 |
9 | W oknie *DevTools dla Node*, przejdź do *Źródła* i w lewej kolumnie wybierz *Filesystem*. Dodaj katalog projektu do obszaru roboczego. Upewnij się, że udzieliłeś pozwolenia.
10 |
11 | Teraz uruchom konkretny plik testowy:
12 |
13 | ```console
14 | npx ava debug test.js
15 | ```
16 |
17 | DevTools powinien połączyć się automatycznie, a twoje testy zostaną uruchomione. Użyj DevTools, aby ustawić punkty przerwania lub użyj słowa kluczowego `debugger`.
18 |
19 | Uruchom z opcją `--break` aby upewnić się, że DevTools osiągnęło punkt przerwania tuż przed załadowaniem pliku testowego:
20 |
21 | ```console
22 | npx ava debug --break test.js
23 | ```
24 |
25 | Domyślnie inspektor nasłuchuje na `127.0.0.1:9229`. Możesz dostosować hosta i port:
26 |
27 | ```console
28 | npx ava debug --host 0.0.0.0 --port 9230 test.js
29 | ```
30 |
31 | Musisz dodać połączenie dla tego portu w zakładce *Connection*.
32 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/debugging-with-vscode.md:
--------------------------------------------------------------------------------
1 | # Debugowanie testów z Visual Studio Code
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/debugging-with-vscode.md)
4 |
5 | Możesz debugować swoje testy za pomocą [Visual Studio Code](https://code.visualstudio.com/).
6 |
7 | ## Tworzenie konfiguracji uruchamiania
8 |
9 | 1. Otwórz obszar roboczy dla swojego projektu.
10 | 1. Na pasku bocznym kliknij uchwyt *Debug*.
11 | 1. Utwórz plik `launch.json`.
12 | 1. Wybierz środowisko Node.js.
13 | 1. Dodaj następujące do tablicy `configurations` i zapisz zmiany:
14 |
15 | ```json
16 | {
17 | "type": "node",
18 | "request": "launch",
19 | "name": "Debug AVA test file",
20 | "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
21 | "runtimeArgs": [
22 | "debug",
23 | "--break",
24 | "${file}"
25 | ],
26 | "port": 9229,
27 | "outputCapture": "std",
28 | "skipFiles": [
29 | "/**/*.js"
30 | ]
31 | }
32 | ```
33 |
34 | ## Używanie debuggera
35 |
36 | Otwórz plik(i), które chcesz debugować. Możesz ustawić punkty przerwania (breakpoints) lub użyć słowa kluczowego `debugger`.
37 |
38 | Teraz, *z otwartym plikiem testowym*, z menu *Debug* uruchom konfigurację *Debug AVA test file*.
39 |
40 | ## Debugowanie wstępnie skompilowanych testów
41 |
42 | Jeśli skompilujesz swoje pliki testowe w innym katalogu i uruchom testy *z* tego katalogu, powyższa konfiguracja nie będzie działać.
43 |
44 | Zakładając, że nazwy plików testowych są unikalne, możesz zamiast tego wypróbować następującą konfigurację. Zakłada się, że dane wyjściowe kompilacji są zapisywane w katalogu `build`. Dostosuj odpowiednio:
45 |
46 |
47 | ```json
48 | {
49 | "type": "node",
50 | "request": "launch",
51 | "name": "Debug AVA test file",
52 | "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
53 | "runtimeArgs": [
54 | "debug",
55 | "--break",
56 | "build/**/${fileBasenameNoExtension}.*"
57 | ],
58 | "port": 9229,
59 | "outputCapture": "std",
60 | "skipFiles": [
61 | "/**/*.js"
62 | ]
63 | }
64 | ```
65 |
66 | ## Seryjne debugowanie
67 |
68 | Domyślnie AVA uruchamia testy jednocześnie. Może to skomplikować debugowanie. Dodaj konfigurację za pomocą argumentu `--serial` więc AVA uruchamia tylko jeden test na raz:
69 |
70 | ```json
71 | {
72 | "type": "node",
73 | "request": "launch",
74 | "name": "Debug AVA test file",
75 | "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
76 | "runtimeArgs": [
77 | "debug",
78 | "--break",
79 | "--serial",
80 | "${file}"
81 | ],
82 | "port": 9229,
83 | "outputCapture": "std",
84 | "skipFiles": [
85 | "/**/*.js"
86 | ]
87 | }
88 | ```
89 |
90 | *Zauważ, że jeśli twoje testy nie są odpowiednio izolowane, niektóre niepowodzenia testów mogą nie pojawić się podczas ich seryjnego uruchamiania.*
91 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/debugging-with-webstorm.md:
--------------------------------------------------------------------------------
1 | # Debugowanie testów z WebStorm
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/debugging-with-webstorm.md)
4 |
5 | **Ten przepis jest nieaktualny.**
6 |
7 | ---
8 |
9 | Począwszy od wersji 2016.2, [WebStorm](https://www.jetbrains.com/webstorm/) i innych IDE od JetBrains (IntelliJ IDEA Ultimate, PHPStorm, PyCharm Professional, i RubyMine z zainstalowaną wtyczką Node.js) pozwalają debugować testy AVA.
10 |
11 |
12 | ## Skonfiguruj za pomocą Node.js
13 |
14 | Dodaj nowe *Node.js Run/Debug configuration*: wybierz `Edit Configurations...` z listy rozwijanej w prawym górnym rogu, a następnie kliknij `+` i wybierz *Node.js*.
15 |
16 | W polu `JavaScript file` podaj ścieżkę do AVA w folderze projektu `node_modules`: `node_modules/.bin/ava` na macOS i Linux lub `node_modules/.bin/ava.cmd` na Windows.
17 |
18 | W `Application parameters` przekaż na przykład flagi CLI i pliki testowe, które chcesz debugować, na przykład `--verbose test.js`.
19 |
20 | W `Node parameters`, przekaż flagę `--inspect-brk` aby włączyć inspektora Node'a.
21 |
22 | Zapisz konfigurację.
23 |
24 | ## Skonfiguruj za pomocą npm
25 |
26 | Wykonaj `npx @ava/init` w katalogu projektu, aby dodać AVA do swojego `package.json`.
27 |
28 | Twój `package.json` powinien wyglądać mniej więcej tak:
29 |
30 | ```json
31 | {
32 | "name": "awesome-package",
33 | "scripts": {
34 | "test": "ava"
35 | },
36 | "devDependencies": {
37 | "ava": "^1.0.0"
38 | }
39 | }
40 | ```
41 |
42 | Dodaj nowe *npm Run/Debug configuration*: wybierz `Edit Configurations...` z listy rozwijanej w prawym górnym rogu, a następnie kliknij `+` i wybierz *npm*.
43 |
44 | Użyj następujących parametrów konfiguracyjnych:
45 |
46 | - `package.json`: Ścieżka do pliku twojego projektu `package.json`
47 | - `Command`: `test`
48 |
49 | Twoje IDE następnie wykona `npm run test` i w ten sposób wywoła `node_modules/.bin/ava` oraz konfigurację AVA, którą określiłeś w swoim package.json.
50 |
51 | W `Node parameters`, przekaż `--inspect-brk`.
52 |
53 | Nie zapomnij wybrać interpretera Node.js.
54 |
55 | Zapisz konfigurację.
56 |
57 | ## Debug
58 |
59 | Ustaw breakpointy w kodzie.
60 |
61 | Kliknij zielony przycisk `Debug` obok listy konfiguracji w prawym górnym rogu. *Debug tool window* pojawi się. Po osiągnięciu punktu przerwania możesz ocenić zmienne i przejść przez kod. Podczas debugowania wielu plików testowych można przełączać się między procesami za pomocą menu rozwijanego w panelu Ramki.
62 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | # Testy endpoint
2 |
3 | Tłumaczenie: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/endpoint-testing.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/endpoint-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/endpoint-testing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/endpoint-testing.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/docs/recipes/endpoint-testing.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/endpoint-testing.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/endpoint-testing.md)
4 |
5 | AVA nie ma wbudowanej metody testowania punktów końcowych, ale możesz na przykład użyć dowolnego wybranego klienta HTTP [`got`](https://github.com/sindresorhus/got). Będziesz także musiał uruchomić serwer HTTP, najlepiej na unikalnym porcie, abyś mógł równolegle uruchamiać testy. Do tego zalecamy [`test-listen`](https://github.com/zeit/test-listen).
6 |
7 | Ponieważ testy są uruchamiane jednocześnie, najlepiej jest utworzyć nową instancję serwera przynajmniej dla każdego pliku testowego, ale być może nawet dla każdego testu. Można to osiągnąć za pomocą hooków `test.before()` i `test.beforeEach()` oraz `t.context`. Jeśli uruchomisz serwer za pomocą hooka `test.before()` powinieneś upewnić się, że testy wykonujesz szeregowo.
8 |
9 | Sprawdź poniższy przykład:
10 |
11 | ```js
12 | const http = require('http');
13 | const test = require('ava');
14 | const got = require('got');
15 | const listen = require('test-listen');
16 | const app = require('../app');
17 |
18 | test.before(async t => {
19 | t.context.server = http.createServer(app);
20 | t.context.baseUrl = await listen(t.context.server);
21 | });
22 |
23 | test.after.always(t => {
24 | t.context.server.close();
25 | });
26 |
27 | test.serial('get /user', async t => {
28 | const res = await got('/user', { baseUrl: t.context.baseUrl, json: true });
29 | t.is(res.body.email, 'ava@rocks.com');
30 | });
31 | ```
32 |
33 | Inne biblioteki, które mogą Ci się przydać:
34 |
35 | - [`supertest`](https://github.com/visionmedia/supertest)
36 | - [`get-port`](https://github.com/sindresorhus/get-port)
37 |
38 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/es-modules.md:
--------------------------------------------------------------------------------
1 | # Korzystanie z modułów ES w AVA
2 |
3 | Tłumaczenie: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/es-modules.md)
4 |
5 | Od Node.js 13, [ECMAScript Modules](https://nodejs.org/docs/latest/api/esm.html#esm_introduction) są natywnie obsługiwane w samym Node.js. AVA 3.3 obsługuje pliki testowe ESM, jednak obsługa jest niepełna. [Projekt wsparcia ESM](https://github.com/orgs/avajs/projects/2) śledzi nasze postępy.
6 |
7 | Obsługa ESM w Node.js jest eksperymentalna, choć domyślnie włączona w Node.js 13. *Zobaczysz takie komunikaty `ExperimentalWarning: The ESM module loader is experimental` w output'cie AVA. Są one emitowane przez Node.js, a nie AVA.*
8 |
9 | ## Włączanie eksperymentalnej obsługi ESM w Node.js 12
10 |
11 | W Node.js 12 musisz włączyć obsługę ESM. Możesz to zrobić za pomocą AVA, konfigurując `nodeArguments` w twoim `package.json` lub pliku `ava.config.*`:
12 |
13 | **`package.json`:**
14 |
15 | ```json
16 | {
17 | "ava": {
18 | "nodeArguments": [
19 | "--experimental-modules"
20 | ]
21 | }
22 | }
23 | ```
24 |
25 | Lub w wierszu poleceń:
26 |
27 | ```console
28 | npx ava --node-arguments '--experimental-modules' test.mjs
29 | ```
30 |
31 | ## Używanie pakietu `esm`
32 |
33 | Jeśli chcesz korzystać ze składni ESM, bez polegania na implementacji Node.js, najlepszym rozwiązaniem jest użycie pakietu [`esm`](https://github.com/standard-things/esm). Pamiętaj, aby użyć rozszerzenia `.js` i *nie* ustawić `"type": "module"` w `package.json`.
34 |
35 | Oto, jak możesz pracować z AVA.
36 |
37 | Najpierw zainstaluj `esm`:
38 |
39 | ```
40 | $ npm install esm
41 | ```
42 |
43 | Skonfiguruj go w swoim pliku `package.json` lub `ava.config.*`, i dodaj go do opcji AVA `"require"` tak właśnie. Pamiętaj, aby dodać go jako pierwszy element.
44 |
45 | **`package.json`:**
46 |
47 | ```json
48 | {
49 | "ava": {
50 | "require": [
51 | "esm"
52 | ]
53 | }
54 | }
55 | ```
56 |
57 | Możesz teraz używać natywnych modułów ES z AVA:
58 |
59 | ```js
60 | // sum.js
61 | export default function sum(a, b) {
62 | return a + b;
63 | };
64 | ```
65 |
66 | ```js
67 | // test.js
68 | const test = require('ava');
69 | const sum = require('./sum');
70 |
71 | test('2 + 2 = 4', t => {
72 | t.is(sum(2, 2), 4);
73 | });
74 | ```
75 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/isolated-mongodb-integration-tests.md:
--------------------------------------------------------------------------------
1 | # Izolowane testy integracyjne MongoDB
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/isolated-mongodb-integration-tests.md)
4 |
5 | > Jak uruchamiać jednorazowe bazy danych MongoDB w testach AVA z izolacją na test.
6 |
7 | To używa [`MongoMem`](https://github.com/CImrie/mongomem), co pozwala szybko uruchomić lokalnie tymczasowy serwer MongoDB. Wykorzystuje tymczasowe miejsce do przechowywania plików, które jest niszczone po zatrzymaniu serwera.
8 |
9 |
10 | ## Zainstaluj MongoDB in-memory Server (MongoMem)
11 |
12 | W katalogu głównym aplikacji uruchom:
13 |
14 | ```console
15 | $ npm install --save-dev mongomem
16 | ```
17 |
18 |
19 | ## Używanie MongoMem
20 |
21 | W pliku testowym zaimportuj moduł i uruchom serwer.
22 |
23 | **Pamiętaj, aby uruchomić serwer na początku pliku, poza przypadkami testowymi.**
24 |
25 | ```js
26 | const test = require('ava');
27 | const {MongoDBServer} = require('mongomem');
28 |
29 | test.before('start server', async t => {
30 | await MongoDBServer.start();
31 | })
32 |
33 | test('some feature', async t => {
34 | const connectionString = await MongoDBServer.getConnectionString();
35 |
36 | // connectionString === 'mongodb://localhost:27017/3411fd12-b5d6-4860-854c-5bbdb011cb93'
37 | // Use `connectionString` to connect to the database with a client of your choice. See below for usage with Mongoose.
38 | });
39 | ```
40 |
41 |
42 | ## Sprzątanie
43 |
44 | Po uruchomieniu testów należy dołączyć metodę `test.after.always()` aby wyczyścić serwer MongoDB. Spowoduje to usunięcie plików tymczasowych używanych przez serwer podczas działania.
45 |
46 | Jest to zwykle usuwane przez system operacyjny, ale dobrą praktyką jest robienie tego ręcznie.
47 |
48 | ```js
49 | test.after.always('cleanup', t => {
50 | MongoDBServer.tearDown(); // Cleans up temporary file storage
51 | });
52 | ```
53 |
54 |
55 | ## Debugowanie
56 |
57 | Jeśli serwer się nie uruchamia, możesz ustawić opcję `MongoDBServer.debug = true;` zanim wywołasz `MongoDBServer.start()`. Umożliwi to serwerowi MongoDB drukowanie błędów połączenia lub uprawnień do plików podczas uruchamiania. Sprawdza i wybiera dostępny port do uruchomienia serwera, więc błędy mogą być związane z uprawnieniami do plików.
58 |
59 | ## Dodatkowo: Konfiguracja i użycie w Mongoose
60 |
61 | [Mongoose](http://mongoosejs.com) to solidny Object-Document-Mapper (ODM) dla MongoDB. Zapoznaj się z jego dokumentacją, aby rozpocząć korzystanie z Mongoose.
62 |
63 | Aby skutecznie używać Mongoose z AVA, sprawdź [Dokumentacja integracji Mongoose](endpoint-testing-with-mongoose.md).
64 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/passing-arguments-to-your-test-files.md:
--------------------------------------------------------------------------------
1 | # Przekazywanie argumentów do plików testowych
2 |
3 | Tłumaczenie: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/passing-arguments-to-your-test-files.md)
4 |
5 | Możesz przekazać argumenty wiersza poleceń do plików testowych. Użyj argumentu `--` terminatora aby oddzielić argumenty AVA od własnych:
6 |
7 | ```js
8 | // test.js
9 | const test = require('ava');
10 |
11 | test('argv', t => {
12 | t.deepEqual(process.argv.slice(2), ['--hello', 'world']);
13 | });
14 | ```
15 |
16 | ```console
17 | $ npx ava -- --hello world
18 | ```
19 |
20 | Potrzebujesz dwóch `--` argumentów terminatorów jeśli wywołujesz AVA za pomocą skryptu `npm test`:
21 |
22 | ```json
23 | {
24 | "scripts": {
25 | "test": "ava"
26 | }
27 | }
28 | ```
29 |
30 | ```console
31 | $ npm test -- -- --hello world
32 | ```
33 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/puppeteer.md:
--------------------------------------------------------------------------------
1 | # Testowanie aplikacji internetowych za pomocą Puppeteer
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/puppeteer.md)
4 |
5 | ## Zależności
6 |
7 | - [Puppeteer](https://github.com/GoogleChrome/puppeteer): `npm install --save-dev puppeteer`
8 |
9 | ## Ustawienie
10 |
11 | Pierwszym krokiem jest skonfigurowanie pomocnika do skonfigurowania środowiska:
12 |
13 | `./test/_withPage.js`
14 |
15 | ```js
16 | const puppeteer = require('puppeteer');
17 |
18 | export default async function withPage(t, run) {
19 | const browser = await puppeteer.launch();
20 | const page = await browser.newPage();
21 | try {
22 | await run(t, page);
23 | } finally {
24 | await page.close();
25 | await browser.close();
26 | }
27 | }
28 | ```
29 |
30 | ## Przykład użycia
31 |
32 | `./test/main.js`
33 |
34 | ```js
35 | const test = require('ava');
36 | const withPage = require('./_withPage');
37 |
38 | const url = 'https://google.com';
39 |
40 | test('page title should contain "Google"', withPage, async (t, page) => {
41 | await page.goto(url);
42 | t.true((await page.title()).includes('Google'));
43 | });
44 |
45 | test('page should contain an element with `#hplogo` selector', withPage, async (t, page) => {
46 | await page.goto(url);
47 | t.not(await page.$('#hplogo'), null);
48 | });
49 |
50 | test('search form should match the snapshot', withPage, async (t, page) => {
51 | await page.goto(url);
52 | const innerHTML = await page.evaluate(form => form.innerHTML, await page.$('#searchform'));
53 | t.snapshot(innerHTML);
54 | });
55 | ```
56 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/testing-with-selenium-webdriverjs.md:
--------------------------------------------------------------------------------
1 | # Konfigurowanie AVA za pomocą Selenium WebDriverJS
2 |
3 | Ten przepis pokazuje, jak używać Selenium WebDriverJS (oficjalna implementacja JavaScript) z AVA do testowania aplikacji internetowych.
4 |
5 | ## Ustawienie
6 |
7 | Ten przepis wykorzystuje następujące pakiety:
8 |
9 | 1. [selenium-webdriver](https://www.npmjs.com/package/selenium-webdriver)
10 | 2. [chromedriver](https://www.npmjs.com/package/chromedriver)
11 |
12 | Zainstaluj je za pomocą:
13 |
14 | ```console
15 | $ npm install selenium-webdriver chromedriver
16 | ```
17 |
18 | W ramach tego przepisu użyjemy Selenium do weryfikacji wyszukiwań w Internecie [Bing](https://www.bing.com) i [Google](https://www.google.com).
19 |
20 | Utwórz następujące pliki:
21 |
22 | - `./test/bingtest.js`
23 | - `./test/googletest.js`
24 |
25 | W obu plikach najpierw dołączmy pakiety:
26 |
27 | ```js
28 | const test = require('ava');
29 | const {Builder, By, Key, until} = require('selenium-webdriver');
30 |
31 | require('chromedriver');
32 | ```
33 |
34 | W pliku `bingtest.js`, dodaj następujący kod, który sprawdza, czy szukasz `webdriver` w Bing, zwracając wyniki.
35 |
36 | ```js
37 | test('Bing Search', async t => {
38 | const keyword = 'webdriver';
39 | const driver = new Builder().forBrowser('chrome').build();
40 | await driver.get('https://www.bing.com');
41 | await driver.findElement(By.name('q')).sendKeys(keyword + Key.ENTER);
42 | await driver.wait(until.titleIs(keyword + ' - Bing'));
43 | t.true((await driver.findElements(By.css('#b_content #b_results li'))).length > 0);
44 | await driver.close();
45 | });
46 | ```
47 |
48 | W pliku `googletest.js`, zamiast jednego testu, dodajmy dwa testy, każdy dla warunków 'webdriver' i 'avajs'.
49 |
50 | Ponieważ chcielibyśmy zainicjować webdriver przed każdym testem, używamy hooków [`beforeEach` and `afterEach`](../01-writing-tests.md#before--after-hooks) aby odpowiednio skonfigurować i usunąć sterownik. Korzystanie z tych hooków pomaga zmniejszyć ilość kodu, który napisalibyśmy w każdym z nich `test()`.
51 |
52 | ```js
53 | test.beforeEach(async t => {
54 | t.context.driver = new Builder().forBrowser('chrome').build();
55 | await t.context.driver.get('https://www.google.com');
56 | });
57 |
58 | test.afterEach('cleanup', async t => {
59 | await t.context.driver.close();
60 | });
61 | ```
62 |
63 | Teraz dodajmy kod testowy:
64 |
65 | ```js
66 | async function searchGoogle(driver, keyword) {
67 | await driver.findElement(By.name('q')).sendKeys(keyword + Key.ENTER);
68 | await driver.wait(until.titleIs(`${keyword} - Google Search`));
69 | }
70 |
71 | test('Google Search for avajs', async t => {
72 | const {driver} = t.context;
73 | await searchGoogle(driver, 'avajs');
74 | t.true((await driver.findElement(By.id('resultStats')).getText()).includes('results'));
75 | });
76 |
77 | test('Google Search for webdriver', async t => {
78 | const {driver} = t.context;
79 | await searchGoogle(driver, 'webdriver');
80 | t.true((await driver.findElement(By.id('resultStats')).getText()).includes('results'));
81 | });
82 | ```
83 |
84 | Jesteś teraz gotowy do uruchomienia testów. Dane wyjściowe powinny wyglądać mniej więcej tak:
85 |
86 | ```console
87 | npx ava
88 | DevTools listening on ws://127.0.0.1:49720/devtools/browser/9ebf4394-447b-4916-91cc-692d06d88896
89 |
90 | DevTools listening on ws://127.0.0.1:49756/devtools/browser/6e19d9fe-4de6-40a3-b120-17067b3125ca
91 |
92 | DevTools listening on ws://127.0.0.1:49757/devtools/browser/ac12c2da-eeed-40d8-9b23-4d2103ec8fac
93 |
94 | bingtest » Bing Search (7.2s)
95 | googletest » Google Search for avajs (2.5s)
96 | googletest » Google Search for webdriver (3.3s)
97 |
98 | 3 tests passed
99 | ```
100 |
--------------------------------------------------------------------------------
/pl_PL/docs/recipes/vue.md:
--------------------------------------------------------------------------------
1 | # Testowanie komponentów Vue.js
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/vue.md)
4 |
5 | ## Zależności
6 |
7 | - [Require extension hooks](https://github.com/jackmellis/require-extension-hooks):
8 | - `npm i --save-dev require-extension-hooks require-extension-hooks-vue require-extension-hooks-babel@beta`
9 |
10 | - [jsdom-global](https://github.com/rstacruz/jsdom-global/blob/master/README.md)
11 | - `npm i --save-dev jsdom jsdom-global`
12 |
13 | - Opcjonalne: [babel-plugin-webpack-alias-7](https://github.com/shortminds/babel-plugin-webpack-alias-7) jeśli chcesz użyć [webpack aliases](https://webpack.js.org/configuration/resolve/#resolve-alias) lub użyć ich w swoich plikach źródłowych
14 | - `npm i --save-dev babel-plugin-webpack-alias-7`
15 |
16 | ## Ustawienie
17 |
18 | Pierwszym krokiem jest skonfigurowanie pomocnika do skonfigurowania środowiska do transponowania plików `.vue` i uruchomienia w środowisku przypominającym przeglądarkę.
19 |
20 | **`package.json`:**
21 |
22 | ```json
23 | {
24 | "ava": {
25 | "require": [
26 | "./test/_setup.js"
27 | ]
28 | }
29 | }
30 | ```
31 |
32 | ```js
33 | // ./test/_setup.js
34 |
35 | // Set up JSDom.
36 | require('jsdom-global')()
37 |
38 | // Fix the Date object, see .
39 | window.Date = Date
40 |
41 | // Setup browser environment
42 | const hooks = require('require-extension-hooks');
43 | const Vue = require('vue');
44 |
45 | // Setup Vue.js to remove production tip
46 | Vue.config.productionTip = false;
47 |
48 | // Setup vue files to be processed by `require-extension-hooks-vue`
49 | hooks('vue').plugin('vue').push();
50 | // Setup vue and js files to be processed by `require-extension-hooks-babel`
51 | hooks(['vue', 'js']).exclude(({filename}) => filename.match(/\/node_modules\//)).plugin('babel').push();
52 | ```
53 |
54 | **Uwaga:** Jeśli używasz _babel-plugin-webpack-alias-7_, musisz również wykluczyć swój plik webpack - np. `filename.includes(/\/node_modules\//) || filename.includes('webpack.config.test.js')`
55 |
56 | Więcej informacji na temat konfigurowania Babel z AVA znajdziesz w [`@ava/babel`](https://github.com/avajs/babel).
57 |
58 | ## Przykładowy test migawki
59 |
60 | ```js
61 | const test = require('ava');
62 | const Vue = require('vue');
63 | const Component = require('component.vue');
64 |
65 | test('renders', t => {
66 | const vm = new Vue(Component).$mount();
67 | const tree = {
68 | $el: vm.$el.outerHTML
69 | };
70 | t.snapshot(tree);
71 | });
72 | ```
73 |
74 | ## Raportowanie pokrycia
75 |
76 | Postępuj zgodnie z [przepisem raportowania zasięgu](code-coverage.md), dodatkowo dodając rozszerzenie `.vue` do `nyc` configa dla plików `.vue`.
77 |
78 | ```json
79 | {
80 | "nyc": {
81 | "extension": [
82 | ".js",
83 | ".vue"
84 | ]
85 | }
86 | }
87 | ```
88 |
--------------------------------------------------------------------------------
/pl_PL/docs/support-statement.md:
--------------------------------------------------------------------------------
1 | # Obsługiwane wersje Node.js
2 |
3 | Tłumaczenia: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/support-statement.md)
4 |
5 | AVA obsługuje najnowszą wersję dowolnej głównej wersji, która [jest obsługiwana przez sam Node.js](https://github.com/nodejs/Release#release-schedule).
6 |
7 | *Obsługiwanie* oznacza tutaj, że uruchamiamy nasz pakiet testowy w podanych wersjach Node.js i przyjmujemy pull request, aby naprawić wszelkie błędy (pod warunkiem, że nie są to znane błędy w samym Node.js, które zostaną natychmiast naprawione). w konsekwencji, *porzucenie wsparcia* oznacza, że usuniemy te wersje Node.js z naszej matrycy testowej i nie będziemy już akceptować określonych pull requestów w celu naprawy błędów w tych wersjach.
8 |
9 | Kiedy rezygnujemy z obsługi wersji głównej objętej LTS, podbijamy główny numer wersji AVA.
10 |
11 | Zrezygnujemy z obsługi wersji Node.js o nieparzystych numerach (np. `11` lub `13`) *bez* podbijania głównego numeru wersji AVA.
12 |
13 | Staramy się unikać *przypadkowego* porzucania obsługi nieaktualnych wersji Node.js. Jeśli takie uszkodzenie wystąpi, zaakceptujemy pull request w celu przywrócenia funkcjonalności. Możemy zdecydować się na wycofanie szkodliwej wersji AVA i zamiast tego podbić główny numer wersji AVA.
14 |
15 | Za każdym razem, gdy podbijamy główny numer wersji AVA, *robimy* jawne porzucenie obsługi najnowszych wersji Node.js. To gwarantuje, że możemy polegać na cofniętych interfejsach API lub dostępności nowszych wersji V8 w późniejszych wersjach Node.js, w samym AVA lub w jednej z naszych zależności.
16 |
17 | Możemy zrezygnować z obsługi wersji Node.js w wersji przedpremierowej wersji głównej, jeśli oczekuje się, że nowa wersja AVA ustabilizuje się w okolicach daty zakończenia wersji Node.js lub później pytanie.
18 |
19 | Eksperymentalne funkcje włączone w konfiguracji `nonSemVerExperiments` mogą zostać zmienione lub usunięte w dowolnym momencie.
20 |
--------------------------------------------------------------------------------
/pl_PL/maintaining.md:
--------------------------------------------------------------------------------
1 | # Utrzymanie
2 |
3 | ## Postępowanie
4 |
5 | **Bądź miły dla wszystkich.** Przeczytaj i przestrzegaj [Kodeksu postępowania](https://github.com/mbiesiad/ava-docs/blob/pl_PL/pl_PL/code-of-conduct.md).
6 |
7 | ## Testowanie
8 |
9 | * `npm test`: Podpowie kod i uruchomi cały pakiet testowy z pokryciem.
10 | * `npx tap --no-cov test/fork.js --bail`: Uruchomi konkretny plik testowy i bail przy pierwszym niepowodzeniu (przydatne podczas wyszukiwania błędów).
11 |
12 | ## CI
13 |
14 | * Testy czasami kończą się niepowodzeniem w systemie Windows. Dokładnie sprawdź błędy.
15 | * Co najmniej jedno zadanie systemu Windows musi przejść.
16 | * Wszystkie inne zadania muszą przejść.
17 |
18 | ## Aktualizowanie zależności
19 |
20 | * Upewnij się, że nowe wersje zależności są zgodne z naszymi obsługiwanymi wersjami Node.js.
21 | * Pozostaw zależność TypeScript bez zmian, aby uniknąć przypadkowego uszkodzenia.
22 | * Otwórz PR z aktualizacjami i merguj, gdy CI przejdzie (patrz poprzedni rozdział).
23 |
24 | ## Aktualizowanie TypeScript
25 |
26 | TypeScript sam nie obserwuje SemVer. W związku z tym może być konieczne wprowadzenie zmian w definicji typu, które z technicznego punktu widzenia niszczą zmiany dla użytkowników starszych wersji TypeScript. W porządku, ale powinniśmy być tego świadomi.
27 |
28 | Aktualizuj zależność TypeScript tylko wtedy, gdy jest to naprawdę konieczne. Pomaga to uniknąć przypadkowego uszkodzenia. Na przykład nie będziemy przypadkowo polegać na nowszych funkcjach TypeScript.
29 |
30 | Mówiąc o, używanie nowszych funkcji TypeScript można uznać za przełomową zmianę. Należy to oceniać indywidualnie dla każdego przypadku.
31 |
32 | ## Pull requests
33 |
34 | * Nowe featury powinny pochodzić z testów i dokumentacji.
35 | * Upewnij się, że [wytyczne współtworzenia](https://github.com/mbiesiad/ava-docs/blob/pl_PL/pl_PL/contributing.md) są odhaczone.
36 | * Squash commits gdy mergowanie.
37 |
38 | ## Eksperymenty
39 |
40 | * Najpierw zaimplementuj przełomowe zmiany, wymagające zgody.
41 | * Wcześniej dostarczaj nowe funkcje, traktując je jak eksperyment, wymagające zgody.
42 |
43 | ## Proces wydania
44 |
45 | * Zaktualizuj zależności (patrz poprzednia sekcja).
46 | * Jeśli [konieczny](docs/support-statement.md), zaktualizuj pole `engines` w `package.json`.
47 | * Usuń nieobsługiwane (lub wkrótce) wersje Node.js.
48 | * Wykonując główną wersję bump, upewnij się, że potrzebujesz najnowszej wersji każdej obsługiwanej wersji Node.js.
49 | * Opublikuj nową wersję za pomocą [`np`](https://github.com/sindresorhus/np) z numerem wersji zgodnie z [SemVer](http://semver.org).
50 | * Napisz [notatkę o wydaniu](https://github.com/avajs/ava/releases/new) zgodnie ze stylem poprzednich uwag do wydania.
51 |
--------------------------------------------------------------------------------
/pt_BR/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota do tradutor**
3 |
4 | Esta é a tradução de [code-of-conduct.md](https://github.com/avajs/ava/blob/main/.github/CODE_OF_CONDUCT.md). [Este link](https://github.com/avajs/ava/compare/d72723b9154f992b62b1e995bd7756cb93e7674c...master) compara a versão em que se baseou esta tradução com a última versão disponível no branch `master` do AVA. Se não houver mudanças em `code-of-conduct.md`, então a tradução está atualizada.
5 | ___
6 |
7 | # Código de Conduta do Contribuidor
8 |
9 | Traduções: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/code-of-conduct.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/code-of-conduct.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/code-of-conduct.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/code-of-conduct.md)
10 |
11 | Como contribuidores e mantenedores deste projeto, e no interesse da fomentar uma
12 | comunidade aberta e acolhedora, nós nos comprometemos a respeitar todas as
13 | pessoas que contribuirem, através do relato de problemas, solicitações de
14 | features, atualizações de documentação, submissão de pull requests ou patches, e
15 | outras atividades.
16 |
17 | Estamos empenhados em tornar a participação neste projecto uma experiência livre
18 | de assédio para todos, independentemente do nível de experiência, sexo,
19 | identidade ou expressão de gênero, orientação sexual, deficiência, aparência
20 | pessoal, tamanho corporal, raça, etnia, idade, religião ou nacionalidade.
21 |
22 | Exemplos de comportamento inaceitável pelos participantes incluem:
23 |
24 | * O uso de linguagem ou imagens sexualizadas
25 | * Ataques pessoais
26 | * Comentários insultantes ou depreciativos
27 | * Assédio público ou privado
28 | * Publicação de informações privadas de outros, tais como endereço físico ou eletrônico, sem permissão explícita
29 | * Outra conduta antiética ou antiprofissional
30 |
31 | Mantenedores do projeto têm o direito e a responsabilidade de remover, editar,
32 | ou rejeitar comentários, commits, código, edições de wiki, issues e outras
33 | contribuições que não estão alinhadas a este Código de Conduta, ou de banir
34 | temporária ou permanentemente qualquer colaborador por outros comportamentos que
35 | considerem inadequados, ameaçadores, ofensivos ou prejudiciais.
36 |
37 | Ao adotar este Código de Conduta, os mantenedores do projeto se comprometem a
38 | justa e consistentemente aplicar estes princípios em todos os aspectos do
39 | gerenciamento deste projecto. Mantenedores de projetos que não seguirem ou
40 | fizerem cumprir o Código de Conduta podem ser removidos permanentemente da
41 | equipe do projeto.
42 |
43 | Este Código de Conduta aplica-se tanto nos espaços do projeto, quanto em espaços
44 | públicos, quando um indivíduo representa o projeto ou a sua comunidade.
45 |
46 | Instâncias de comportamento abusivo, ofensivo ou de qualquer forma inaceitável
47 | podem ser relatadas entrando em contato com um mantenedor do projeto através do
48 | endereço sindresorhus@gmail.com. Todas as reclamações serão analisadas e
49 | investigadas e resultarão em uma resposta considerada necessária e adequada às
50 | circunstâncias. Os mantenedores são obrigados a manter a confidencialidade em
51 | relação ao relator de um incidente.
52 |
53 | Este Código de Conduta é uma adaptação de [Contributor Covenant][homepage],
54 | versão 1.3.0, disponível em
55 | [http://contributor-covenant.org/version/1/3/0/][versão]
56 |
57 | [homepage]: http://contributor-covenant.org
58 | [versão]: http://contributor-covenant.org/version/1/3/0/
59 |
--------------------------------------------------------------------------------
/pt_BR/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Nota do tradutor**
3 |
4 | Esta é a tradução de [endpoint-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md). [Este link](https://github.com/avajs/ava/compare/0e6db13a918f0116927299271d91fff590328cb9...master) compara a versão em que se baseou esta tradução com a última versão disponível no branch `master` do AVA. Se não houver mudanças em `endpoint-testing.md`, então a tradução está atualizada.
5 | ___
6 |
7 | # Teste de Endpoint
8 |
9 | Traduções: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/endpoint-testing.md), [Français](endpoint-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/recipes/endpoint-testing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/endpoint-testing.md)
10 |
11 | AVA não possui um método incorporado para testar endpoints, mas você pode usar qualquer biblioteca de asserção com ele. Vamos usar [`supertest-as-promised`](https://github.com/WhoopInc/supertest-as-promised).
12 |
13 | Uma vez que os testes são executados simultaneamente, é melhor criar uma nova instância de servidor para cada teste, porque se nós referenciarmos a mesma instância, poderia ser mutada entre os testes. Isso pode ser feito com um `test.beforeEach` e um `t.context`, ou simplesmente com uma função factory:
14 |
15 | ```js
16 | function makeApp() {
17 | const app = express();
18 | app.post('/signup', signupHandler);
19 | return app;
20 | }
21 | ```
22 |
23 | Em seguida, apenas injete sua instância de servidor em supertest. A única pegadinha é usar uma promessa ou sintaxe async/await em vez do método de supertest `end`:
24 |
25 | ```js
26 | test('signup:Success', async t => {
27 | t.plan(2);
28 |
29 | const res = await request(makeApp())
30 | .post('/signup')
31 | .send({email: 'ava@rocks.com', password: '123123'});
32 |
33 | t.is(res.status, 200);
34 | t.is(res.body.email, 'ava@rocks.com');
35 | });
36 | ```
37 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Localized [AVA](https://avajs.dev) docs
2 |
3 | - [Español](es_ES/readme.md) *(by [@AlbertoFuente](https://github.com/AlbertoFuente))*
4 | - [Français](fr_FR/readme.md) *(by [@forresst](https://github.com/forresst))*
5 | - [Italiano](it_IT/readme.md) *(by [@dej611](https://github.com/dej611))*
6 | - [日本語](ja_JP/readme.md) *(by [@makotot](https://github.com/makotot))*
7 | - [Português](pt_BR/readme.md) *(by [@charbelrami](https://github.com/charbelrami))*
8 | - [Русский](ru_RU/readme.md) *(by [@sohje](https://github.com/sohje))*
9 | - [简体中文](zh_CN/readme.md) *(by [@zhaozhiming](https://github.com/zhaozhiming))*
10 | - [한국어](ko_KR/readme.md) *(by [@preco21](https://github.com/preco21), [@jopemachine](https://github.com/jopemachine))*
11 | - [Polski](pl_PL/readme.md) *(by [@mbiesiad](https://github.com/mbiesiad))*
12 |
13 |
14 | ## Contribute
15 |
16 | We're happy to accept localizations for the AVA docs if you can commit to keeping it up to date. You'll be added to this repo and free to do any changes to your localization.
17 |
--------------------------------------------------------------------------------
/ru_RU/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Примечание от переводчика**
3 |
4 | Здесь содержится перевод файла [code-of-conduct.md](https://github.com/avajs/ava/blob/main/.github/CODE_OF_CONDUCT.md). Если при нажатии на [ссылку](https://github.com/avajs/ava/compare/4111f9483f2ff6a158b603735a712eee3ab074c4...main#diff-d3030a18b089fdb1fbfabf6e75e4aef0), содержащую последние правки в master ветке AVA, Вы не можете найти файл `code-of-conduct.md`, то можете считать что перевод актуален.
5 | ___
6 | # Кодекс Поведения участника
7 |
8 | Переводы: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/code-of-conduct.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/code-of-conduct.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/code-of-conduct.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/code-of-conduct.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/code-of-conduct.md)
9 |
10 | Как участники и сопровождающие этот проект, в интересах содействия
11 | открытому и дружелюбному сообществу, мы обязуемся уважать всех людей, которые
12 | вовлечены в процесс отчетности об ошибках, добавлении запросов о новом функционале,
13 | обновлении документации, в отправке изменений и патчей, а так же любую другую активность в проекте.
14 |
15 | Мы полны решимости сделать участие в этом проекте свободным от
16 | оскорблений для всех, независимо от уровня опыта, половой
17 | идентичности и самовыражения, сексуальной ориентации, инвалидности, внешности,
18 | размера тела, расы, национальности, возраста, религии или национальности.
19 |
20 | Примеры недопустимого поведения участников включают в себя:
21 |
22 | * Использование похабной речи или изображений
23 | * Личные оскорбления
24 | * Троллинг или оскорбительные/унижительные комментарии
25 | * Публичные или личные домогательства
26 | * Публикация частной информации, такой как физический или
27 | электронный адрес, без явного разрешения
28 | * Другое неэтичное или непрофессиональное поведение
29 |
30 | Сопровождающие проекта имеют право и обязанность удалять, изменять или
31 | отвергать комментарии, изменения, код, правки в wiki, проблемы и
32 | другие вклады в проект, если они противоречат настоящим условиям Кодекса Поведения,
33 | или запрещать временно или навсегда быть участником проекта людям, чье
34 | поведение является непростительным, угрожающим, оскорбительным или вредным.
35 |
36 | Принимая Кодекс Поведения, сопровождающие проект обязуются справедливо
37 | и постоянно применять эти принципы к каждому аспекту управления этим проектом.
38 | Те сопровождающие этот проект, кто не будет следовать или применять
39 | Кодекс Поведения могут быть удалены из команды проекта навсегда.
40 |
41 | Кодекс Поведения относится как к внутреннему пространству проекта, так и к
42 | публичным местам, когда человек представляет этот проект или сообщество.
43 |
44 | Примеры оскорбительного или неприемлимого поведения могут быть направлены
45 | руководителю проекта на электронный адрес sindresorhus@gmail.com. Все
46 | жалобы будут рассмотрены и изучены, на каждую жалобу будет целесообразный
47 | и необходимый ответ, в зависимости от обстоятельств. Сопровождающие проект
48 | обязаны сохранять конфиденциальность в отношении лица, направившего жалобу.
49 |
50 | Кодекс Поведения адаптирован с [Contributor Covenant][homepage],
51 | версия 1.3.0, доступна здесь
52 | [http://contributor-covenant.org/version/1/3/0/][version]
53 |
54 | [homepage]: http://contributor-covenant.org
55 | [version]: http://contributor-covenant.org/version/1/3/0/
56 |
--------------------------------------------------------------------------------
/ru_RU/docs/recipes/browser-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Примечание от переводчика**
3 |
4 | Здесь содержится перевод файла [browser-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/browser-testing.md). Если при нажатии на [ссылку](https://github.com/avajs/ava/compare/8e2f3dca177a4283ad882596d3c1425cabb998ef...main#diff-9d3d394077fa7f97cbbb0fefc098ac60), содержащую последние правки в master ветке AVA, Вы не можете найти файл `browser-testing.md`, то можете считать что перевод актуален.
5 | ___
6 | # Настройка AVA для тестирования браузера
7 |
8 | Переводы: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/browser-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/recipes/browser-testing.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/browser-testing.md)
9 |
10 | AVA не поддерживает запуск тестов в браузере, [пока что](https://github.com/avajs/ava/issues/24). Некоторым библиотекам необходимы браузерное глобальное окружение(`window`, `document`, `navigator`, и т.д.).
11 | Один из примеров - это React, по крайней мере, если Вы собираетесь использовать ReactDOM.render и эмулировать DOM события с ReactTestUtils.
12 |
13 | Этот пример работает с любыми библиотеками, которые моделируют браузерное окружение.
14 |
15 | ## Установка jsdom
16 |
17 | Установите [jsdom](https://github.com/tmpvar/jsdom).
18 |
19 | > JavaScript реализация WHATWG DOM и HTML стандартов, для использования с node.js
20 |
21 | ```
22 | $ npm install --save-dev jsdom
23 | ```
24 |
25 | ## Настройка jsdom
26 |
27 | Создайте вспомогательный файл и поместите его в каталог `test/helpers`. В этом случае, AVA не будет рассматривать файл в качестве теста.
28 |
29 | `test/helpers/setup-browser-env.js`:
30 |
31 | ```js
32 | global.document = require('jsdom').jsdom('');
33 | global.window = document.defaultView;
34 | global.navigator = window.navigator;
35 | ```
36 |
37 | ## Сконфигурируйте тесты с использованием jsdom
38 |
39 | Сконфигурируйте AVA `require` для подключения вспомогательного файла перед каждым тестовым файлом.
40 |
41 | `package.json`:
42 |
43 | ```json
44 | {
45 | "ava": {
46 | "require": [
47 | "./test/helpers/setup-browser-env.js"
48 | ]
49 | }
50 | }
51 | ```
52 |
53 | ## Наслаждайтесь!
54 |
55 | Напишите Ваши тесты и наслаждайтесь смоделируемым `window` объектом.
56 |
57 | `test/my.react.test.js`:
58 |
59 | ```js
60 | import test from 'ava';
61 | import React from 'react';
62 | import {render} from 'react-dom';
63 | import {Simulate} from 'react-addons-test-utils';
64 | import sinon from 'sinon';
65 | import CustomInput from './components/custom-input.jsx';
66 |
67 | test('Input calls onBlur', t => {
68 | const onUserBlur = sinon.spy();
69 | const input = render(
70 | React.createElement(CustomInput, onUserBlur),
71 | div
72 | );
73 |
74 | Simulate.blur(input);
75 |
76 | t.true(onUserBlur.calledOnce);
77 | });
78 | ```
79 |
--------------------------------------------------------------------------------
/ru_RU/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Примечание от переводчика**
3 |
4 | Здесь содержится перевод файла [endpoint-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md). Если при нажатии на [ссылку](https://github.com/avajs/ava/compare/4111f9483f2ff6a158b603735a712eee3ab074c4...main#diff-aee54ab6a703c02779edb3ebbb35e96f), содержащую последние правки в master ветке AVA, Вы не можете найти файл `endpoint-testing.md`, то можете считать что перевод актуален.
5 | ___
6 | # Тестирование HTTP серверов
7 |
8 | Переводы: [Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/endpoint-testing.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/endpoint-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/recipes/endpoint-testing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/endpoint-testing.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/docs/recipes/endpoint-testing.md)
9 |
10 | AVA не имеет встроенных средств для тестирования HTTP серверов, но Вы можете использовать любую библиотеку для этого. Воспользуемся [`supertest-as-promised`](https://github.com/WhoopInc/supertest-as-promised).
11 |
12 | Так как все тесты запускаются одновременно, то лучше всего создавать новый сервер для каждого теста, потому что сервер может изменить свое состояние между тестами. Сделайте это при помощи `test.beforeEach` и `t.context`, или же воспользуйтесь factory методом:
13 |
14 | ```js
15 | function makeApp() {
16 | const app = express();
17 | app.post('/signup', signupHandler);
18 | return app;
19 | }
20 | ```
21 |
22 | Далее, передайте объект сервера в supertest. Используйте Promises или async/await вместо метода `end` supertest'a:
23 |
24 | ```js
25 | test('signup:Success', async t => {
26 | t.plan(2);
27 |
28 | const res = await request(makeApp())
29 | .post('/signup')
30 | .send({email: 'ava@rocks.com', password: '123123'});
31 |
32 | t.is(res.status, 200);
33 | t.is(res.body.email, 'ava@rocks.com');
34 | });
35 | ```
36 |
--------------------------------------------------------------------------------
/ru_RU/docs/recipes/typescript.md:
--------------------------------------------------------------------------------
1 | ___
2 | **Примечание от переводчика**
3 |
4 | Здесь содержится перевод файла [typescript.md](https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md). Если при нажатии на [ссылку](https://github.com/avajs/ava/compare/8e2f3dca177a4283ad882596d3c1425cabb998ef...main#diff-60cce07a584082115d230f2e3d571ad6), содержащую последние правки в master ветке AVA, Вы не можете найти файл `typescript.md`, то можете считать что перевод актуален.
5 | ___
6 | # TypeScript
7 |
8 | Переводы: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/typescript.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/recipes/typescript.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/typescript.md)
9 |
10 | В AVA включена поддержка TypeScript файлов. Это позволяет разработчикам использовать TypeScript для написания тестов.
11 |
12 | ## Установка
13 |
14 | Установите TypeScript компилятор [tsc](https://github.com/Microsoft/TypeScript).
15 |
16 | ```
17 | $ npm install --save-dev tsc
18 | ```
19 |
20 | Создайте [`tsconfig.json`](https://github.com/Microsoft/TypeScript/wiki/tsconfig.json) файл. Этот файл определяет параметры компилятора, необходимые для компиляции проекта или тестового файла.
21 |
22 | ```json
23 | {
24 | "compilerOptions": {
25 | "module": "commonjs",
26 | "target": "es2015"
27 | }
28 | }
29 | ```
30 |
31 | Добавьте `test` скрипт в Ваш `package.json` файл. Сперва будет скомпилирован проект и после будет произведет запуск AVA.
32 |
33 | ```json
34 | {
35 | "scripts": {
36 | "test": "tsc && ava"
37 | }
38 | }
39 | ```
40 |
41 |
42 | ## Добавьте тесты
43 |
44 | Создайте `test.ts` файл.
45 |
46 | ```ts
47 | import test from 'ava';
48 |
49 | async function fn() {
50 | return Promise.resolve('foo');
51 | }
52 |
53 | test(async (t) => {
54 | t.is(await fn(), 'foo');
55 | });
56 | ```
57 |
58 |
59 | ## Выполните тесты
60 |
61 | ```
62 | $ npm test
63 | ```
64 |
--------------------------------------------------------------------------------
/zh_CN/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | ___
2 | **备注**
3 |
4 | 这是 [code-of-coduct.md](https://github.com/avajs/ava/raw/main/code-of-coduct.md) 的简体中文翻译。这个[链接](https://github.com/avajs/ava/compare/89767ec3b6174e59d37faaadb50cfa3c0d58bda6...main#diff-d3030a18b089fdb1fbfabf6e75e4aef0) 用来查看本翻译与 AVA 的 master 分支是否有差别(如果你没有看到`code-of-coduct.md`发生变化,那就意味着这份翻译文档是最新的)。
5 | ___
6 |
7 | # 贡献者的行为准则
8 |
9 | 翻译:[Español](https://github.com/avajs/ava-docs/blob/main/es_ES/code-of-conduct.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/code-of-conduct.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/code-of-conduct.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/code-of-conduct.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/code-of-conduct.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/code-of-conduct.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/code-of-conduct.md)
10 |
11 | 作为这个项目的贡献者和维护者,我们希望社区开放和受欢迎,我们承诺尊重所有参与项目的人,不管是报告问题,提交功能需求,更新文档,提交 pull request 或 patch,或者是其他积极的活动。
12 |
13 | 我们致力于让每个参与项目的人享受相同的体验,不管经验水平,性别,性别身份和表达,性取向,残疾,个人形象,身体大小,种族,种族渊源,年龄,宗教信仰或者国籍。
14 |
15 | 参与者不被接收的行为有如下例子:
16 |
17 | * 色情内容或图片
18 | * 个人攻击
19 | * 恶意攻击或者侮辱、贬低他人的言论
20 | * 公开或者私下骚扰
21 | * 公布他人私人信息,包括现实和网络的信息
22 | * 没有得到明确许可进行的演讲
23 | * 其他不道德和不专业的行为
24 |
25 | 项目维护者有如下权利和义务,包括删除,编辑或者拒绝评论,提交,代码,wiki 编辑,问题和其他贡献者没有遵守行为准则的行为等操作,可以临时或永久的禁止任何贡献者,如果认为贡献者不合适,威胁他人,无礼或者有害的,会进行临时或者永久禁止的处理。
26 |
27 | 通过采用这份行为准则,项目维护者承诺在项目管理的方方面面上公平和坚持地贯彻这些原则。如果有维护者没有遵守或执行行为准则,他可能就会在项目团队中被永久除名。
28 |
29 |
30 | 当个人代表项目或者社区的时候,这份行为准则适用于项目空间和公共空间。
31 |
32 | 举报辱骂,骚扰或者其他不被接受的行为可以通过 sindresorhus@gmail.com 联系项目维护人员。所有的投诉都会被审计和调查,最终会产生一个认为必要和合理的结果。维护人员有义务为报告者保密其信息。
33 |
34 | 这份行为准则改编自[贡献者契约][homepage],版本 1.3.0,可在 [http://contributor-covenant.org/version/1/3/0/][version] 获取。
35 |
36 | [homepage]: http://contributor-covenant.org
37 | [version]: http://contributor-covenant.org/version/1/3/0/
38 |
--------------------------------------------------------------------------------
/zh_CN/contributing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **备注**
3 |
4 | 这是 [contributing.md](https://github.com/avajs/ava/blob/main/.github/CONTRIBUTING.md) 的简体中文翻译。这个[链接](https://github.com/avajs/ava/compare/89767ec3b6174e59d37faaadb50cfa3c0d58bda6...main#diff-cc4aac3e9be04e0413c9520f223b493c) 用来查看本翻译与 AVA 的 master 分支是否有差别(如果你没有看到`contributing.md`发生变化,那就意味着这份翻译文档是最新的)。
5 | ___
6 | # 向 AVA 贡献
7 |
8 | ✨ 感谢向 AVA 作出贡献! ✨
9 |
10 | 请注意,这个项目发布带有[贡献者的行为准则](code-of-conduct.md),参与这个项目你需要同意并遵守其中的条款。
11 |
12 | 翻译:[Español](https://github.com/avajs/ava-docs/blob/main/es_ES/contributing.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/contributing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/contributing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/contributing.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/contributing.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/contributing.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/contributing.md)
13 |
14 | ## 我怎么贡献?
15 |
16 | ### 改进文档
17 |
18 | 作为 AVA 的用户你是帮助我们改进文档的最佳候选人,修改拼写错误,修复错误,更好的解释,更多的例子等等。为一些可以改进的事情提问题,[帮助我们翻译文档](https://github.com/avajs/ava-docs),不管任何事情,即使是改善现在这个文档。
19 |
20 | ### 改善问题
21 |
22 | 一些问题在创建时缺少信息,不能重现,描述太过简单无效,帮助我们将他们变得更容易处理,因为处理问题需要大量时间,我们情愿将时间花在修复缺陷和添加新功能上面。
23 |
24 | ### 在问题中给出反馈
25 |
26 | 我们总是在问题跟踪器上寻找更多的讨论意见,这是一个影响 AVA 未来发展方向的好机会。
27 |
28 | ### 在我们的聊天室中闲聊
29 |
30 | 我们有一个[聊天室](https://gitter.im/avajs/ava),可以进到里面潜水,跟我们聊天,或者帮助其他人。
31 |
32 | ### 提交问题
33 |
34 | - 问题跟踪器是针对问题的,请使用我们的[聊天室](https://gitter.im/avajs/ava) 或者 [Stack Overflow](https://stackoverflow.com/questions/tagged/ava) 来寻求支持。
35 | - 在新开一个问题之前先搜索以前的问题。
36 | - 确保你使用的是最新版本的 AVA。
37 | - 用一个清晰和描述性好的标题。
38 | - 包含尽可能多的信息:重现问题的步骤,错误的信息,Node.js 的版本,操作系统等。
39 | - 在问题的描述上你花越多时间,越多的信息将给到我们。
40 | - [最好的问题提交方式是提供一个失败的测试案例。](https://twitter.com/sindresorhus/status/579306280495357953)
41 |
42 | ### 提交一个 pull rquest
43 |
44 | - 重大的修改最好是先开一个问题来进行讨论,这样可以避免你做一些不必要的工作。
45 | - 对于长期远大的任务,你应该将你所做的工作在社区中提出来并尽快得到反馈,尽快开一个能证明你想法的最简版本的 pull request。在前期,不需要把事情做得完美,或者 100% 完成,只需要在标题添加一个 [WIP] 前缀,然后描述哪些工作你需要继续做的。这样评审人员就不会挑剔其中的小细节或者指出哪些你已经知道的改进点。
46 | - 新功能应该具备测试和文档。
47 | - 不要包含不相关的修改。
48 | - 在提交 pull request 之前检查代码和运行测试,通过执行`$ npm test`命令来完成。
49 | - 在一个[主题分支](https://github.com/dchelimsky/rspec/wiki/Topic-Branches) 中提交 pull request 而不是 master 分支。
50 | - 为 pull request 和 commit 使用一个清晰和描述性强的标题。
51 | - 写一个让人信服的描述来说明为什么我们要接受你的 pull request。说服我们是你的工作,需要回答“为什么”并提供用例。
52 | - 你可能被要求修改你的 pull request,但绝对没有必要去新开一个 pull request,[只需要更新原来那个就可以了。](https://github.com/RichardLitt/knowledge/blob/master/github/amending-a-commit-guide.md)
53 |
--------------------------------------------------------------------------------
/zh_CN/docs/recipes/browser-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **备注**
3 |
4 | 这是 [browser-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/browser-testing.md) 的简体中文翻译。这个[链接](https://github.com/avajs/ava/compare/8e2f3dca177a4283ad882596d3c1425cabb998ef...main#diff-9d3d394077fa7f97cbbb0fefc098ac60) 用来查看本翻译与 AVA 的 master 分支是否有差别(如果你没有看到`browser-testing.md`发生变化,那就意味着这份翻译文档是最新的)。
5 | ___
6 |
7 | # 设置 AVA 做浏览器测试
8 |
9 | 翻译:[Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/browser-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/browser-testing.md) [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/browser-testing.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/browser-testing.md)
10 |
11 |
12 |
13 | AVA [还](https://github.com/avajs/ava/issues/24)不支持在浏览器中运行测试。一些库需要浏览器提供的全局变量(`window`, `document`, `navigator`等等)。
14 | React 就是其中的一个例子,至少当你想用 ReactDOM.render 和用 ReactTestUTils 模拟事件。
15 |
16 | 这个秘方让需要模拟浏览器环境的库可以工作。
17 |
18 | ## 安装 browser-env
19 |
20 | > **❗️ 重点提示**
21 | >
22 | >`browser-env` 将 `jsdom` 里浏览器环境上的属性添加到 Node.js 的全局环境。这是明确的[违背了](https://github.com/tmpvar/jsdom/wiki/Don't-stuff-jsdom-globals-onto-the-Node-global) `jsdom` 的推荐行为。请读完链接里的 wiki 页面并确保你明白了其中的注意事项。如果你只是需要一个并不包涵太多依赖的浏览器环境,那也许 [`window`](https://github.com/lukechilds/window#universal-testing-pattern) 是个更好的解决方案。
23 |
24 | 安装 [browser-env](https://github.com/lukechilds/browser-env)。
25 |
26 | > 使用 jsdom 模拟一个全局的浏览器环境。
27 |
28 | ```
29 | $ npm install --save-dev browser-env
30 | ```
31 |
32 | ## 设置 browser-env
33 |
34 | 在 `test/helpers` 目录中创建一个 helper 文件。这样确保 AVA 不会把它当成测试来处理。
35 |
36 | `test/helpers/setup-browser-env.js`:
37 |
38 | ```js
39 | import browserEnv from 'browser-env';
40 | browserEnv();
41 | ```
42 |
43 | ## 配置测试使用 browser-env
44 |
45 | 配置 AVA,通过 `require` 那个 helper 文件使得每个测试运行前都加载它。
46 |
47 | `package.json`:
48 |
49 | ```json
50 | {
51 | "ava": {
52 | "require": [
53 | "./test/helpers/setup-browser-env.js"
54 | ]
55 | }
56 | }
57 | ```
58 |
59 | ## 享受!
60 |
61 | 编写你的测试并享受一个模拟的 window 对象吧。
62 |
63 | `test/my.dom.test.js`:
64 |
65 | ```js
66 | import test from 'ava';
67 |
68 | test('Insert to DOM', t => {
69 | const div = document.createElement('div');
70 | document.body.appendChild(div);
71 |
72 | t.is(document.querySelector('div'), div);
73 | });
74 | ```
75 |
76 | `test/my.react.test.js`:
77 |
78 | ```js
79 | import test from 'ava';
80 | import React from 'react';
81 | import {render} from 'react-dom';
82 | import {Simulate} from 'react-addons-test-utils';
83 | import sinon from 'sinon';
84 | import CustomInput from './components/custom-input.jsx';
85 |
86 | test('Input calls onBlur', t => {
87 | const onUserBlur = sinon.spy();
88 | const input = render(
89 | React.createElement(CustomInput, onUserBlur),
90 | div
91 | );
92 |
93 | Simulate.blur(input);
94 |
95 | t.true(onUserBlur.calledOnce);
96 | });
97 | ```
98 |
--------------------------------------------------------------------------------
/zh_CN/docs/recipes/endpoint-testing.md:
--------------------------------------------------------------------------------
1 | ___
2 | **备注**
3 |
4 | 这是 [endpoint-testing.md](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md) 的简体中文翻译。这个[链接](https://github.com/avajs/ava/compare/89767ec3b6174e59d37faaadb50cfa3c0d58bda6...main#diff-aee54ab6a703c02779edb3ebbb35e96f) 用来查看本翻译与 AVA 的 master 分支是否有差别(如果你没有看到`endpoint-testing.md`发生变化,那就意味着这份翻译文档是最新的)。
5 | ___
6 |
7 | # 端点测试
8 |
9 | 翻译:[Español](https://github.com/avajs/ava-docs/blob/main/es_ES/docs/recipes/endpoint-testing.md), [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/endpoint-testing.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/endpoint-testing.md), [日本語](https://github.com/avajs/ava-docs/blob/main/ja_JP/docs/recipes/endpoint-testing.md), [Português](https://github.com/avajs/ava-docs/blob/main/pt_BR/docs/recipes/endpoint-testing.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/endpoint-testing.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/endpoint-testing.md)
10 |
11 | AVA 没有内嵌的方法可以来做端点测试,但你可以用其他断言库来做,让我们用 [`supertest-as-promised`](https://github.com/WhoopInc/supertest-as-promised) 来看看。
12 |
13 | 因为测试是并发执行的,所以最好是为每个测试建立一个新的服务器实例,如果所有测试都引用同一个实例,那实例可能会被不同的测试改变状态。这可以在`test.beforeEach`和`t.context`里完成,或者简单的工厂方法:
14 |
15 | ```js
16 | function makeApp() {
17 | const app = express();
18 | app.post('/signup', signupHandler);
19 | return app;
20 | }
21 | ```
22 |
23 | 然后,将你的服务器注入到测试超类中,主要的点是用 promise 或 async/await 语法来代替测试超类的`end`方法:
24 |
25 | ```js
26 | test('signup:Success', async t => {
27 | t.plan(2);
28 |
29 | const res = await request(makeApp())
30 | .post('/signup')
31 | .send({email: 'ava@rocks.com', password: '123123'});
32 |
33 | t.is(res.status, 200);
34 | t.is(res.body.email, 'ava@rocks.com');
35 | });
36 | ```
37 |
--------------------------------------------------------------------------------
/zh_CN/docs/recipes/typescript.md:
--------------------------------------------------------------------------------
1 | ___
2 | **备注**
3 |
4 | 这是 [typescript.md](https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md) 的简体中文翻译。这个[链接](https://github.com/avajs/ava/compare/8e2f3dca177a4283ad882596d3c1425cabb998ef...main#diff-60cce07a584082115d230f2e3d571ad6) 用来查看本翻译与 AVA 的 master 分支是否有差别(如果你没有看到`typescript.md`发生变化,那就意味着这份翻译文档是最新的)。
5 | ___
6 |
7 | # TypeScript
8 |
9 | 翻译:[Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/typescript.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/typescript.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/typescript.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/typescript.md)
10 |
11 | AVA 捆绑了一个 TypeScript 定义文件,让开发人员可以了解如何用 TypeScript 写测试。
12 |
13 | ## 设置
14 |
15 | 首先安装 TypeScript 编译器 [tsc](https://github.com/Microsoft/TypeScript)。
16 |
17 | ```
18 | $ npm install --save-dev tsc
19 | ```
20 |
21 | 创建一个 [`tsconfig.json`](https://github.com/Microsoft/TypeScript/wiki/tsconfig.json) 文件,文件指定编译器是用来编译工程或者测试文件。
22 |
23 | ```json
24 | {
25 | "compilerOptions": {
26 | "module": "commonjs",
27 | "target": "es2015"
28 | }
29 | }
30 | ```
31 |
32 | 在`package.json`文件里添加一个`test`脚本,在运行 AVA 前先编译工程。
33 |
34 | ```json
35 | {
36 | "scripts": {
37 | "test": "tsc && ava"
38 | }
39 | }
40 | ```
41 |
42 |
43 | ## 添加测试
44 |
45 | 创建一个`test.ts`文件。
46 |
47 | ```ts
48 | import test from 'ava';
49 |
50 | async function fn() {
51 | return Promise.resolve('foo');
52 | }
53 |
54 | test(async (t) => {
55 | t.is(await fn(), 'foo');
56 | });
57 | ```
58 |
59 |
60 | ## 执行测试
61 |
62 | ```
63 | $ npm test
64 | ```
65 |
--------------------------------------------------------------------------------
/zh_CN/docs/recipes/watch-mode.md:
--------------------------------------------------------------------------------
1 | ___
2 | **备注**
3 |
4 | 这是 [watch-mode.md](https://github.com/avajs/ava/blob/main/docs/recipes/watch-mode.md) 的简体中文翻译。这个[链接](https://github.com/avajs/ava/compare/82c02bce80696547db0387dec243ddb470c8bce7...main#diff-92da4f3d087d796fdf4a45be88586b62) 用来查看本翻译与 AVA 的 master 分支是否有差别(如果你没有看到`watch-mode.md`发生变化,那就意味着这份翻译文档是最新的)。
5 | ___
6 |
7 | # 观察模式
8 |
9 | 翻译:[Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/watch-mode.md), [Italiano](https://github.com/avajs/ava-docs/blob/main/it_IT/docs/recipes/watch-mode.md), [Русский](https://github.com/avajs/ava-docs/blob/main/ru_RU/docs/recipes/watch-mode.md), [简体中文](https://github.com/avajs/ava-docs/blob/main/zh_CN/docs/recipes/watch-mode.md)
10 |
11 |
12 | AVA 自带了一个聪明的观察模式,它会观察那些改变了的文件并运行受到改变影响的测试。
13 |
14 | ## 运行测试时启用观察模式
15 |
16 | 你可以通过使用`--watch`或`-w`标志来启用观察模式,如果你是全局安装的 AVA:
17 |
18 | ```console
19 | $ ava --watch
20 | ```
21 |
22 | 如果你将 AVA 配置在`package.json`中,像这样:
23 |
24 | ```json
25 | {
26 | "scripts": {
27 | "test": "ava"
28 | }
29 | }
30 | ```
31 |
32 | 你可以这样运行:
33 |
34 | ```console
35 | $ npm test -- --watch
36 | ```
37 |
38 | 你可以设置一个特殊的脚本:
39 |
40 | ```json
41 | {
42 | "scripts": {
43 | "test": "ava",
44 | "test:watch": "ava --watch"
45 | }
46 | }
47 | ```
48 |
49 | 然后使用:
50 |
51 | ```console
52 | $ npm run test:watch
53 | ```
54 |
55 | ## 要求
56 |
57 | AVA 使用 [`chokidar`] 来作为文件观察器,它被配置为可选的依赖库,因为`chokidar`有时候无法安装,如果`chokidar`安装失败那么观察模式就不可用,然后你将看到一条这样的信息:
58 |
59 | > The optional dependency chokidar failed to install and is required for --watch. Chokidar is likely not supported on your platform.
60 |
61 | 请参考 [`chokidar`文档][`chokidar`] 了解如何解决这个问题。
62 |
63 | ## 源文件和测试文件
64 |
65 | 在 AVA 中*源文件*和*测试文件*是有差别的,正如你所想的一样,*测试文件*包含了你的测试,*源文件*是需要支持测试运行的其他所有文件,是你的源代码或者测试数据。
66 |
67 | 默认情况下 AVA 观察测试文件,`package.json`和其他的`.js`文件的改变,它会忽略由 [`ignore-by-default`] 包提供的[特定文件夹](https://github.com/novemberborn/ignore-by-default/blob/master/index.js) 下的文件。
68 |
69 | 你可以使用 [`--source` CLI 标志]或`package.json`文件的`ava`属性为源文件配置模式,注意如果你从 [`ignore-by-default`] 中指定了一个负模式目录,那么忽略将不再有效,所以你可能想要在你的配置里重复这些操作。
70 |
71 | 如果你的测试会写入磁盘,那么它们会跟踪观察器来返回你的测试,这种情况下你需要使用`--source`标志。
72 |
73 | ## 依赖跟踪
74 |
75 | AVA 跟踪测试文件依赖的源文件,如果你改变的源文件只有一个测试被依赖,那么就只会返回这个测试,如果它不能识别哪个测试文件依赖了这个被修改的源文件,那么它会返回所有的测试。
76 |
77 | 依赖跟踪在 required 模式中有效,支持自定义继承和转换,使用 [`--require` CLI 标志]而不是从你的测试文件来帮助你加载它们。使用`fs`模块来访问的文件不会被跟踪。
78 |
79 | ## 手动返回所有测试
80 |
81 | 你可以在 console 中,通过在Enter后面打印r来快速返回所有测试,
82 |
83 | ## 调试
84 |
85 | 有时候观察模式会出现一些意想不到的事情,比如当你只运行一个测试时会返回所有测试,为了调查原因你可以启用调试模式:
86 |
87 | ```console
88 | $ DEBUG=ava:watcher npm test -- --watch
89 | ```
90 |
91 | 在 Windows 里这样用:
92 |
93 | ```console
94 | $ set DEBUG=ava:watcher
95 | $ npm test -- --watch
96 | ```
97 |
98 | ## 帮助我们改善观察模式
99 |
100 | 观察模式比较新并且现在处于初期阶段,请 [报告](https://github.com/avajs/ava/issues) 任何你遇到问题,谢谢!
101 |
102 | [`chokidar`]: https://github.com/paulmillr/chokidar
103 | [`ignore-by-default`]: https://github.com/novemberborn/ignore-by-default
104 | [`--require` CLI 标志]: https://github.com/avajs/ava-docs/blob/main/zh_CN/readme.md#cli
105 | [`--source` CLI 标志]: https://github.com/avajs/ava-docs/blob/main/zh_CN/readme.md#cli
106 |
--------------------------------------------------------------------------------