fullstack.spec.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // @ts-check
  2. const { test, expect } = require('@playwright/test');
  3. test('button click', async ({ page }) => {
  4. await page.goto('http://localhost:3333');
  5. await page.waitForTimeout(1000);
  6. // Expect the page to contain the counter text.
  7. const main = page.locator('#main');
  8. await expect(main).toContainText('hello axum! 12345');
  9. // Click the increment button.
  10. let button = page.locator('button.increment-button');
  11. await button.click();
  12. // Expect the page to contain the updated counter text.
  13. await expect(main).toContainText('hello axum! 12346');
  14. });
  15. test('fullstack communication', async ({ page }) => {
  16. await page.goto('http://localhost:3333');
  17. await page.waitForTimeout(1000);
  18. // Expect the page to contain the counter text.
  19. const main = page.locator('#main');
  20. await expect(main).toContainText('Server said: ...');
  21. // Click the increment button.
  22. let button = page.locator('button.server-button');
  23. await button.click();
  24. // Expect the page to contain the updated counter text.
  25. await expect(main).toContainText('Server said: Hello from the server!');
  26. });