From b2be148ef151560453aabd78220e972a697e588b Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 12 Nov 2024 10:20:15 +0200 Subject: [PATCH] docs: added note about test timeout --- .../integration-tests/api-routes/page.mdx | 11 +++++++++++ .../testing-tools/integration-tests/page.mdx | 11 +++++++++++ .../integration-tests/workflows/page.mdx | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/api-routes/page.mdx b/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/api-routes/page.mdx index 80fc794f04ca7..d3808312b5637 100644 --- a/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/api-routes/page.mdx +++ b/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/api-routes/page.mdx @@ -60,6 +60,8 @@ medusaIntegrationTestRunner({ }) }, }) + +jest.setTimeout(60 * 1000) ``` You use the `medusaIntegrationTestRunner` to write your tests. @@ -86,6 +88,15 @@ If you don't have a `test:integration` script in `package.json`, refer to the [M This runs your Medusa application and runs the tests available under the `src/integrations/http` directory. +### Jest Timeout + +Since your tests connect to the database and perform actions that require more time than the typical tests, make sure to increase the timeout in your test: + +```ts title="integration-tests/http/custom-routes.spec.ts" +// in your test's file +jest.setTimeout(60 * 1000) +``` + --- ## Test a POST API Route diff --git a/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/page.mdx b/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/page.mdx index 4a4d5330f6785..c8b0dfe5cd633 100644 --- a/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/page.mdx +++ b/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/page.mdx @@ -36,6 +36,8 @@ medusaIntegrationTestRunner({ // TODO write tests... }, }) + +jest.setTimeout(60 * 1000) ``` The `medusaIntegrationTestRunner` function accepts an object as a parameter. The object has a required property `testSuite`. @@ -50,6 +52,15 @@ The `medusaIntegrationTestRunner` function accepts an object as a parameter. The The tests in the `testSuite` function are written using [Jest](https://jestjs.io/). +### Jest Timeout + +Since your tests connect to the database and perform actions that require more time than the typical tests, make sure to increase the timeout in your test: + +```ts title="integration-tests/http/test.spec.ts" +// in your test's file +jest.setTimeout(60 * 1000) +``` + --- ### Run Tests diff --git a/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/workflows/page.mdx b/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/workflows/page.mdx index 0aec5b27c1565..d2c52d78ddad7 100644 --- a/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/workflows/page.mdx +++ b/www/apps/book/app/learn/debugging-and-testing/testing-tools/integration-tests/workflows/page.mdx @@ -61,10 +61,21 @@ medusaIntegrationTestRunner({ }) }, }) + +jest.setTimeout(60 * 1000) ``` You use the `medusaIntegrationTestRunner` to write an integration test for the workflow. The test pases if the workflow returns the string `"Hello, World!"`. +### Jest Timeout + +Since your tests connect to the database and perform actions that require more time than the typical tests, make sure to increase the timeout in your test: + +```ts title="integration-tests/http/custom-routes.spec.ts" +// in your test's file +jest.setTimeout(60 * 1000) +``` + --- ## Run Test