* docs improvements and changes * updated module definition * modules + dml changes * fix build * fix vale error * fix lint errors * fixes to stripe docs * fix condition * fix condition * fix module defintion * fix checkout * disable UI action * change oas preview action * flatten provider module options * fix lint errors * add module link docs * pr comments fixes * fix vale error * change node engine version * links -> linkable * add note about database name * small fixes * link fixes * fix response code in api reference * added migrations step
67 lines
1.8 KiB
Plaintext
67 lines
1.8 KiB
Plaintext
export const metadata = {
|
||
title: `${pageNumber} Debugging and Testing Tools`,
|
||
}
|
||
|
||
# {metadata.title}
|
||
|
||
In this chapter, you’ll learn about debugging and testing tools you can use.
|
||
|
||
<Note title="Tip">
|
||
|
||
Since the Medusa server is a Node.js server, you can use any Node.js testing tool you prefer, even if it’s not listed here.
|
||
|
||
</Note>
|
||
|
||
## Jest
|
||
|
||
[Jest](https://jestjs.io/) is a JavaScript testing framework. Your Medusa project is already configured with Jest; you can use it out-of-the-box.
|
||
|
||
<Note>
|
||
|
||
Refer to [Jest's documentation](https://jestjs.io/docs/getting-started) to learn how to install and configure it.
|
||
|
||
</Note>
|
||
|
||
For example, consider the following service created at `src/modules/hello/service.ts`:
|
||
|
||
```ts title="src/modules/hello/service.ts"
|
||
class HelloModuleService {
|
||
getMessage(): string {
|
||
return "Hello, world!"
|
||
}
|
||
}
|
||
|
||
export default HelloModuleService
|
||
|
||
```
|
||
|
||
You can write a test for it in the file `src/modules/hello/__tests__/hello-world.spec.ts`:
|
||
|
||
```ts title="src/modules/hello/__tests__/hello-world.spec.ts"
|
||
import HelloModuleService from "../service"
|
||
|
||
describe("HelloModuleService", () => {
|
||
const helloModuleService = new HelloModuleService()
|
||
|
||
it("should return hello world message", () => {
|
||
expect(helloModuleService.getMessage()).toBe("Hello, world!")
|
||
})
|
||
})
|
||
```
|
||
|
||
---
|
||
|
||
## IDE Debugging Tools
|
||
|
||
Your IDE may provide a debugging tool for Node.js. In that case, you can use that tool to debug your Medusa customizations.
|
||
|
||
For example, if you’re using VSCode, refer to [this guide](https://code.visualstudio.com/docs/nodejs/nodejs-debugging) to learn how to configure and use the debugger.
|
||
|
||
---
|
||
|
||
## Node.js Debugger
|
||
|
||
You can also use Node.js’s Debugger API to debug your Medusa customizations.
|
||
|
||
Refer to [Node.js’s documentation](https://nodejs.org/docs/latest-v18.x/api/debugger.html) for more details.
|