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

361
Views
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 answers
Answer question

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 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!