docs: rename packages (#9618)
This commit is contained in:
@@ -8,5 +8,5 @@ In the next chapters, you’ll learn about the tools Medusa provides for testing
|
||||
|
||||
By the end of this chapter, you’ll learn:
|
||||
|
||||
- How to use Medusa's `medusa-test-utils` test to write integration tests.
|
||||
- How to use Medusa's `@medusajs/test-utils` test to write integration tests.
|
||||
- How to use Medusa’s `Logger` utility to log messages.
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ export const getHighlights = [
|
||||
]
|
||||
|
||||
```ts title="integration-tests/http/custom-routes.spec.ts" highlights={getHighlights}
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
testSuite: ({ api, getContainer }) => {
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ In this chapter, you'll learn about the `medusaIntegrationTestRunner` utility fu
|
||||
|
||||
## medusaIntegrationTestRunner Utility
|
||||
|
||||
The `medusaIntegrationTestRunner` utility function is provided by the `medusa-test-utils` package to create integration tests in your Medusa project. It runs a full Medusa application, allowing you test API routes, workflows, or other customizations.
|
||||
The `medusaIntegrationTestRunner` utility function is provided by the `@medusajs/test-utils` package to create integration tests in your Medusa project. It runs a full Medusa application, allowing you test API routes, workflows, or other customizations.
|
||||
|
||||
For example:
|
||||
|
||||
@@ -29,7 +29,7 @@ export const highlights = [
|
||||
]
|
||||
|
||||
```ts title="integration-tests/http/test.spec.ts" highlights={highlights}
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
testSuite: ({ api, getContainer }) => {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ export const helloWorldWorkflow = createWorkflow(
|
||||
To write a test for this workflow, create the file `integration-tests/http/workflow.spec.ts` with the following content:
|
||||
|
||||
```ts title="integration-tests/http/workflow.spec.ts"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { helloWorldWorkflow } from "../../src/workflows/hello-world"
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ export default HelloModuleService
|
||||
To create an integration test for the method, create the file `src/modules/hello/__tests__/service.spec.ts` with the following content:
|
||||
|
||||
```ts title="src/modules/hello/__tests__/service.spec.ts"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { HELLO_MODULE } from ".."
|
||||
import HelloModuleService from "../service"
|
||||
import MyCustom from "../models/my-custom"
|
||||
|
||||
@@ -19,12 +19,12 @@ In this chapter, you'll learn about the `moduleIntegrationTestRunner` utility fu
|
||||
|
||||
## 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.
|
||||
The `moduleIntegrationTestRunner` utility function is provided by the `@medusajs/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.
|
||||
|
||||
For example, assuming you have a `hello` module, create a test file at `src/modules/hello/__tests__/service.spec.ts`:
|
||||
|
||||
```ts title="src/modules/hello/__tests__/service.spec.ts"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { HELLO_MODULE } from ".."
|
||||
import HelloModuleService from "../service"
|
||||
import MyCustom from "../models/my-custom"
|
||||
@@ -83,7 +83,7 @@ If your module accepts options, you can set them using the `moduleOptions` prope
|
||||
For example:
|
||||
|
||||
```ts
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import HelloModuleService from "../service"
|
||||
|
||||
moduleIntegrationTestRunner<HelloModuleService>({
|
||||
@@ -103,7 +103,7 @@ If your module doesn't have a data model, pass a dummy model in the `moduleModel
|
||||
For example:
|
||||
|
||||
```ts
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import HelloModuleService from "../service"
|
||||
import { model } from "@medusajs/framework/utils"
|
||||
|
||||
|
||||
@@ -6,23 +6,23 @@ export const metadata = {
|
||||
|
||||
In this chapter, you'll learn about Medusa's testing tools and how to install and configure them.
|
||||
|
||||
## medusa-test-utils Package
|
||||
## @medusajs/test-utils Package
|
||||
|
||||
Medusa provides a `medusa-test-utils` package with utility tools to create integration tests for your custom API routes, modules, or other Medusa customizations.
|
||||
Medusa provides a `@medusajs/test-utils` package with utility tools to create integration tests for your custom API routes, modules, or other Medusa customizations.
|
||||
|
||||
### Install medusa-test-utils
|
||||
### Install @medusajs/test-utils
|
||||
|
||||
To use the `medusa-test-utils` package, install it as a `devDependency`:
|
||||
To use the `@medusajs/test-utils` package, install it as a `devDependency`:
|
||||
|
||||
```bash npm2yarn
|
||||
npm install --save-dev medusa-test-utils@rc
|
||||
npm install --save-dev @medusajs/test-utils@rc
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Install and Configure Jest
|
||||
|
||||
Writing tests with `medusa-test-utils`'s tools requires installing and configuring Jest in your project.
|
||||
Writing tests with `@medusajs/test-utils`'s tools requires installing and configuring Jest in your project.
|
||||
|
||||
{/* TODO remove this note at some point in the future */}
|
||||
|
||||
@@ -100,4 +100,4 @@ Medusa provides utility tools for integration tests only. You can write unit tes
|
||||
|
||||
## Test Tools and Writing Tests
|
||||
|
||||
The next chapters explain how to use the testing tools provided by `medusa-test-utils` to write tests.
|
||||
The next chapters explain how to use the testing tools provided by `@medusajs/test-utils` to write tests.
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = {
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
resolve: "@medusajs/medusa/file-local-next",
|
||||
resolve: "@medusajs/medusa/file-local",
|
||||
id: "local",
|
||||
options: {
|
||||
// provider options...
|
||||
|
||||
@@ -47,7 +47,7 @@ export async function POST(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const inventoryModuleService = await initializeInventoryModule({})
|
||||
@@ -97,7 +97,7 @@ export async function GET(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const inventoryModuleService = await initializeInventoryModule({})
|
||||
@@ -144,7 +144,7 @@ export async function GET(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
type ContextType = {
|
||||
params: {
|
||||
@@ -201,7 +201,7 @@ export async function POST(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const inventoryModuleService = await initializeInventoryModule({})
|
||||
@@ -255,7 +255,7 @@ export async function POST(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const inventoryModuleService = await initializeInventoryModule({})
|
||||
@@ -309,7 +309,7 @@ export async function POST(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const inventoryModuleService = await initializeInventoryModule({})
|
||||
@@ -363,7 +363,7 @@ export async function POST(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const inventoryModuleService = await initializeInventoryModule({})
|
||||
@@ -432,7 +432,7 @@ export async function GET(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
type ContextType = {
|
||||
params: {
|
||||
@@ -501,7 +501,7 @@ export async function DELETE(
|
||||
<CodeTab label="Next.js App Router" value="nextjs">
|
||||
|
||||
```ts
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
|
||||
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory"
|
||||
|
||||
type ContextType = {
|
||||
params: {
|
||||
|
||||
@@ -46,7 +46,7 @@ export async function POST(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location-next"
|
||||
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location"
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const stockLocationModuleService = await initializeStockLocationModule({})
|
||||
@@ -92,7 +92,7 @@ export async function GET(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location-next"
|
||||
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location"
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const stockLocationModuleService = await initializeStockLocationModule({})
|
||||
@@ -146,7 +146,7 @@ export async function POST(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location-next"
|
||||
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location"
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const stockLocationModuleService = await initializeStockLocationModule({})
|
||||
@@ -200,7 +200,7 @@ export async function DELETE(
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location-next"
|
||||
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location"
|
||||
|
||||
export async function DELETE(request: Request) {
|
||||
const stockLocationModuleService = await initializeStockLocationModule({})
|
||||
|
||||
@@ -119,7 +119,7 @@ The code snippet must be written using NPM.
|
||||
When a command uses the global option `-g`, add it at the end of the NPM command to ensure that it’s transformed to a Yarn command properly. For example:
|
||||
|
||||
```bash npm2yarn
|
||||
npm install @medusajs/medusa-cli -g
|
||||
npm install @medusajs/cli -g
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -3230,7 +3230,7 @@ Learn more in [this documentation](!docs!/advanced-development/admin/tips#routin
|
||||
|
||||
## Integration Tests
|
||||
|
||||
Medusa provides a `medusa-test-utils` package with utility tools to create integration tests for your custom API routes, modules, or other Medusa customizations.
|
||||
Medusa provides a `@medusajs/test-utils` package with utility tools to create integration tests for your custom API routes, modules, or other Medusa customizations.
|
||||
|
||||
<Note>
|
||||
|
||||
@@ -3243,7 +3243,7 @@ For details on setting up your project for integration tests, refer to [this doc
|
||||
To create a test for a custom API route, create the file `integration-tests/http/custom-routes.spec.ts` with the following content:
|
||||
|
||||
```ts title="integration-tests/http/custom-routes.spec.ts"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
testSuite: ({ api, getContainer }) => {
|
||||
@@ -3277,7 +3277,7 @@ Learn more in [this documentation](!docs!/debugging-and-testing/testing-tools/in
|
||||
To create a test for a workflow, create the file `integration-tests/http/workflow.spec.ts` with the following content:
|
||||
|
||||
```ts title="integration-tests/http/workflow.spec.ts"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { helloWorldWorkflow } from "../../src/workflows/hello-world"
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
@@ -3309,7 +3309,7 @@ To create a test for a module's service, create the test under the `__tests__` d
|
||||
For example, create the file `src/modules/hello/__tests__/service.spec.ts` with the following content:
|
||||
|
||||
```ts title="src/modules/hello/__tests__/service.spec.ts"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { HELLO_MODULE } from ".."
|
||||
import HelloModuleService from "../service"
|
||||
import MyCustom from "../models/my-custom"
|
||||
|
||||
@@ -6,12 +6,12 @@ export const metadata = {
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
This document provides a reference to the `medusaIntegrationTestRunner` function provided by the `medusa-test-utils` package.
|
||||
This document provides a reference to the `medusaIntegrationTestRunner` function provided by the `@medusajs/test-utils` package.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
testSuite: ({ api, getContainer }) => {
|
||||
|
||||
@@ -6,12 +6,12 @@ export const metadata = {
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
This document provides a reference to the `moduleIntegrationTestRunner` function provided by the `medusa-test-utils` package.
|
||||
This document provides a reference to the `moduleIntegrationTestRunner` function provided by the `@medusajs/test-utils` package.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { HELLO_MODULE } from ".."
|
||||
import HelloModuleService from "../service"
|
||||
import MyCustom from "../models/my-custom"
|
||||
|
||||
@@ -6,6 +6,6 @@ export const metadata = {
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
This section of the documentation provides a reference to the testing functions provided by the `medusa-test-utils` package.
|
||||
This section of the documentation provides a reference to the testing functions provided by the `@medusajs/test-utils` package.
|
||||
|
||||
<ChildDocs />
|
||||
@@ -114,7 +114,7 @@ export const generatedEditDates = {
|
||||
"app/commerce-modules/user/page.mdx": "2024-10-15T14:44:19.628Z",
|
||||
"app/commerce-modules/page.mdx": "2024-10-07T13:55:08.014Z",
|
||||
"app/contribution-guidelines/_admin-translations/page.mdx": "2024-05-13T18:55:11+03:00",
|
||||
"app/contribution-guidelines/docs/page.mdx": "2024-05-13T18:55:11+03:00",
|
||||
"app/contribution-guidelines/docs/page.mdx": "2024-10-16T15:48:04.071Z",
|
||||
"app/create-medusa-app/page.mdx": "2024-08-05T11:10:55+03:00",
|
||||
"app/deployment/admin/vercel/page.mdx": "2024-10-16T08:10:29.377Z",
|
||||
"app/deployment/medusa-application/railway/page.mdx": "2024-10-15T12:50:50.981Z",
|
||||
@@ -230,7 +230,7 @@ export const generatedEditDates = {
|
||||
"app/architectural-modules/workflow-engine/in-memory/page.mdx": "2024-10-15T12:50:57.249Z",
|
||||
"app/architectural-modules/cache/in-memory/page.mdx": "2024-10-15T12:49:57.608Z",
|
||||
"app/architectural-modules/notification/local/page.mdx": "2024-10-15T12:51:21.284Z",
|
||||
"app/architectural-modules/file/local/page.mdx": "2024-10-15T12:51:07.033Z",
|
||||
"app/architectural-modules/file/local/page.mdx": "2024-10-16T15:48:42.839Z",
|
||||
"app/architectural-modules/notification/send-notification/page.mdx": "2024-09-30T08:43:53.151Z",
|
||||
"app/architectural-modules/file/page.mdx": "2024-07-01T10:21:19+03:00",
|
||||
"app/architectural-modules/event/page.mdx": "2024-05-28T13:25:03+03:00",
|
||||
@@ -753,9 +753,9 @@ export const generatedEditDates = {
|
||||
"references/types/HttpTypes/interfaces/types.HttpTypes.AdminWorkflowExecution/page.mdx": "2024-08-30T00:11:02.510Z",
|
||||
"references/types/HttpTypes/interfaces/types.HttpTypes.AdminWorkflowExecutionResponse/page.mdx": "2024-08-30T00:11:02.514Z",
|
||||
"references/types/interfaces/types.BaseReturnItem/page.mdx": "2024-08-30T00:11:02.538Z",
|
||||
"app/test-tools-reference/medusaIntegrationTestRunner/page.mdx": "2024-09-02T12:12:48.492Z",
|
||||
"app/test-tools-reference/moduleIntegrationTestRunner/page.mdx": "2024-10-16T08:52:30.701Z",
|
||||
"app/test-tools-reference/page.mdx": "2024-09-02T12:25:44.922Z",
|
||||
"app/test-tools-reference/medusaIntegrationTestRunner/page.mdx": "2024-10-16T15:47:38.579Z",
|
||||
"app/test-tools-reference/moduleIntegrationTestRunner/page.mdx": "2024-10-16T15:47:38.504Z",
|
||||
"app/test-tools-reference/page.mdx": "2024-10-16T15:47:38.429Z",
|
||||
"references/types/HttpTypes/interfaces/types.HttpTypes.AdminGetInvitesParams/page.mdx": "2024-09-03T00:10:55.319Z",
|
||||
"references/types/HttpTypes/interfaces/types.HttpTypes.AdminInventoryLevel/page.mdx": "2024-09-17T00:10:58.487Z",
|
||||
"references/types/HttpTypes/interfaces/types.HttpTypes.BaseAddress/page.mdx": "2024-09-03T00:10:55.003Z",
|
||||
@@ -2290,7 +2290,7 @@ export const generatedEditDates = {
|
||||
"app/commerce-modules/sales-channel/links-to-other-modules/page.mdx": "2024-10-15T14:25:29.097Z",
|
||||
"app/commerce-modules/stock-location/links-to-other-modules/page.mdx": "2024-10-15T14:33:11.483Z",
|
||||
"app/commerce-modules/store/links-to-other-modules/page.mdx": "2024-06-26T07:19:49.931Z",
|
||||
"app/examples/page.mdx": "2024-10-15T12:19:18.820Z",
|
||||
"app/examples/page.mdx": "2024-10-16T15:47:38.345Z",
|
||||
"app/medusa-cli/commands/build/page.mdx": "2024-10-16T08:16:27.618Z",
|
||||
"app/js-sdk/page.mdx": "2024-10-16T12:12:34.512Z"
|
||||
}
|
||||
Reference in New Issue
Block a user