SDK Reference
Installation
Install and configure the Midstream Playwright SDK
Installation
Get started with Midstream in your Playwright project.
Prerequisites
- Node.js 18+
- Playwright 1.40+
- A GitHub repository
Install the Package
npm install @midstream/playwright
Or with other package managers:
# pnpm
pnpm add @midstream/playwright
# yarn
yarn add @midstream/playwright
Configure Your Project
Create a midstream.json file in your project root:
{
"install": "npm install",
"start": "npm start",
"test": "npx playwright test {{file}} -g {{grep}}"
}
This tells Midstream how to run your application and tests in the demo environment.
Add to Your Tests
Import and use the checkpoint function in your Playwright tests:
import { midstreamCheckpoint } from "@midstream/playwright";
import { test, expect } from "@playwright/test";
test("user can complete checkout", async ({ page }) => {
await page.goto("/products");
await page.click('[data-testid="add-to-cart"]');
// Create a checkpoint - this becomes a shareable demo
await midstreamCheckpoint(page, "cart-with-item", {
name: "Shopping Cart",
description: "Cart with one item added",
});
await page.click('[data-testid="checkout"]');
await expect(page.locator("h1")).toContainText("Checkout");
});
Next Steps
- Learn about the Checkpoint API
- Configure advanced options