fullstack.spec.js 1.0 KB

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