Skip to content

Commit

Permalink
Add API tests for Login page
Browse files Browse the repository at this point in the history
  • Loading branch information
matttechwell committed Jan 14, 2025
1 parent 63dd2a0 commit 0423fad
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/api/api-test.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { test, expect } = require('@playwright/test');

test.describe('API Tests for Login Page', () => {
const baseURL = 'https://www.saucedemo.com/v1/';

test('Validate Login Page Response', async ({ request }) => {
const response = await request.get(baseURL);

// Validate status code
expect(response.status()).toBe(200);

// Validate Content-Type header
expect(response.headers()['content-type']).toContain('text/html');

// Validate specific content in the response
const responseBody = await response.text();
expect(responseBody).toContain('<title>Swag Labs</title>');
expect(responseBody).toContain('standard_user');
expect(responseBody).toContain('secret_sauce');
expect(responseBody).toContain('id="login_button_container"');
});
});

0 comments on commit 0423fad

Please sign in to comment.