#How to test my api in my medusa backend

21 messages · Page 1 of 1 (latest)

candid pawn
#

I am developing a medusajs application and I need to unit test my endpoints with jest. The examples I have been guided by have not worked for me. Could you help me with an example of how to test my endpoints in my medusajs backend?

crisp nexus
candid pawn
#

I need to make them with jest

crisp nexus
#

I don't know about jest, but the idea is the same

#

There is a detailed API reference with curl examples
There are also tons of examples in the medusa monorepo

candid pawn
#

I mean testing the code, where you create a test folder and run node run test to test your tests, not as such the endpoints from the postman.

crisp nexus
#

Yes, check the test folders in the monorepo

candid pawn
#

if I've been looking at it but when I run them I get an error, I don't know if it's because of the configuration of the tests in my project, I show you the error

silent belfry
#

otherwise I have no error u are getting

candid pawn
#

this is my test:

#

by executing it

vital pelican
#

OK a couple ov things.. 1. Have you used ts-jest

#
  1. The question I had is how did you get your medusa instance to fire up
#

If you can get the instance to start..you can use tools like super test to the test the api

#

Without having several mocks

#

Do you have to write the tests on js?