fullstack.spec.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. // Expect the title to contain the counter text.
  10. await expect(page).toHaveTitle("hello axum! 12345");
  11. // Click the increment button.
  12. let button = page.locator("button.increment-button");
  13. await button.click();
  14. // Expect the page to contain the updated counter text.
  15. await expect(main).toContainText("hello axum! 12346");
  16. // Expect the title to contain the updated counter text.
  17. await expect(page).toHaveTitle("hello axum! 12346");
  18. });
  19. test("fullstack communication", async ({ page }) => {
  20. await page.goto("http://localhost:3333");
  21. await page.waitForTimeout(1000);
  22. // Expect the page to contain the counter text.
  23. const main = page.locator("#main");
  24. await expect(main).toContainText("Server said: ...");
  25. // Click the increment button.
  26. let button = page.locator("button.server-button");
  27. await button.click();
  28. // Expect the page to contain the updated counter text.
  29. await expect(main).toContainText("Server said: Hello from the server!");
  30. });