docs: add prerequisites link for test guides (#9057)
- Add a prerequisites link to test guides pointing to how to setup the testing tools - Add in the main http / module integration guides the command to run the tests
This commit is contained in:
+12
-1
@@ -1,3 +1,5 @@
|
||||
import { Prerequisites } from "docs-ui"
|
||||
|
||||
export const metadata = {
|
||||
title: `${pageNumber} Example: Integration Tests for a Module`,
|
||||
}
|
||||
@@ -6,6 +8,15 @@ export const metadata = {
|
||||
|
||||
In this chapter, find an example of writing an integration test for a module using the [moduleIntegrationTestRunner utility function](../page.mdx).
|
||||
|
||||
<Prerequisites
|
||||
items={[
|
||||
{
|
||||
text: "Testing Tools Setup",
|
||||
link: "/debugging-and-testing/testing-tools"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
||||
## Write Integration Test for Module
|
||||
|
||||
Consider a `hello` module with a `HelloModuleService` that has a `getMessage` method:
|
||||
@@ -67,4 +78,4 @@ If you don't have a `test:modules` script in `package.json`, refer to the [Medus
|
||||
|
||||
</Note>
|
||||
|
||||
This runs your Medusa application and runs the tests available in any `__tests__` directory under the `src` directory.
|
||||
This runs your Medusa application and runs the tests available in any `__tests__` directory under the `src/modules` directory.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Prerequisites } from "docs-ui"
|
||||
|
||||
export const metadata = {
|
||||
title: `${pageNumber} Write Tests for Modules`,
|
||||
}
|
||||
@@ -6,6 +8,15 @@ export const metadata = {
|
||||
|
||||
In this chapter, you'll learn about the `moduleIntegrationTestRunner` utility function and how to use it to write integration tests for a module's main service.
|
||||
|
||||
<Prerequisites
|
||||
items={[
|
||||
{
|
||||
text: "Testing Tools Setup",
|
||||
link: "/debugging-and-testing/testing-tools"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
||||
## moduleIntegrationTestRunner Utility
|
||||
|
||||
The `moduleIntegrationTestRunner` utility function is provided by the `medusa-test-utils` package to create integration tests for a module. The integration tests run on a test Medusa application with only the specified module enabled.
|
||||
@@ -47,6 +58,24 @@ The tests in the `testSuite` function are written using [Jest](https://jestjs.io
|
||||
|
||||
---
|
||||
|
||||
## Run Tests
|
||||
|
||||
Run the following command to run your module integration tests:
|
||||
|
||||
```bash npm2yarn
|
||||
npm run test:modules
|
||||
```
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
If you don't have a `test:modules` script in `package.json`, refer to the [Medusa Testing Tools chapter](../page.mdx#add-test-commands).
|
||||
|
||||
</Note>
|
||||
|
||||
This runs your Medusa application and runs the tests available in any `__tests__` directory under the `src/modules` directory.
|
||||
|
||||
---
|
||||
|
||||
## Pass Module Options
|
||||
|
||||
If your module accepts options, you can set them using the `moduleOptions` property of the `moduleIntegrationTestRunner`'s parameter.
|
||||
|
||||
Reference in New Issue
Block a user