A medida que crece nuestro proyecto, las buenas pruebas son las que garantizan que podamos hacerle mantenimiento a nuestro c贸digo sin romper nada o al menos d谩ndonos la oportunidad de darnos cuenta y repararlo antes de afectar a los usuarios
Requisitos
驴Qu茅 necesitas para aprender Testing E2E con Node.js?
Introducci贸n: pruebas e2e con Node.js
Explorando la API
Explorando el c贸digo del proyecto
Instalando y configurando Jest con Node
Tu primer prueba e2e
Buenas pr谩cticas en pruebas E2E
Pruebas a la API de Fake Store
Configurando el entorno de pruebas para nuestro proyecto
Coverage Report
Pruebas a Schemas o DTOs
Pruebas a endpoints GET
Pruebas al Login
Pruebas a rutas con protecci贸n
Pruebas a rutas con accessToken
Pruebas a endpoints POST
Pruebas en Entornos de Desarrollo Avanzados
驴Crear bases de datos solo para pruebas?
Preparando el ambiente de pruebas e2e
Creando un seed de datos manual
Seed de datos con sequelize
Umzug: corriendo los seeds de datos para pruebas e2e
Pruebas a crear categor铆as
Pruebas al endpoint de producto
Pruebas a la paginaci贸n
Mocking y automatizaci贸n
Mocking en Node.js
Automatizacion en GitHub Actions
Pr贸ximos pasos
驴Quieres m谩s cursos de testing?
You don't have access to this class
Keep learning! Join and start boosting your career
Launching a coverage report on your development projects is crucial to make sure how many tests are running and what parts of your code are being covered. These reports guide you in determining which flows or endpoints are not yet covered in your current tests. Coverage does not measure the quality of the tests; it simply indicates which parts of the code have been "touched" during testing.
To generate a coverage report, you need to add specific configurations in your package.json
file. Often these settings are separated so as not to overload a single command. Here's how you can do it:
Adding a command in package.json:
{ " scripts": { " test:e2e": "jest --coverage" }}
Running the command:
npm run test:e2e
coverage
folder containing the report.Visual Studio Code makes it easy to find this report. Inside your project, when you run the tests, a folder named coverage
is automatically created.
Locate the folder:
Open the report in a browser:
coverage
, look for index.html
which you can open with any web browser.Often, when running end-to-end (e2e) tests, you cover multiple lines of code simply by launching the application. However, to ensure more detailed coverage:
For example, make sure that routers, the authentication process and other important endpoints are covered in the tests. Develop specific tests for non-covered endpoints, such as login or data verification.
It is common that when integrating different types of tests, such as unit testing
and end-to-end
, coverage reports become intertwined. To prevent this:
Correctly configure the coverage directory in the configuration file, such as jest.config.js
:
module.exports = { coverageDirectory: 'coverage/e2e'};
Ignore coverage folders in Git: Add these new folders to your .gitignore
file to prevent such reports from being logged in version control.
Run and verify: When re-running the npm run test:e2e
command, make sure that your tests are generating reports only for the specified test type.
This methodical separation will help you maintain proper order when handling different types of tests, ensuring that each report is clear and useful for future code reviews and enhancements. Go ahead and continue exploring how to improve your testing capabilities!
Contributions 2
Questions 0
A medida que crece nuestro proyecto, las buenas pruebas son las que garantizan que podamos hacerle mantenimiento a nuestro c贸digo sin romper nada o al menos d谩ndonos la oportunidad de darnos cuenta y repararlo antes de afectar a los usuarios
Want to see more contributions, questions and answers from the community?