1
0

cli-optimization.spec.js 953 B

1234567891011121314151617181920212223242526
  1. // @ts-check
  2. const { test, expect } = require("@playwright/test");
  3. test("optimized scripts run", async ({ page }) => {
  4. await page.goto("http://localhost:8989");
  5. // Expect the page to load the script after optimizations have been applied. The script
  6. // should add an editor to the page that shows a main function
  7. const main = page.locator("#main");
  8. await expect(main).toContainText("hi");
  9. // Expect the page to contain an image with the id "some_image"
  10. const image = page.locator("#some_image");
  11. await expect(image).toBeVisible();
  12. // Get the image src
  13. const src = await image.getAttribute("src");
  14. // Expect the page to contain an image with the id "some_image_with_the_same_url"
  15. const image2 = page.locator("#some_image_with_the_same_url");
  16. await expect(image2).toBeVisible();
  17. // Get the image src
  18. const src2 = await image2.getAttribute("src");
  19. // Expect the urls to be different
  20. expect(src).not.toEqual(src2);
  21. });