---
title: "Test with Simile"
description: "Run Inttegro’s public API contract locally, exercise deterministic outcomes, and isolate integration-test state."
canonical: "https://studio.inttegro.dev/guides/test-with-simile"
format: inttegro-machine-docs/v1
language: "TypeScript"
sdk_version: "v15.0.0"
reader_profile: optional
reader_manifest: "https://studio.inttegro.dev/machine/typescript/readers/index.json"
reader_identification: "Optional: declare your client only if known and your current-session capabilities; use reader_manifest for supplemental recommendations."
preamble_estimated_tokens: 682
model_token_report: "https://studio.inttegro.dev/machine/token-report.json"
preamble_questions: 5
preamble_source: "general"
recommended_mcp_tools: ["get_integration_guide","check_integration_readiness","get_country_specifications"]
estimated_tokens: 3209
token_estimate_method: "utf8_bytes_divided_by_4"
---

## Machine preamble

**Summary:** Run Inttegro’s public API contract locally, exercise deterministic outcomes, and isolate integration-test state. This TypeScript representation uses the selected SDK's native names wherever Studio has a verified mapping.

### Five questions

#### Q1. When should the reader use Test with Simile?

Use this guide when implementing the complete business outcome rather than an isolated request.

#### Q2. What is authoritative on this page?

The guide owns the business sequence and verification logic. Its linked API references own the exact request, response, state, and error contracts.

#### Q3. What page-specific constraint matters most?

Keep the documented ordering, trust boundary, idempotency behavior, and authoritative read-after-write verification intact.

#### Q4. Can Inttegro MCP materially help with this task?

Yes, when the reader has an authenticated MCP connection and the task needs live context, guided planning, or a supported operation. The strongest matches are `get_integration_guide`, `check_integration_readiness`, `get_country_specifications`; their exact roles and boundaries are listed below.

#### Q5. How should the reader verify the answer and continue?

Use the guide’s explicit completion condition and verify the final resource through the documented lookup or lifecycle state; a successful redirect or accepted request may be intermediate. Continue with [Orders API](https://studio.inttegro.dev/machine/typescript/api/orders.md#create-an-order) and [Idempotent requests](https://studio.inttegro.dev/machine/typescript/api/idempotency.md) when those concerns enter scope.

### Recommended MCP assistance

Use these through an authenticated Inttegro MCP connection. This document remains the contract source.

- [`get_integration_guide`](https://studio.inttegro.dev/machine/typescript/inttegro-mcp/tools.md#get_integration_guide) — read-only integration guidance. Returns a focused implementation sequence and canonical Studio links for authentication, checkout, orders, catalog, messaging, idempotency, or testing.
- [`check_integration_readiness`](https://studio.inttegro.dev/machine/typescript/inttegro-mcp/tools.md#check_integration_readiness) — read-only integration guidance. Audits platform secret storage, server-runtime compatibility, idempotency, errors, state verification, checkout returns, and messaging consent without receiving source code or credentials.
- [`get_country_specifications`](https://studio.inttegro.dev/machine/typescript/inttegro-mcp/tools.md#get_country_specifications) — read; no mutation confirmation. Lists Commerce-supported countries, currencies, payment methods, payout schedules, and onboarding capabilities.

## Document content

# Test with Simile

Install Inttegro’s published Simfile, create a local application profile, and
run your integration against the emulator. This walkthrough covers public and
authenticated requests, exact failure scenarios, retries, and isolated test
state.

## Prerequisites

- A supported Simile installation from the [Simile downloads](https://os.inttegro.dev/simile/downloads)
- cURL or one of the server runtimes shown below
- An integration that can read its base URL and API key from environment variables

## Install the Inttegro Simfile

Install Simile with Homebrew:

```bash
brew install inttegro/tap/simile
```

On macOS or Linux, you can use the project installer instead:

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/inttegro/simile/HEAD/install.sh)"
```

Download the [published Inttegro contract bundle](https://github.com/inttegro/openapi/archive/refs/heads/master.tar.gz).
It contains the [Inttegro Simfile](https://raw.githubusercontent.com/inttegro/openapi/master/simile/Simfile),
its public HCL modules, and the API contract that the Simfile references.
Extract the published contract and `simile/` directory together:

```bash
mkdir -p inttegro-test-mode
cd inttegro-test-mode

curl -fsSL https://github.com/inttegro/openapi/archive/refs/heads/master.tar.gz \
  | tar -xzf - --strip-components=1 \
      openapi-master/commerce.yml \
      openapi-master/simile

cd simile
simile register
```

Registration compiles the OpenAPI contract and public HCL modules before
installing an immutable local revision. `simile register` discovers `./Simfile`
and reads its `inttegro` service name. For repeatable CI, download
`https://github.com/inttegro/openapi/archive/<commit>.tar.gz` and replace the
`openapi-master/` archive member prefix with `openapi-<commit>/`.

Create an application profile for your integration. The credential is
synthetic, stored locally, and valid only in this emulator:

```bash
simile setup inttegro \
  --profile checkout \
  --set name="Checkout development" \
  --use \
  --reporting off

simile profiles inttegro
simile profile inttegro checkout
```

Setup writes the generated `API_KEY`, `APPLICATION_ID`, and profile metadata to
the private environment file reported by `simile profile`. Keep that file out
of source control. `--reporting off` makes the local reporting choice explicit.

## Run the local API

Start the registered service in one terminal:

```bash
simile start inttegro
```

The published listener is `http://127.0.0.1:4242`. In another terminal, load
the setup-created environment. The file also sets `SIMILE_BASE_URL`:

```bash
set -a
. "${SIMILE_HOME:-$HOME/.simile}/profiles/inttegro/checkout.env"
set +a
```

The following example first calls the public country-specification operation,
then creates an authenticated, finalized order. The same payload and
idempotency key can be repeated safely.

**Call the local Inttegro API**

```typescript
const baseUrl = process.env.SIMILE_BASE_URL
const apiKey = process.env.API_KEY
if (!baseUrl || !apiKey) throw new Error('Load the Simile profile environment')

const countries = await fetch(`${baseUrl}/spec/countries`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: '{}',
})
if (!countries.ok) throw new Error(await countries.text())

const order = await fetch(`${baseUrl}/orders/create`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': 'simile-order-001',
  },
  body: JSON.stringify({
    request_meta: { idempotency_key: 'simile-order-001' },
    number: 'SIMILE-ORDER-001',
    finalize: true,
    execute_payment: false,
    customer_data: { name: 'Ama Mensah', email_address: 'ama@example.test' },
    line_items: [
      {
        type: 'product',
        product: {
          type: 'physical',
          name: 'Premium Cotton T-Shirt',
          quantity: 1,
          price: { currency: 'ghs', value: 20000 },
        },
      },
    ],
  }),
})
if (!order.ok) throw new Error(await order.text())
console.log(await order.json())
```

The order response has a generated `or_` identifier, the supplied order
number, a `requires_payment` status, and a GHS 200.00 total. Look it up through
[Look up an order](https://studio.inttegro.dev/machine/typescript/api/orders.md#lookup-an-order) to verify that later requests
observe the stored public snapshot.

## Exercise outcomes, retries, and state

Run application tests under Simile when you want the base URL and selected
profile injected automatically:

```bash
simile test inttegro --profile checkout -- ./scripts/integration-test
```

The child receives `SIMILE_BASE_URL`, `API_KEY`, `APPLICATION_ID`, and the
selected profile metadata. Simile owns the emulator for the test process,
returns the child’s exit status, and shuts the listener down afterward.

Use a named scenario for one documented result. This example makes refund
cancellation return the reviewed `409 refund_cannot_cancel` response:

```bash
simile test inttegro \
  --profile checkout \
  --scenario refund_cannot_cancel \
  -- ./scripts/integration-test refund-cannot-cancel
```

For lost-response recovery, use `order_response_lost_after_commit`. It commits
order creation, closes delivery before the response arrives, and lets the test
retry the same request with the same idempotency key. Reusing that key with a
changed body returns Inttegro’s documented idempotency error instead of creating
a second order.

Inspect the available scenarios and persisted causal history without printing
stored values:

```bash
simile describe service inttegro --verbose
simile state inttegro
```

Pass `--values` to `simile state` only in a controlled local or CI environment;
stored snapshots can contain customer data supplied by your tests.

## Report an inconsistency

Please report a contradiction when the emulator and Inttegro's documented or
observed public behavior disagree. Do not hide the mismatch behind test-only
branches or weaken an assertion to make the test pass. A small reproducible
report helps Inttegro correct the published contract or test behavior for every
integration.

The earlier `--reporting off` option disables automatic submission only. You
can still prepare, inspect, and explicitly send a one-off report. Simile's
[issue-reporting workflow](https://os.inttegro.dev/simile/issue-reporting)
captures the operation, compiled contract, request, seed, and selected controls
in a reproduction bundle; verifies the failure; and stores the report locally
for review before anything is sent.

If you want Simile to report reproducible internal emulator failures while the
service or supervised tests run, opt in for this profile and provide an address
where Inttegro can ask follow-up questions:

```bash
simile reporting inttegro --profile checkout
simile reporting inttegro \
  --profile checkout \
  --mode automatic \
  --contact developer@example.com
```

Automatic reporting remains profile-scoped and can be withdrawn at any time:

```bash
simile reporting inttegro --profile checkout --mode off
```

For a mismatch you observe yourself, follow the manual workflow to capture the
smallest failing request, prepare a report with what you expected and what
happened, inspect the saved `report.json` and reproduction bundle, and then use
`simile report REPORT_ID --send --contact you@example.com`. Replace the example
address with one you control. Use synthetic profile credentials and test data;
never attach production keys, secrets, or customer records.

## Isolate or reset state

Set `SIMILE_HOME` before registration to choose the state boundary. A stable
directory preserves profiles and declared resource state across runs:

```bash
export SIMILE_HOME="$PWD/.simile-inttegro"
```

Give each CI job or parallel worker a fresh directory. To reset one named local
service, stop it, remove that registration and its service state, then register
and set it up again:

```bash
simile remove inttegro --confirm inttegro
simile register
simile setup inttegro --profile checkout --set name="Checkout development" --use --reporting off
```

Run reset commands from the downloaded `simile/` directory so `simile register`
can find `./Simfile`. Review the [testing boundary](https://studio.inttegro.dev/machine/typescript/api/testing.md#know-what-requires-another-test-boundary)
before deciding which checks still require deployed-application or
production-readiness verification.

## Related resources

- [Simile documentation](https://os.inttegro.dev/simile) - CLI lifecycle, profiles, scenarios, and current limits
- [Report an issue with Simile](https://os.inttegro.dev/simile/issue-reporting) - Capture, review, and submit a reproducible inconsistency
- [Published Inttegro Simfile](https://raw.githubusercontent.com/inttegro/openapi/master/simile/Simfile) - Downloadable local test-mode entrypoint
- [Idempotent requests](https://studio.inttegro.dev/machine/typescript/api/idempotency.md) - Stable retry keys and conflict behavior
- [Orders API](https://studio.inttegro.dev/machine/typescript/api/orders.md#create-an-order) - Complete create-order contract
