From 907ce826c34a4023d354822c7bbb45399f78a1ae Mon Sep 17 00:00:00 2001 From: makinzm Date: Sun, 22 Dec 2024 18:27:23 +0900 Subject: [PATCH] fix: delete test user directory --- tests/e2e/content_script.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/e2e/content_script.spec.ts b/tests/e2e/content_script.spec.ts index 9393dac..1310bf6 100644 --- a/tests/e2e/content_script.spec.ts +++ b/tests/e2e/content_script.spec.ts @@ -1,6 +1,11 @@ // tests/e2e/content_script.spec.ts import { test, expect, chromium } from "@playwright/test"; import * as path from "path"; +import * as fs from "fs"; +import * as util from "util"; + +// 非同期でディレクトリを削除するためのユーティリティ +const rmdir = util.promisify(fs.rmdir); test("Content script should create a button when selecting 'World' text if domein is included, then fail to create if domain is excluded", async () => { // 拡張機能 dist フォルダへのパス @@ -97,3 +102,12 @@ test("Content script should create a button when selecting 'World' text if domei await context.close(); }); + +// テスト後にユーザーデータディレクトリを削除 +test.afterAll(async () => { + const userDataDir = path.resolve(__dirname, "../../.tmp-user-data"); + if (fs.existsSync(userDataDir)) { + await rmdir(userDataDir, { recursive: true }); + console.log("Removed user data directory:", userDataDir); + } +})