Files

76 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 587d824a367417b2b2512c46
title: Aprende cómo funcionan las aserciones de JavaScript
challengeType: 2
forumTopicId: 301589
dashedName: learn-how-javascript-assertions-work
---
# --description--
Trabajar en estos desafíos implica escribir tu código usando uno de los siguientes métodos:
- Clona [este repositorio de Github](https://github.com/freeCodeCamp/boilerplate-mochachai/) y completa estos desafíos localmente.
- Usa [nuestro proyecto inicial de Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) para completar estos desafíos.
- Utiliza un constructor de sitios web de tu elección para completar el proyecto. Asegúrate de incorporar todos los archivos de nuestro repositorio de GitHub.
Cuando hayas terminado, asegúrate de que un demo funcional de tu proyecto esté alojado en algún lugar público. Luego, envía la URL en el campo `Solution Link`.
# --instructions--
Dentro de `tests/1_unit-tests.js` bajo la prueba etiquetada `#1` en la `Basic Assertions`, cambiar cada `assert` a `assert.isNull` o `assert.isNotNull` para que la prueba sea superada (debe evaluar a `true`). No modifiques los argumentos pasados a los verificadores.
# --hints--
Todas las pruebas deben pasar.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=0').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Debe elegir el método correcto para la primera aserción - `isNull` vs. `isNotNull`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=0').then(
(data) => {
assert.equal(data.assertions[0].method, 'isNull', 'Null is null');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Debe elegir el método correcto para la segunda aserción - `isNull` vs. `isNotNull`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=0').then(
(data) => {
assert.equal(data.assertions[1].method, 'isNotNull', '1 is not null');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
# --solutions--
```js
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/
```