Skip to content

Commit 0d67715

Browse files
authored
fix playwright autoconfig (fixes #1319, via #1321)
1 parent edd37f3 commit 0d67715

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

packages/allure-js-commons/src/sdk/runtime/runtime.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,14 @@ export const getGlobalTestRuntimeWithAutoconfig = (): TestRuntime | Promise<Test
2828
return testRuntime() ?? noopRuntime;
2929
}
3030

31-
if ("_playwrightInstance" in globalThis) {
32-
try {
33-
// protection from bundlers tree-shaking visiting (webpack, rollup)
34-
// @ts-ignore
35-
// eslint-disable-next-line no-eval
36-
return (0, eval)("(() => import('allure-playwright/autoconfig'))()").then(() => {
37-
return getGlobalTestRuntimeFunction()?.() ?? noopRuntime;
38-
});
39-
} catch (err) {
40-
// eslint-disable-next-line no-console
41-
console.log("can't execute allure-playwright/autoconfig", err);
42-
return noopRuntime;
43-
}
44-
}
31+
try {
32+
// protection from bundlers tree-shaking visiting (webpack, rollup)
33+
// @ts-ignore
34+
// eslint-disable-next-line no-eval
35+
return (0, eval)("(() => import('allure-playwright/autoconfig'))()").then(() => {
36+
return getGlobalTestRuntimeFunction()?.() ?? noopRuntime;
37+
});
38+
} catch (ignored) {}
4539

4640
return noopRuntime;
4741
};
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import { test } from "@playwright/test";
12
import { setGlobalTestRuntime } from "allure-js-commons/sdk/runtime";
23
import { AllurePlaywrightTestRuntime } from "./runtime.js";
34

4-
setGlobalTestRuntime(new AllurePlaywrightTestRuntime());
5+
if (test.info()) {
6+
setGlobalTestRuntime(new AllurePlaywrightTestRuntime());
7+
}

0 commit comments

Comments
 (0)