1
0

web-routing.spec.js 978 B

1234567891011121314151617181920212223242526272829303132
  1. // @ts-check
  2. const { test, expect } = require("@playwright/test");
  3. test("redirect", async ({ page }) => {
  4. // Going to the root url should redirect to /other.
  5. await page.goto("http://localhost:2020");
  6. // Expect the page to the text Other
  7. const main = page.locator("#other");
  8. await expect(main).toContainText("Other");
  9. // Expect the url to be /other
  10. await expect(page).toHaveURL("http://localhost:2020/other");
  11. });
  12. test("links", async ({ page }) => {
  13. await page.goto("http://localhost:2020/other");
  14. // Expect clicking the link to /other/123 to navigate to /other/123
  15. const link = page.locator("a[href='/other/123']");
  16. await link.click();
  17. await expect(page).toHaveURL("http://localhost:2020/other/123");
  18. });
  19. test("fallback", async ({ page }) => {
  20. await page.goto("http://localhost:2020/my/404/route");
  21. // Expect the page to contain the text Fallback
  22. const main = page.locator("#not-found");
  23. await expect(main).toContainText("NotFound");
  24. });