Skip to content

Commit 9605917

Browse files
ricardochlSplaktar
authored andcommitted
translate: translations for testing guides
Fixes #54
1 parent b7be8ab commit 9605917

29 files changed

+3142
-924
lines changed

adev-es/src/app/routing/sub-navigation-data.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -510,51 +510,51 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
510510
],
511511
},
512512
{
513-
label: 'Testing',
513+
label: 'Pruebas',
514514
children: [
515515
{
516-
label: 'Overview',
516+
label: 'Visión general',
517517
path: 'guide/testing',
518518
contentPath: 'guide/testing/overview',
519519
},
520520
{
521-
label: 'Code coverage',
521+
label: 'Cobertura de código',
522522
path: 'guide/testing/code-coverage',
523523
contentPath: 'guide/testing/code-coverage',
524524
},
525525
{
526-
label: 'Testing services',
526+
label: 'Pruebas de servicios',
527527
path: 'guide/testing/services',
528528
contentPath: 'guide/testing/services',
529529
},
530530
{
531-
label: 'Basics of testing components',
531+
label: 'Fundamentos de pruebas de componentes',
532532
path: 'guide/testing/components-basics',
533533
contentPath: 'guide/testing/components-basics',
534534
},
535535
{
536-
label: 'Component testing scenarios',
536+
label: 'Escenarios de pruebas de componentes',
537537
path: 'guide/testing/components-scenarios',
538538
contentPath: 'guide/testing/components-scenarios',
539539
},
540540
{
541-
label: 'Testing attribute directives',
541+
label: 'Pruebas de directivas de atributo',
542542
path: 'guide/testing/attribute-directives',
543543
contentPath: 'guide/testing/attribute-directives',
544544
},
545545
{
546-
label: 'Testing pipes',
546+
label: 'Pruebas de pipes',
547547
path: 'guide/testing/pipes',
548548
contentPath: 'guide/testing/pipes',
549549
},
550550
{
551-
label: 'Testing routing and navigation',
551+
label: 'Pruebas de enrutamiento y navegación',
552552
path: 'guide/routing/testing',
553553
contentPath: 'guide/routing/testing',
554554
status: 'new',
555555
},
556556
{
557-
label: 'Debugging tests',
557+
label: 'Depuración de pruebas',
558558
path: 'guide/testing/debugging',
559559
contentPath: 'guide/testing/debugging',
560560
},
@@ -564,27 +564,27 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
564564
contentPath: 'guide/testing/utility-apis',
565565
},
566566
{
567-
label: 'Experimental unit testing integration',
567+
label: 'Integración experimental de pruebas unitarias',
568568
path: 'guide/testing/unit-tests',
569569
contentPath: 'guide/testing/experimental-unit-test',
570570
},
571571
{
572-
label: 'Component harnesses overview',
572+
label: 'Visión general de component harnesses',
573573
path: 'guide/testing/component-harnesses-overview',
574574
contentPath: 'guide/testing/component-harnesses-overview',
575575
},
576576
{
577-
label: 'Using component harnesses in tests',
577+
label: 'Usando component harnesses en pruebas',
578578
path: 'guide/testing/using-component-harnesses',
579579
contentPath: 'guide/testing/using-component-harnesses',
580580
},
581581
{
582-
label: 'Creating harnesses for your components',
582+
label: 'Creando harnesses para tus componentes',
583583
path: 'guide/testing/creating-component-harnesses',
584584
contentPath: 'guide/testing/creating-component-harnesses',
585585
},
586586
{
587-
label: 'Adding harness support for additional testing environments',
587+
label: 'Agregar soporte de harness para entornos de pruebas adicionales',
588588
path: 'guide/testing/component-harnesses-testing-environments',
589589
contentPath: 'guide/testing/component-harnesses-testing-environments',
590590
},
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
# Testing Attribute Directives
3+
4+
An *attribute directive* modifies the behavior of an element, component or another directive.
5+
Its name reflects the way the directive is applied: as an attribute on a host element.
6+
7+
## Testing the `HighlightDirective`
8+
9+
The sample application's `HighlightDirective` sets the background color of an element based on either a data bound color or a default color \(lightgray\).
10+
It also sets a custom property of the element \(`customProperty`\) to `true` for no reason other than to show that it can.
11+
12+
<docs-code header="app/shared/highlight.directive.ts" path="adev/src/content/examples/testing/src/app/shared/highlight.directive.ts"/>
13+
14+
It's used throughout the application, perhaps most simply in the `AboutComponent`:
15+
16+
<docs-code header="app/about/about.component.ts" path="adev/src/content/examples/testing/src/app/about/about.component.ts"/>
17+
18+
Testing the specific use of the `HighlightDirective` within the `AboutComponent` requires only the techniques explored in the ["Nested component tests"](guide/testing/components-scenarios#nested-component-tests) section of [Component testing scenarios](guide/testing/components-scenarios).
19+
20+
<docs-code header="app/about/about.component.spec.ts" path="adev/src/content/examples/testing/src/app/about/about.component.spec.ts" visibleRegion="tests"/>
21+
22+
However, testing a single use case is unlikely to explore the full range of a directive's capabilities.
23+
Finding and testing all components that use the directive is tedious, brittle, and almost as unlikely to afford full coverage.
24+
25+
*Class-only tests* might be helpful, but attribute directives like this one tend to manipulate the DOM.
26+
Isolated unit tests don't touch the DOM and, therefore, do not inspire confidence in the directive's efficacy.
27+
28+
A better solution is to create an artificial test component that demonstrates all ways to apply the directive.
29+
30+
<docs-code header="app/shared/highlight.directive.spec.ts (TestComponent)" path="adev/src/content/examples/testing/src/app/shared/highlight.directive.spec.ts" visibleRegion="test-component"/>
31+
32+
<img alt="HighlightDirective spec in action" src="assets/images/guide/testing/highlight-directive-spec.png">
33+
34+
HELPFUL: The `<input>` case binds the `HighlightDirective` to the name of a color value in the input box.
35+
The initial value is the word "cyan" which should be the background color of the input box.
36+
37+
Here are some tests of this component:
38+
39+
<docs-code header="app/shared/highlight.directive.spec.ts (selected tests)" path="adev/src/content/examples/testing/src/app/shared/highlight.directive.spec.ts" visibleRegion="selected-tests"/>
40+
41+
A few techniques are noteworthy:
42+
43+
* The `By.directive` predicate is a great way to get the elements that have this directive *when their element types are unknown*
44+
* The [`:not` pseudo-class](https://developer.mozilla.org/docs/Web/CSS/:not) in `By.css('h2:not([highlight])')` helps find `<h2>` elements that *do not* have the directive.
45+
`By.css('*:not([highlight])')` finds *any* element that does not have the directive.
46+
47+
* `DebugElement.styles` affords access to element styles even in the absence of a real browser, thanks to the `DebugElement` abstraction.
48+
But feel free to exploit the `nativeElement` when that seems easier or more clear than the abstraction.
49+
50+
* Angular adds a directive to the injector of the element to which it is applied.
51+
The test for the default color uses the injector of the second `<h2>` to get its `HighlightDirective` instance and its `defaultColor`.
52+
53+
* `DebugElement.properties` affords access to the artificial custom property that is set by the directive
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11

2-
# Testing Attribute Directives
2+
# Probar directivas de atributo
33

4-
An *attribute directive* modifies the behavior of an element, component or another directive.
5-
Its name reflects the way the directive is applied: as an attribute on a host element.
4+
Una *directiva de atributo* modifica el comportamiento de un elemento, componente u otra directiva.
5+
Su nombre refleja la forma en que se aplica la directiva: como un atributo en un elemento host.
66

7-
## Testing the `HighlightDirective`
7+
## Probar la `HighlightDirective`
88

9-
The sample application's `HighlightDirective` sets the background color of an element based on either a data bound color or a default color \(lightgray\).
10-
It also sets a custom property of the element \(`customProperty`\) to `true` for no reason other than to show that it can.
9+
La `HighlightDirective` de la aplicación de muestra establece el color de fondo de un elemento basado en un color vinculado a datos o un color predeterminado \(lightgray\).
10+
También establece una propiedad personalizada del elemento \(`customProperty`\) a `true` sin otra razón que mostrar que puede hacerlo.
1111

1212
<docs-code header="app/shared/highlight.directive.ts" path="adev/src/content/examples/testing/src/app/shared/highlight.directive.ts"/>
1313

14-
It's used throughout the application, perhaps most simply in the `AboutComponent`:
14+
Se usa en toda la aplicación, quizás más simplemente en el `AboutComponent`:
1515

1616
<docs-code header="app/about/about.component.ts" path="adev/src/content/examples/testing/src/app/about/about.component.ts"/>
1717

18-
Testing the specific use of the `HighlightDirective` within the `AboutComponent` requires only the techniques explored in the ["Nested component tests"](guide/testing/components-scenarios#nested-component-tests) section of [Component testing scenarios](guide/testing/components-scenarios).
18+
Probar el uso específico de la `HighlightDirective` dentro del `AboutComponent` requiere solo las técnicas exploradas en la sección ["Pruebas de componentes anidados"](guide/testing/components-scenarios#nested-component-tests) de [Escenarios de prueba de componentes](guide/testing/components-scenarios).
1919

2020
<docs-code header="app/about/about.component.spec.ts" path="adev/src/content/examples/testing/src/app/about/about.component.spec.ts" visibleRegion="tests"/>
2121

22-
However, testing a single use case is unlikely to explore the full range of a directive's capabilities.
23-
Finding and testing all components that use the directive is tedious, brittle, and almost as unlikely to afford full coverage.
22+
Sin embargo, probar un solo caso de uso es poco probable que explore el rango completo de las capacidades de una directiva.
23+
Encontrar y probar todos los componentes que usan la directiva es tedioso, frágil y casi tan poco probable de ofrecer cobertura completa.
2424

25-
*Class-only tests* might be helpful, but attribute directives like this one tend to manipulate the DOM.
26-
Isolated unit tests don't touch the DOM and, therefore, do not inspire confidence in the directive's efficacy.
25+
Las *pruebas solo de clase* podrían ser útiles, pero las directivas de atributo como esta tienden a manipular el DOM.
26+
Las pruebas unitarias aisladas no tocan el DOM y, por lo tanto, no inspiran confianza en la eficacia de la directiva.
2727

28-
A better solution is to create an artificial test component that demonstrates all ways to apply the directive.
28+
Una mejor solución es crear un componente de prueba artificial que demuestre todas las formas de aplicar la directiva.
2929

3030
<docs-code header="app/shared/highlight.directive.spec.ts (TestComponent)" path="adev/src/content/examples/testing/src/app/shared/highlight.directive.spec.ts" visibleRegion="test-component"/>
3131

32-
<img alt="HighlightDirective spec in action" src="assets/images/guide/testing/highlight-directive-spec.png">
32+
<img alt="HighlightDirective spec en acción" src="assets/images/guide/testing/highlight-directive-spec.png">
3333

34-
HELPFUL: The `<input>` case binds the `HighlightDirective` to the name of a color value in the input box.
35-
The initial value is the word "cyan" which should be the background color of the input box.
34+
ÚTIL: El caso `<input>` vincula la `HighlightDirective` al nombre de un valor de color en el cuadro de entrada.
35+
El valor inicial es la palabra "cyan" que debería ser el color de fondo del cuadro de entrada.
3636

37-
Here are some tests of this component:
37+
Aquí hay algunas pruebas de este componente:
3838

3939
<docs-code header="app/shared/highlight.directive.spec.ts (selected tests)" path="adev/src/content/examples/testing/src/app/shared/highlight.directive.spec.ts" visibleRegion="selected-tests"/>
4040

41-
A few techniques are noteworthy:
41+
Algunas técnicas son dignas de mención:
4242

43-
* The `By.directive` predicate is a great way to get the elements that have this directive *when their element types are unknown*
44-
* The [`:not` pseudo-class](https://developer.mozilla.org/docs/Web/CSS/:not) in `By.css('h2:not([highlight])')` helps find `<h2>` elements that *do not* have the directive.
45-
`By.css('*:not([highlight])')` finds *any* element that does not have the directive.
43+
* El predicado `By.directive` es una excelente manera de obtener los elementos que tienen esta directiva *cuando sus tipos de elemento son desconocidos*
44+
* La [pseudo-clase `:not`](https://developer.mozilla.org/docs/Web/CSS/:not) en `By.css('h2:not([highlight])')` ayuda a encontrar elementos `<h2>` que *no* tienen la directiva.
45+
`By.css('*:not([highlight])')` encuentra *cualquier* elemento que no tenga la directiva.
4646

47-
* `DebugElement.styles` affords access to element styles even in the absence of a real browser, thanks to the `DebugElement` abstraction.
48-
But feel free to exploit the `nativeElement` when that seems easier or more clear than the abstraction.
47+
* `DebugElement.styles` permite el acceso a los estilos del elemento incluso en ausencia de un navegador real, gracias a la abstracción `DebugElement`.
48+
Pero siéntete libre de explotar el `nativeElement` cuando eso parezca más fácil o más claro que la abstracción.
4949

50-
* Angular adds a directive to the injector of the element to which it is applied.
51-
The test for the default color uses the injector of the second `<h2>` to get its `HighlightDirective` instance and its `defaultColor`.
50+
* Angular agrega una directiva al injector del elemento al que se aplica.
51+
La prueba para el color predeterminado usa el injector del segundo `<h2>` para obtener su instancia de `HighlightDirective` y su `defaultColor`.
5252

53-
* `DebugElement.properties` affords access to the artificial custom property that is set by the directive
53+
* `DebugElement.properties` permite el acceso a la propiedad personalizada artificial que se establece por la directiva
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
# Find out how much code you're testing
3+
4+
The Angular CLI can run unit tests and create code coverage reports.
5+
Code coverage reports show you any parts of your code base that might not be properly tested by your unit tests.
6+
7+
To generate a coverage report run the following command in the root of your project.
8+
9+
<docs-code language="shell">
10+
ng test --no-watch --code-coverage
11+
</docs-code>
12+
13+
When the tests are complete, the command creates a new `/coverage` directory in the project.
14+
Open the `index.html` file to see a report with your source code and code coverage values.
15+
16+
If you want to create code-coverage reports every time you test, set the following option in the Angular CLI configuration file, `angular.json`:
17+
18+
<docs-code language="json">
19+
"test": {
20+
"options": {
21+
"codeCoverage": true
22+
}
23+
}
24+
</docs-code>
25+
26+
## Code coverage enforcement
27+
28+
The code coverage percentages let you estimate how much of your code is tested.
29+
If your team decides on a set minimum amount to be unit tested, enforce this minimum with the Angular CLI.
30+
31+
For example, suppose you want the code base to have a minimum of 80% code coverage.
32+
To enable this, open the [Karma](https://karma-runner.github.io) test platform configuration file, `karma.conf.js`, and add the `check` property in the `coverageReporter:` key.
33+
34+
<docs-code language="javascript">
35+
coverageReporter: {
36+
dir: require('path').join(__dirname, './coverage/<project-name>'),
37+
subdir: '.',
38+
reporters: [
39+
{ type: 'html' },
40+
{ type: 'text-summary' }
41+
],
42+
check: {
43+
global: {
44+
statements: 80,
45+
branches: 80,
46+
functions: 80,
47+
lines: 80
48+
}
49+
}
50+
}
51+
</docs-code>
52+
53+
HELPFUL: Read more about creating and fine tuning Karma configuration in the [testing guide](guide/testing#configuration).
54+
55+
The `check` property causes the tool to enforce a minimum of 80% code coverage when the unit tests are run in the project.
56+
57+
Read more on coverage configuration options in the [karma coverage documentation](https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md).
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11

2-
# Find out how much code you're testing
2+
# Descubrir cuánto código estás probando
33

4-
The Angular CLI can run unit tests and create code coverage reports.
5-
Code coverage reports show you any parts of your code base that might not be properly tested by your unit tests.
4+
Angular CLI puede ejecutar pruebas unitarias y crear reportes de cobertura de código.
5+
Los reportes de cobertura de código te muestran cualquier parte de tu código base que podría no estar correctamente probada por tus pruebas unitarias.
66

7-
To generate a coverage report run the following command in the root of your project.
7+
Para generar un reporte de cobertura ejecuta el siguiente comando en la raíz de tu proyecto.
88

99
<docs-code language="shell">
1010
ng test --no-watch --code-coverage
1111
</docs-code>
1212

13-
When the tests are complete, the command creates a new `/coverage` directory in the project.
14-
Open the `index.html` file to see a report with your source code and code coverage values.
13+
Cuando las pruebas estén completas, el comando crea un nuevo directorio `/coverage` en el proyecto.
14+
Abre el archivo `index.html` para ver un reporte con tu código fuente y valores de cobertura de código.
1515

16-
If you want to create code-coverage reports every time you test, set the following option in the Angular CLI configuration file, `angular.json`:
16+
Si quieres crear reportes de cobertura de código cada vez que pruebas, establece la siguiente opción en el archivo de configuración de Angular CLI, `angular.json`:
1717

1818
<docs-code language="json">
1919
"test": {
@@ -23,13 +23,13 @@ If you want to create code-coverage reports every time you test, set the followi
2323
}
2424
</docs-code>
2525

26-
## Code coverage enforcement
26+
## Aplicación de cobertura de código
2727

28-
The code coverage percentages let you estimate how much of your code is tested.
29-
If your team decides on a set minimum amount to be unit tested, enforce this minimum with the Angular CLI.
28+
Los porcentajes de cobertura de código te permiten estimar cuánto de tu código está probado.
29+
Si tu equipo decide sobre una cantidad mínima establecida para ser probada unitariamente, aplica este mínimo con Angular CLI.
3030

31-
For example, suppose you want the code base to have a minimum of 80% code coverage.
32-
To enable this, open the [Karma](https://karma-runner.github.io) test platform configuration file, `karma.conf.js`, and add the `check` property in the `coverageReporter:` key.
31+
Por ejemplo, supón que quieres que la base de código tenga un mínimo de 80% de cobertura de código.
32+
Para habilitar esto, abre el archivo de configuración de la plataforma de pruebas [Karma](https://karma-runner.github.io), `karma.conf.js`, y agrega la propiedad `check` en la clave `coverageReporter:`.
3333

3434
<docs-code language="javascript">
3535
coverageReporter: {
@@ -50,8 +50,8 @@ coverageReporter: {
5050
}
5151
</docs-code>
5252

53-
HELPFUL: Read more about creating and fine tuning Karma configuration in the [testing guide](guide/testing#configuration).
53+
ÚTIL: Lee más sobre crear y ajustar la configuración de Karma en la [guía de pruebas](guide/testing#configuration).
5454

55-
The `check` property causes the tool to enforce a minimum of 80% code coverage when the unit tests are run in the project.
55+
La propiedad `check` hace que la herramienta aplique un mínimo de 80% de cobertura de código cuando las pruebas unitarias se ejecutan en el proyecto.
5656

57-
Read more on coverage configuration options in the [karma coverage documentation](https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md).
57+
Lee más sobre opciones de configuración de cobertura en la [documentación de karma coverage](https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md).

0 commit comments

Comments
 (0)