-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
#459None of the antiwork repos use shortest?2 comments · 2025-08-04#450Chromium refreshing0 comments · 2025-06-18#413Support for Playwright MCP1 comments · 2025-03-30#399After upgrading from 0.4.5 to 0.4.7 the cache is not reused2 comments · 2025-03-20#392Using undici to make Anthropic API accessible even behind a proxy0 comments · 2025-03-12#375QA agent3 comments · 2025-03-02#342Can Shortest be used with Rails via Importmap?1 comments · 2025-02-18#340Going from shortest -> scrappy playwright test code2 comments · 2025-02-12
Latest release
v0.4.9 v0.4.9 2025-04-01What'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