errors.ts 582 B

123456789101112131415161718
  1. import { expect, type Page } from "@playwright/test"
  2. export function trackPageErrors(page: Page) {
  3. const errors: string[] = []
  4. page.on("console", (message) => {
  5. if (message.type() === "error") errors.push(message.text())
  6. })
  7. page.on("pageerror", (error) => errors.push(error.stack ?? error.message))
  8. return errors
  9. }
  10. export function expectNoSmokeErrors(consoleErrors: string[], toastErrors: string[], forbiddenText: string[]) {
  11. expect({ consoleErrors, toastErrors, forbiddenText }).toEqual({
  12. consoleErrors: [],
  13. toastErrors: [],
  14. forbiddenText: [],
  15. })
  16. }