This Playwright API Testing Framework is designed to automate API testing scenarios using Playwright in a TypeScript environment. The framework showcases how to leverage Playwright for comprehensive testing coverage, including interactions with web storage, handling authentication, and performing operations against both Conduit's real-world application and GitHub's APIs.
- Conduit Application Testing: Automate user authentication, article publication, and verification through both API and UI layers.
- GitHub API Integration: Perform operations like creating repositories, issues, and handling repository deletion through GitHub's API.
- Authentication Handling: Manage authentication states for testing by utilizing JSON files and environment variables for storing sensitive data.
- Cross-Origin Handling: Demonstrates handling of local storage across different origins.
/.auth/
- Contains JSON files (api-user.json
,ui-user.json
) for storing/generating authentication tokens and states./controller/
- Houses theConduitController
andGitHubController
for managing API requests./src/pages/
- Contains page objects for UI interactions, likeConduitPage
./src/tests/
- Includes test specifications (conduit.api.spec.ts
,github.api.spec.ts
) and setup files for API and UI authentication states.
- Node.js
- A valid Conduit account and a GitHub account with generated personal access tokens.
- Clone the repository to your local machine.
- Install the required dependencies by running
npm install
in the project root directory. - Configure the
.env
file at the root of your project with your Conduit and GitHub credentials:
CONDUIT_EMAIL=<your_email>
CONDUIT_PASSWORD=<your_password>
GITHUB_TOKEN=<your_github_token>
## Getting Started
### Installation
1. Clone the repository to your local machine:
```bash
git clone <repo url>
- Clone the repository to your local machine:
cd playwright-api-testing
-
Modify .auth/api-user.json or .auth/ui-user.json files to include your actual Conduit JWT tokens (this must be manually extracted from Chrome dev console).
-
Running Tests To run Conduit related tests, execute npm run test-conduit. To perform GitHub API tests, use npm run test-github. To generate and view an allure report of the test run, execute npm run allure.