Tusk Drift is in private preview and only supports Node.js backends at the moment. Reach out to support@usetusk.ai if interested.

Prerequisites

  • Repo with Node.js backend
  • Tusk account with a Team Plan or above
  • Optional but recommended: Dev or staging environment

Overview

Tusk Drift helps you test your APIs with hundreds of realistic edge cases without requiring developers to manually write or maintain API tests. The Drift SDK automatically records real-world traffic on a service on staging or production environments. When a PR is raised, Drift automatically replays inbound API calls, while mocking outbound calls, to find deviations between the returned output and expected output. Drift will classify deviations as “intended” or “unintended” based on the business logic in the PR, Jira/Linear ticket, and code context. Resolve unintended deviations to prevent regressions from slipping through to production.

Setup

1

Install Tusk CLI

Install the Tusk CLI using Homebrew.
2

Navigate to app directory

cd into your application directory.
3

Initialize Tusk configuration

Run tusk init to set up your project:
  • CLI analyzes project to check if your app is supported
  • CLI creates configuration file
    • You’ll input: service name, port, start command, readiness check
    • This sets defaults for test execution and recording parameters
4

Install Drift SDK

Install the Drift SDK in your service via CLI.
5

Configure the SDK

Set up the SDK by simply adding the following code snippet to your server.ts file.
    // 1. Import
    import express from 'express';
+   import { TuskDrift } from '@tusk/drift-sdk';

    const app = express();

    // 2. Initialize
+   const tusk = new TuskDrift({ 
+       apiKey: process.env.TUSK_API_KEY,
+       environment: 'development'
+   });

    app.use(express.json());

    // 3. Mark app as ready
    app.listen(3000, () => {
+       tusk.markAppAsReady();
        console.log('Server running on port 3000');
    });
6

Start service in record mode

Start your service in record mode to begin capturing API traffic.
7

Make a request

Make a request to your service that has the SDK enabled. Your trace gets recorded automatically.
8

Replay trace via CLI

Use the CLI to replay the recorded trace and verify that tests are being run.
9

Create PR with Tusk setup

Create a PR with the Tusk SDK installation and configuration file. We also recommend adding a GitHub workflow to run against these recordings in CI.

FAQ