antiwork /shortest

QA via natural language AI tests

★ 5,699⑂ 340👁 31⑃ 283● 0▤ 12
TypeScriptMITCreated 2024-09-18shortest.com
TA的项目
下载:v0.4.9v0.4.9 ↓0.4.92025-04-01
-1
日增长
5,699
stars
340
forks
31
watchers
283
prs
0
issues
12
releases

README

Shortest

AI-powered natural language end-to-end testing framework.


Your browser does not support the video tag.


 Features

- Natural language E2E testing framework
- AI-powered test execution using Anthropic Claude API
- Built on Playwright
- GitHub integration with 2FA support
- Email validation with Mailosaur

 Using Shortest in your project

If helpful, here's a short video!

 Installation

Use the shortest init command to streamline the setup process in a new or existing project.

The shortest init command will:

sh
npx @antiwork/shortest init


This will:

- Automatically install the @antiwork/shortest package as a dev dependency if it is not already installed
- Create a default shortest.config.ts file with boilerplate configuration
- Generate a .env.local file (unless present) with placeholders for required environment variables, such as ANTHROPIC_API_KEY
- Add .env.local and .shortest/ to .gitignore

 Quick start

1. Determine your test entry and add your Anthropic API key in config file: shortest.config.ts

typescript
import type { ShortestConfig } from "@antiwork/shortest";

export default {
  headless: false,
  baseUrl: "http://localhost:3000",
  browser: {
    contextOptions: {
      ignoreHTTPSErrors: true
    },
  },
  testPattern: "/.test.ts",
  ai: {
    provider: "anthropic",
  },
} satisfies ShortestConfig;

The Anthropic API key defaults to SHORTEST_ANTHROPIC_API_KEY / ANTHROPIC_API_KEY environment variables. Can be overwritten via ai.config.apiKey.

Optionally, you can configure browser behavior using the browser.contextOptions property in your configuration file. This allows you to pass custom Playwright browser context options.

2. Create test files using the pattern specified in the config: app/login.test.ts

typescript
import { shortest } from "@antiwork/shortest";

shortest("Login to the app using email and password", {
  username: process.env.GITHUB_USERNAME,
  password: process.env.GITHUB_PASSWORD,
});


 Using callback functions

You can also use callback functions to add additional assertions and other logic. AI will execute the callback function after the test
execution in browser is completed.

typescript
import { shortest } from "@antiwork/shortest";
import { db } from "@/lib/db/drizzle";
import { users } from "@/lib/db/schema";
import { eq } from "drizzle-orm";

shortest("Login to the app using username and password", {
  username: process.env.USERNAME,
  password: process.env.PASSWORD,
}).after(async ({ page }) = {
  // Get current user's clerk ID from the page
  const clerkId = await page.evaluate(() = {
    return window.localStorage.getItem("clerk-user");
  });

  if (!clerkId) {
    throw new Error("User not found in database");
  }

  // Query the database
  const [user] = await db
    .select()
    .from(users)
    .where(eq(users.clerkId, clerkId))
    .limit(1);

  expect(user).toBeDefined();
});


 Lifecycle hooks

You can use lifecycle hooks to run code before and after the test.

typescript
import 

Discussions

Latest release

v0.4.9 v0.4.9 2025-04-01
What's Changed
 chore(cli): release v0.4.8 by @rmarescu in https://github.com/antiwork/shortest/pull/405
 feat: add analyze command by @rmarescu in https://github.com/antiwork/shortest/pull/402
 feat: add plan command by @rmarescu in https://github.com/antiwork/shortest/pull/407
 feat: improve init experience by @rmarescu in https://github.com/antiwork/shortest/pull/412
 feat: add generate command by @rmarescu in https://github.com/antiwork/shortest/pull/410
 feat: add sample test file generation to init command by @rmarescu in https://github.com/antiwork/shortest/pull/411
 fix: update 

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON