diff --git a/playwright.config.ts b/playwright.config.ts index 5aed4a1..c9ae9a8 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -28,6 +28,7 @@ export default defineConfig({ { name: "Setup", testMatch: "*.setup.*", + teardown: "Teardown", use: { storageState: STORAGE_STATE, }, @@ -50,6 +51,13 @@ export default defineConfig({ storageState: STORAGE_STATE, }, }, + { + name: "Teardown", + testMatch: "*.teardown.*", + use: { + storageState: STORAGE_STATE, + }, + }, ], webServer: [ { diff --git a/tests/global.teardown.ts b/tests/global.teardown.ts new file mode 100644 index 0000000..8f25b35 --- /dev/null +++ b/tests/global.teardown.ts @@ -0,0 +1,12 @@ +import { STORAGE_STATE } from "../playwright.config"; +import { test as teardown } from "./test"; + +teardown("delete repo", async ({ page, prismic }) => { + const cookies = await page.context().cookies(); + const repoName = cookies.find((c) => c.name === "repository-name")?.value; + if (!repoName) return; + const repo = prismic.getRepo(repoName); + await repo.delete(); + await page.context().clearCookies({ name: "repository-name" }); + await page.context().storageState({ path: STORAGE_STATE }); +});