This project contains automated end-to-end tests using Playwright and TypeScript, designed to work with Specmatic for contract-driven testing.
specs/- Contains Playwright test specs (e.g.,example.spec.ts).playwright.config.ts- Playwright configuration file.package.json- Project dependencies and scripts.playwright-report/- Generated Playwright HTML reports.test-results/- Raw test result files.
Install dependencies:
npm install
# or
yarn installnpx playwright init-agents --loop=vscodeThis repo includes a Codex skill for working on these Playwright tests:
$specmatic-studio-playwright
Use it explicitly in a prompt when you want Codex to follow this repo's testing, page-object, screenshot, and visual-validation conventions.
Example prompts:
Use $specmatic-studio-playwright to add a new OpenAPI test that saves a valid spec and verifies the success flow.
Use $specmatic-studio-playwright to refactor screenshot handling so Applitools validation only runs when explicitly requested.
Use $specmatic-studio-playwright to add an @eyes visual test for the example generation flow.
Use $specmatic-studio-playwright to create a page-object method for opening the right sidebar and asserting a process bar is visible.
Use $specmatic-studio-playwright to review this Playwright spec and align it with the repo's page-object and screenshot conventions.
You can also ask naturally without naming the skill, but mentioning
$specmatic-studio-playwright makes the intended guidance much more reliable.
To run all Playwright end-to-end tests.
npx playwright testTo run a specific test file:
npx playwright test tests/example.spec.tsRuns the tests in a specific file.
npx playwright test exampleStarts the interactive UI mode.
npx playwright test --uiRuns the tests only on Desktop Chrome.
npx playwright test --project=chromiumRuns the tests in debug mode.
npx playwright test --debugAuto generate tests with Codegen.
npx playwright codegenIf SPECMATIC_STUDIO_JAR_URL is set, the test run will start Specmatic
Studio from that jar instead of using Docker.
SPECMATIC_STUDIO_JAR_URL="https://repo.example.com/executable-all-1.8.1.jar" \
SPECMATIC_STUDIO_JAR_OVERWRITE=false \
npx playwright testTo dry-run jar resolution without downloading or starting Specmatic Studio:
SPECMATIC_STUDIO_JAR_URL=LATEST node utils/specmatic-studio-runtime.js resolveSPECMATIC_STUDIO_JAR_URL=LATEST_SNAPSHOT node utils/specmatic-studio-runtime.js resolveSPECMATIC_STUDIO_JAR_URL=LATEST_RELEASE node utils/specmatic-studio-runtime.js resolveWhat happens in jar mode:
- The jar is downloaded into the repo-local
temp/directory and reused on later runs. - Set
SPECMATIC_STUDIO_JAR_OVERWRITE=trueto force a fresh download. SPECMATIC_STUDIO_JAR_URL=LATEST_SNAPSHOTresolves the newest snapshot jar from the Specmatic snapshots repository.SPECMATIC_STUDIO_JAR_URL=LATEST_RELEASEresolves the newest release jar from the Specmatic releases repository.SPECMATIC_STUDIO_JAR_URL=LATESTresolves the newest available jar across the Specmatic snapshot and release repositories.- The test run starts
java -jar <downloaded-jar> studio --port 9000. - Playwright uses
http://127.0.0.1:9000/_specmatic/studioas theBASE_URLfor the run. - If Java is not installed or
javais not available onPATH, the run fails with a clear error. - If port
9000is already in use, the run fails with a clear error. - Global teardown stops the Java process after the tests complete.
To run tests with a specific tag (e.g., @dashboard-overview), use the following npm script:
npm run test:tag -- @dashboard-overviewNote: The
--is required to forward the tag argument to Playwright. This will run only the tests annotated with the specified tag.
You can also use any other tag, such as @admin, in the same way:
npm run test:tag -- @adminTo run tests with a specific tag using npx (no npm script required):
npx playwright test --grep @dashboard-overviewYou can use any tag, for example:
npx playwright test --grep @adminAfter running tests, view the HTML report:
npx playwright show-reportThe report will open in your default browser.
This project is intended to be used alongside Specmatic for contract-driven testing. Refer to the Specmatic documentation for integration steps and best practices.
MIT