Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

359
Vistas
How to run function in tests?

I'm a Java Developer but I want to have some experience also with NodeJS. In Java, when i make a function, then i can run this function in a simple way with using tests like below:

    @Autowired
    SomeService service;

    @Test
    public void testGet() {
        SomeDto dto = service.getDto(1L);
        log.info("Retrieved: {}", dto.getName());
    }

Right now I can run only this one test and check that my method work properly. But how to do this with using NodeJS? For example i have this method:

async getData(id: any): Promise<SomeDto> {
   return this.conn.getRepository(Client).findById(id);
}

how to run this method in tests like I'm doing it with Java?

PS. I don't want to create unit test and so on, I want only to run my functions with using tests

thanks for any help!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In nodejs (Or TS) we have lot of test framework, mocha is famous test framework

You can use mocha for BDD, TDD, ...

See mocha document in https://mochajs.org/

Below link help you to write test in nodejs and i hope helpful for you:

https://blog.logrocket.com/a-quick-and-complete-guide-to-mocha-testing-d0e0ea09f09d/


Tip: If you want use TDD you can use sinon package, this package is so good for TDD and fake function

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda