From 80a3ec44460831e3ba7426e00a5e82267d837e66 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Fri, 2 Aug 2024 12:00:22 -0400 Subject: [PATCH] test: Fix flakey Playwright tests due to static assets Our playwright tests can be flakey caused by the build process when generating static assets. Even though we check if file exists before symlinking, it can at times fail because file already exists. I have not dug/thought about why this happens -- just catch/ignore and move on. Closes https://github.com/getsentry/sentry-javascript/issues/11902 --- .../browser-integration-tests/utils/staticAssets.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dev-packages/browser-integration-tests/utils/staticAssets.ts b/dev-packages/browser-integration-tests/utils/staticAssets.ts index e293bd65237c..4b13159c58a4 100644 --- a/dev-packages/browser-integration-tests/utils/staticAssets.ts +++ b/dev-packages/browser-integration-tests/utils/staticAssets.ts @@ -27,7 +27,16 @@ export function addStaticAssetSymlink(localOutPath: string, originalPath: string // Only copy files once if (!fs.existsSync(newPath)) { - fs.symlinkSync(originalPath, newPath); + try { + fs.symlinkSync(originalPath, newPath); + } catch (error) { + // There must be some race condition here as some of our tests flakey + // because the file already exists. Let's catch and ignore + // only ignore these kind of errors + if (!`${error}`.includes('file already exists')) { + throw error; + } + } } symlinkAsset(newPath, path.join(localOutPath, fileName));