From a7fbe01baf765c243ce5fe8ff911a9e4224c35e5 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Fri, 2 Aug 2024 13:59:35 -0230 Subject: [PATCH] test: Fix flakey Playwright tests due to static assets (#13199) 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));