Skip to content

Instantly share code, notes, and snippets.

@MatiasNZamora
Last active December 17, 2023 07:05
Show Gist options
  • Save MatiasNZamora/a4893d4873c43a1fb2c1d9ebd4cbd540 to your computer and use it in GitHub Desktop.
Save MatiasNZamora/a4893d4873c43a1fb2c1d9ebd4cbd540 to your computer and use it in GitHub Desktop.

Pasos para configurar Jest con TypeScript, en Node

Documentación oficial sobre Jest

  1. Instalaciones de desarrollo (super test es útil para probar Express)
npm install -D jest @types/jest ts-jest supertest
  1. Crear archivo de configuración de Jest
npx jest --init
  1. En el archivo jest.config.js configurar
preset: 'ts-jest',
testEnvironment: "jest-environment-node",

// Opcional - The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: ['dotenv/config'],
  1. Crear scripts en el package.json
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment