Forked from Klerith/angular-jest-installation.md
Created
March 6, 2025 20:20
Revisions
-
Klerith revised this gist
Mar 4, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,9 @@ npm remove <karma karma-chrome-launcher...> ``` 2. Instalar Jest ``` npm install --save-dev jest jest-preset-angular @types/jest ``` 3. Crear el ```setup-jest.ts``` en la carpeta root del proyecto y el contenido es el siguiente ```setup-jest.ts -
Klerith created this gist
Mar 4, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ # Angular testing con JEST 1. Remover cualquier referencia de Jasmine / Karma en el package.json ``` npm remove <karma karma-chrome-launcher...> ``` 2. Instalar Jest npm install --save-dev jest jest-preset-angular @types/jest 3. Crear el ```setup-jest.ts``` en la carpeta root del proyecto y el contenido es el siguiente ```setup-jest.ts import 'jest-preset-angular/setup-jest'; ``` 4. Agregar en el package.json, la configuración de Jest ```package.json "jest": { "preset": "jest-preset-angular", "setupFilesAfterEnv": [ "<rootDir>/setup-jest.ts" ], "globalSetup": "jest-preset-angular/global-setup" } ``` 4. Configurar JEST en tsconfig.json y tsconfig.spec.json ```tsconfig.json "types": [ "jest" ] ``` 5. Configurar los comandos para ejecutar las pruebas en el package.json ```package.json "test": "jest", "test:watch": "jest --watchAll", ``` 6. Remover karma.config.js y el archivo test.ts