Skip to main content
The SDK provides programmatic APIs that let you build, deploy, install, and uninstall your app from test code. Combined with Vitest and the typed API clients, you can write integration tests that verify your app works end-to-end against a real Twenty server.

Using npm packages

You can install and use any npm package in your app. Both logic functions and front components are bundled with esbuild, which inlines all dependencies into the output — no node_modules are needed at runtime.

Installing a package

Then import it in your code:
src/logic-functions/fetch-data.ts
The same works for front components:
src/front-components/chart.tsx

How bundling works

The build step uses esbuild to produce a single self-contained file per logic function and per front component. All imported packages are inlined into the bundle. Logic functions run in a Node.js environment. Node built-in modules (fs, path, crypto, http, etc.) are available and do not need to be installed. Front components run in a Web Worker. Node built-in modules are not available — only browser APIs and npm packages that work in a browser environment. Both environments have twenty-client-sdk/core and twenty-client-sdk/metadata available as pre-provided modules — these are not bundled but resolved at runtime by the server.

Setup

The scaffolded app already includes Vitest. If you set it up manually, install the dependencies:
Create a vitest.config.ts at the root of your app:
vitest.config.ts
Create a global setup file that verifies the server is reachable, writes a test config for the SDK (~/.twenty/config.test.json), and syncs the app before tests run:
src/__tests__/global-setup.ts

Programmatic SDK APIs

The twenty-sdk/cli subpath exports functions you can call directly from test code: Each function returns a result object with success: boolean and either data or error.

Writing an integration test

Here is a full example that builds, deploys, and installs the app, then verifies it appears in the workspace:
src/__tests__/app-install.integration-test.ts

Running tests

Make sure your local Twenty server is running, then:
Or in watch mode during development:

Type checking

You can also run type checking on your app without running tests:
This runs tsc --noEmit against your app’s tsconfig.json and reports any type errors. Scaffolded apps also ship a yarn typecheck script that covers test files too (tsconfig.spec.json).

CI with GitHub Actions

The scaffolder generates a ready-to-use workflow at .github/workflows/ci.yml. On every push to main and every pull request, it spawns an ephemeral Twenty server in the runner (via the twentyhq/twenty/.github/actions/spawn-twenty-app-dev-test action), then runs yarn lint, yarn typecheck, yarn test:unit, and yarn test with TWENTY_API_URL / TWENTY_API_KEY pointing at that server. No secrets are required, and you can pin the server version via the TWENTY_VERSION env at the top of the workflow. See Publishing → Automated CI/CD for a full walkthrough of the three scaffolded workflows (ci.yml, the cd.yml deploy pipeline, and publish.yml for npm publishing).