Browse Source

fix: update Playwright config and teardown error handling (#5383)

- Remove teardown dependency on e2e tests to fix execution order
- Move server cleanup before file operations in teardown
- Add proper error handling and logging for cleanup operations
Bee 5 months ago
parent
commit
f2101e375f
2 changed files with 5 additions and 5 deletions
  1. 0 1
      playwright.config.ts
  2. 5 4
      src/test/e2e/utils/global.teardown.ts

+ 0 - 1
playwright.config.ts

@@ -26,7 +26,6 @@ export default defineConfig({
 		{
 			name: "cleanup test environment",
 			testMatch: /global\.teardown\.ts/,
-			dependencies: ["e2e tests"],
 		},
 	],
 })

+ 5 - 4
src/test/e2e/utils/global.teardown.ts

@@ -5,9 +5,12 @@ import { ClineApiServerMock } from "../fixtures/server"
 import { getResultsDir, rmForRetries } from "./helpers"
 
 teardown("cleanup test environment", async () => {
-	const assetsDir = getResultsDir()
+	await ClineApiServerMock.stopGlobalServer()
+		.then(() => console.log("ClineApiServerMock stopped successfully."))
+		.catch((error) => console.error("Error stopping ClineApiServerMock:", error))
 
 	try {
+		const assetsDir = getResultsDir()
 		const results = await fs.readdir(assetsDir, { withFileTypes: true })
 		await Promise.all(
 			results
@@ -22,12 +25,10 @@ teardown("cleanup test environment", async () => {
 					}
 				}),
 		)
-		await ClineApiServerMock.stopGlobalServer()
-		console.log("ClineApiServerMock stopped successfully.")
 	} catch (error) {
 		// Silently handle case where assets directory doesn't exist
 		if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
-			throw error
+			console.error("Error during cleanup:", error)
 		}
 	}
 })