|
1 | | -The test demonstrates one of the temptations a developer meets when writing tests. |
| 1 | +El test demuestra una tentación habitual del/a desarrollador/a al escribir tests. |
2 | 2 |
|
3 | | -What we have here is actually 3 tests, but layed out as a single function with 3 asserts. |
| 3 | +Lo que tenemos aquí son en realidad 3 pruebas, pero presentadas como una sola función con 3 afirmaciones. |
4 | 4 |
|
5 | | -Sometimes it's easier to write this way, but if an error occurs, it's much less obvious what went wrong. |
| 5 | +A veces es más fácil escribir de esta manera, pero si ocurre un error, es mucho menos obvio saber qué salió mal. |
6 | 6 |
|
7 | | -If an error happens inside a complex execution flow, then we'll have to figure out the data at that point. We'll actually have to *debug the test*. |
| 7 | +Sería mucho mejor dividir la prueba en múltiples bloques 'it' con entradas y salidas claramente escritas. |
8 | 8 |
|
9 | | -It would be much better to break the test into multiple `it` blocks with clearly written inputs and outputs. |
10 | | - |
11 | | -Like this: |
| 9 | +Como ésto: |
12 | 10 | ```js |
13 | | -describe("Raises x to power n", function() { |
14 | | - it("5 in the power of 1 equals 5", function() { |
| 11 | +describe("Eleva x a la potencia n", function() { |
| 12 | + it("5 elevado a 1 es igual a 5", function() { |
15 | 13 | assert.equal(pow(5, 1), 5); |
16 | 14 | }); |
17 | 15 |
|
18 | | - it("5 in the power of 2 equals 25", function() { |
| 16 | + it("5 elevado a 2 es igual a 25", function() { |
19 | 17 | assert.equal(pow(5, 2), 25); |
20 | 18 | }); |
21 | 19 |
|
22 | | - it("5 in the power of 3 equals 125", function() { |
| 20 | + it("5 elevado a 3 es igual a 125", function() { |
23 | 21 | assert.equal(pow(5, 3), 125); |
24 | 22 | }); |
25 | 23 | }); |
26 | 24 | ``` |
27 | 25 |
|
28 | | -We replaced the single `it` with `describe` and a group of `it` blocks. Now if something fails we would see clearly what the data was. |
| 26 | +Reemplazamos el único `it` por un `describe` y agrupamos los bloques `it` dentro. Ahora si algo sale mal, podemos ver claramente que dato fue. |
29 | 27 |
|
30 | | -Also we can isolate a single test and run it in standalone mode by writing `it.only` instead of `it`: |
| 28 | +Además podemos aislar un único test y ejecutarlo individualmente escribiendo `it.only` en lugar de `it`: |
31 | 29 |
|
32 | 30 |
|
33 | 31 | ```js |
34 | 32 | describe("Raises x to power n", function() { |
35 | | - it("5 in the power of 1 equals 5", function() { |
| 33 | + it("5 elevado a 1 es igual a 5", function() { |
36 | 34 | assert.equal(pow(5, 1), 5); |
37 | 35 | }); |
38 | 36 |
|
39 | 37 | *!* |
40 | | - // Mocha will run only this block |
41 | | - it.only("5 in the power of 2 equals 25", function() { |
| 38 | + // Mocha sólo ejecutará este bloque |
| 39 | + it.only("5 elevado a 2 es igual a 25", function() { |
42 | 40 | assert.equal(pow(5, 2), 25); |
43 | 41 | }); |
44 | 42 | */!* |
45 | 43 |
|
46 | | - it("5 in the power of 3 equals 125", function() { |
| 44 | + it("5 elevado a 3 es igual a 125", function() { |
47 | 45 | assert.equal(pow(5, 3), 125); |
48 | 46 | }); |
49 | 47 | }); |
|
0 commit comments