Files
medusa-store/www/apps/book/app/debugging-and-testing/tools/page.mdx
Shahed Nasser 964927b597 docs: general fixes and improvements (#7918)
* 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
2024-07-04 17:26:03 +03:00

67 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export const metadata = {
title: `${pageNumber} Debugging and Testing Tools`,
}
# {metadata.title}
In this chapter, youll 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 its 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 youre 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.jss Debugger API to debug your Medusa customizations.
Refer to [Node.jss documentation](https://nodejs.org/docs/latest-v18.x/api/debugger.html) for more details.