Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonanv/test-jest-angularjs

Test with Jest into Angular v17
https://github.com/jonanv/test-jest-angularjs

angular angular-cli angular17 angular2 javascript jest jest-tests no-standalone typescript

Last synced: 3 days ago
JSON representation

Test with Jest into Angular v17

Awesome Lists containing this project

README

        

# TestJestAngularjs

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.8.

## Steps for configuration Jest

1. Remover cualquier referencia de Jasmine / Karma en el package.json
```js
npm remove @types/jasmine jasmine-core karma karma-chrome-launcher karma-coverage karma-jasmine karma-jasmine-html-reporter
```

2. Instalar Jest
```js
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": [
"/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