Skip to content

Commit

Permalink
docs: added note about test timeout (#10041)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser authored Nov 13, 2024
1 parent 5fec006 commit 2d469ba
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ medusaIntegrationTestRunner({
})
},
})

jest.setTimeout(60 * 1000)
```

You use the `medusaIntegrationTestRunner` to write your tests.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d469ba

Please sign in to comment.