Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
Broma: no se puede encontrar el nombre para describir la broma.

Después de un año y medio que he terminado un proyecto, estoy a punto de empezar a probar otro proyecto con Jest y ahí para ya tenía instalados los paquetes necesarios a nivel de desarrollo:

 "devDependencies": { "@types/jest": "^27.4.1", "supertest": "^6.1.6" }

Cuando comencé a corregir el código de prueba automatizado, de inmediato recibo una advertencia de Errores:

 Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.ts(2582)

Busqué este asunto y encontré este artículo https://stackoverflow.com/questions/54139158/cannot-find-name-describe-do-you-need-to-install-type-definitions-for-a-test

Como se sugirió, intenté hacer ajustes en tsconfig.json, pero desafortunadamente esto no resolvió mi problema. Aquí está mi tsconfig.json:

 { "compilerOptions": { /* Visit https://aka.ms/tsconfig.json to read more about this file */ /* Language and Environment */ "target": "es6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, /* Modules */ "module": "commonjs" /* Specify what module code is generated. */, "types": [ "jest" ] /* Specify type package names to be included without being referenced in a source file. */, /* Interop Constraints */ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, /* Type Checking */ "strict": true /* Enable all strict type-checking options. */, /* Completeness */ "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, "include": ["src/**/*, tests/*.js"], "exclude": ["node_modules"] }

Para tsconfig, también se queja de lo siguiente:

 No inputs were found in config file tsconfig.ts. Specified "include" paths where `["src/**/*, tests/*.js"]` and 'exclude' paths where '["node_modules"]'

¿Cómo puedo resolver estos problemas extraños al darme cuenta de que no estoy usando mecanografiado en mi proyecto y no estoy familiarizado con mecanografiado en este momento?

Gracias por adelantado

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Después de tomarme un descanso de este problema e investigar un poco, logré encontrar una solución. La solución es instalar el paquete @jest/globals

Con eso instalado, lo importé a mi archivo de prueba. Aquí hay un ejemplo a continuación:

 const jest = require("@jest/globals"); const mongoose = require("mongoose"); const request = require("supertest"); const app = require("../express-app"); let server; jest.describe("Testing Auth Service", () => { jest.describe("/api/v1/", () => { jest.beforeEach(() => { server = require("../index"); }); jest.afterAll(async () => { await server.close(); }); }); });

Si hay un mejor enfoque para esto, por favor deje un comentario. Lo apreciaría.

Atentamente.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!