Skip to content

Commit

Permalink
test: add teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Dec 19, 2024
1 parent abe0d3b commit ec537bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default defineConfig({
{
name: "Setup",
testMatch: "*.setup.*",
teardown: "Teardown",
use: {
storageState: STORAGE_STATE,
},
Expand All @@ -50,6 +51,13 @@ export default defineConfig({
storageState: STORAGE_STATE,
},
},
{
name: "Teardown",
testMatch: "*.teardown.*",
use: {
storageState: STORAGE_STATE,
},
},
],
webServer: [
{
Expand Down
12 changes: 12 additions & 0 deletions tests/global.teardown.ts
Original file line number Diff line number Diff line change
@@ -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 });
});

0 comments on commit ec537bd

Please sign in to comment.