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]: Errors in the playwright config aren't clear when working in test files #34305

Closed
Stono opened this issue Jan 11, 2025 · 5 comments
Closed

Comments

@Stono
Copy link

Stono commented Jan 11, 2025

Version

1.48.2

Steps to reproduce

Hi,
If there is an error in your platwright.config.ts for whatever reason (in my case i messed up an import), it's kind of a transparent failure in vscode.

When all is well: (notice the run icon):
Image

When there's an error in the playwright server (notice no icon):
Image

I can't find any obvious way of debugging this, typically I'd expect Playwright to appear in the Output window, but it does not:

Image

I swear this used to be there, so is this a bug?

The nasty way this manifests for me is because we require some environment variables to be set i our playwright config file, and if the user forgets to set them, everything is just silently broken and i get loads of "playwright doesn't work in vscode" type questions.

Expected behavior

For it to be clear that the reason the test run icon isn't available is because playwright failed to load, and the reason is X

Actual behavior

As above

Additional context

No response

Environment

node 22
@pavelfeldman
Copy link
Member

Config problems should be listed in the Problems tab of VS Code

@Stono
Copy link
Author

Stono commented Jan 13, 2025

It's probably down to complexity of my setup but that isn't the case here. So for example our "apps" have this as their playwright.config.ts:

import { generatePlaywrightConfig } from '@at/platform-checks'

export default generatePlaywrightConfig()

We do this because we publish generatePlaywrightConfig in a shared module (@at/platform-checks) that ensures all our apps are setup for playwright in the same way, and critically, it also had some coded that loaded/setup environment variables from the local apps config.

So now if you imagine that function, crudely, doing:

export const generatePlaywrightConfig = async (): Promise<PlaywrightTestConfig> => {
  const someVar = process.env.someVar
  if (typeof someVar === 'undefined') { throw new Error('You haven't set your environment variables!') }
  ...
}

This would cause an error if they haven't set someVar. And that error can be seen if you do npx playwright test:

Image

However the way this manifests is a silent failure in vscode.

Image

@yury-s
Copy link
Member

yury-s commented Jan 13, 2025

@Stono would it be possible for you to share a reduced example where this happens? I that the error is thrown from a file outside of node modules, which is likely important. I've tried to recreate a repro based on your description but the error is always shown in the Problems view for me.

@Stono
Copy link
Author

Stono commented Jan 13, 2025

Sure thing. Will do tomorrow!

@yury-s
Copy link
Member

yury-s commented Jan 17, 2025

We need more information to act on this report. Please file a new one with a repro and link to this issue when you get back to it!

@yury-s yury-s closed this as completed Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants