Skip to content

elto82/02-bases

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pasos para usar Node con TypeScript con Nodemon

Más información - Docs Oficiales

  1. Instalar TypeScript y tipos de Node, como dependencia de desarrollo
npm i -D typescript @types/node
  1. Inicializar el archivo de configuración de TypeScript ( Se puede configurar al gusto)
npx tsc --init --outDir dist/ --rootDir src
  1. Opcional - Para traspilar el código, se puede usar este comando
npx tsc
npx tsc --watch
  1. Configurar Nodemon y Node-TS
npm install -D ts-node nodemon
  1. Crear archivo de configuración de Nodemon - nodemon.json
{
  "watch": ["src"],
  "ext": ".ts,.js",
  "ignore": [],
  "exec": "npx ts-node ./src/app.ts"
}
  1. Crear script para correr en desarrollo en el package.json
  "dev": "nodemon"
  "dev": "npx nodemon" // En caso de no querer instalar nodemon
  1. Instalar rimraf (Herramienta que funciona similar al rm -f) eliminar directorio
npm install -D rimraf
  1. Crear scripts en el package.json para construir e iniciar en producción
   "build": "rimraf ./dist && tsc",
   "start": "npm run build && node dist/app.js"

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",

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors