Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] last line of globalTeardown output is cleared by line reporter #23875

Open
mxschmitt opened this issue Jun 23, 2023 · 1 comment
Open
Assignees
Labels
feature-test-runner Playwright test specific issues

Comments

@mxschmitt
Copy link
Member

Repro:

diff --git a/examples/todomvc/globalSetup.ts b/examples/todomvc/globalSetup.ts
new file mode 100644
index 000000000..0f80bb680
--- /dev/null
+++ b/examples/todomvc/globalSetup.ts
@@ -0,0 +1,3 @@
+export default () => {
+  console.log('\\n%%from-global-setup');
+}
\ No newline at end of file
diff --git a/examples/todomvc/globalTeardown.ts b/examples/todomvc/globalTeardown.ts
new file mode 100644
index 000000000..d9faa7d89
--- /dev/null
+++ b/examples/todomvc/globalTeardown.ts
@@ -0,0 +1,3 @@
+export default () => {
+  console.log('\\n%%from-global-teardown');
+}
\ No newline at end of file
diff --git a/examples/todomvc/playwright.config.ts b/examples/todomvc/playwright.config.ts
index 06e262f2f..14fc4606d 100644
--- a/examples/todomvc/playwright.config.ts
+++ b/examples/todomvc/playwright.config.ts
@@ -46,6 +46,9 @@ export default defineConfig({
     trace: 'on-first-retry',
   },
 
+  globalSetup: './globalSetup.ts',
+  globalTeardown: './globalTeardown.ts',
+
   /* Configure projects for major browsers */
   projects: [
     {
@@ -57,20 +60,6 @@ export default defineConfig({
       },
     },
 
-    {
-      name: 'firefox',
-      use: {
-        ...devices['Desktop Firefox'],
-      },
-    },
-
-    {
-      name: 'webkit',
-      use: {
-        ...devices['Desktop Safari'],
-      },
-    },
-
     /* Test against mobile viewports. */
     // {
     //   name: 'Mobile Chrome',

inside the examples/todomvc project: npx playwright test --reporter=html.

Expected: We see the console.log of global teardown.
Actual: We don't.

When setting this to true it works:

printsToStdio() {
return false;
}

@dgozman
Copy link
Contributor

dgozman commented Jun 27, 2023

This is because reporter (in this case, list reporter) is not aware of the terminal output produced by global teardown, and so this output is overridden with the test epilogue.

A solution would be to capture all output in the main process, but then all reporters should use a real output method instead of the captured one, which is not backwards compatible.

Running global setup/teardown in a separate process would also help, but we already do that for dependencies, so seems like not worth it.

@dgozman dgozman added feature-test-runner Playwright test specific issues and removed v1.36 labels Jun 27, 2023
@dgozman dgozman changed the title [BUG] globalTeardown does not get printed with html reporter [BUG] last line of globalTeardown output is cleared by line reporter Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-test-runner Playwright test specific issues
Projects
None yet
Development

No branches or pull requests

2 participants