# Integration testing

Learn how to write integration tests for your Nuxt integration.

When writing integration tests, it is generally recommended to avoid relying on external services for faster and more reliable results.

The Nuxt SDK allows you to set up a custom endpoint so you can mock responses and test your integration without relying on our servers.

## Set a custom endpoint

You can run tests against a mock server by specifying a custom base endpoint URL in your Nuxt configuration:

```ts
export default defineNuxtConfig({
  modules: ['@croct/plug-nuxt'],
  croct: {
    appId: '00000000-0000-0000-0000-000000000000',
    baseEndpointUrl: 'http://localhost:3010',
  },
})
```

These are the endpoints you can mock:

| Path                   | Description                     |
| ---------------------- | ------------------------------- |
| `/client/web/cid`      | Endpoint for assigning a CID.   |
| `/client/web/evaluate` | Endpoint for query evaluation.  |
| `/client/web/track`    | Endpoint for tracking events.   |
| `/content`             | Endpoint for content retrieval. |

If you enable [test mode](/reference/sdk/nuxt/api/configuration#test-prop), you do not need to mock the `/client/web/track` endpoint, as the SDK replaces the transport layer with a fake one that simulates successful calls.

## Create a mock server

[Mockoon](https://mockoon.com) is a free and open-source tool for quickly mocking APIs and services. You can define rules to mock different responses based on request parameters, which is perfect for testing different slots and query results.

To get started, install the [Mockoon CLI](https://mockoon.com/cli/):

```bash
npm install -g @mockoon/cli
```

Then, create a configuration file named `croct.json` with your mock rules. The easiest way to do this is to use the [Mockoon desktop app](https://mockoon.com/download/), which generates a configuration file for you.

> **Response body**
>
> We recommend using the body from an actual content or query evaluation response to ensure that it matches the real one.

Lastly, run the following command to start the mock server:

```bash
mockoon start --config croct.json
```

After starting the mock server, accessing your application should return the mocked content and query results.
