Skip to content

Latest commit

 

History

History
120 lines (83 loc) · 2.57 KB

File metadata and controls

120 lines (83 loc) · 2.57 KB

Specmatic Playwright TypeScript Tests

This project contains automated end-to-end tests using Playwright and TypeScript, designed to work with Specmatic for contract-driven testing.

Project Structure

  • 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.

Getting Started

Prerequisites

Installation

Install dependencies:

npm install
# or
yarn install

Installing Playwright agents in VS Code:

npx playwright init-agents --loop=vscode

Running Tests

To run all Playwright end-to-end tests.

npx playwright test

To run a specific test file:

npx playwright test tests/example.spec.ts

Runs the tests in a specific file.

  npx playwright test example

Starts the interactive UI mode.

  npx playwright test --ui

Runs the tests only on Desktop Chrome.

  npx playwright test --project=chromium

Runs the tests in debug mode.

  npx playwright test --debug

Auto generate tests with Codegen.

  npx playwright codegen

Running Tests by Tag

To run tests with a specific tag (e.g., @dashboard-overview), use the following npm script:

npm run test:tag -- @dashboard-overview

Note: 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 -- @admin

To run tests with a specific tag using npx (no npm script required):

npx playwright test --grep @dashboard-overview

You can use any tag, for example:

npx playwright test --grep @admin

Viewing Reports

After running tests, view the HTML report:

npx playwright show-report

The report will open in your default browser.

Integrating with Specmatic

This project is intended to be used alongside Specmatic for contract-driven testing. Refer to the Specmatic documentation for integration steps and best practices.

Useful Links

License

MIT