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

passing variable from globalSetup to test suites #2238

Closed
4 tasks done
Madvinking opened this issue Oct 30, 2022 · 5 comments
Closed
4 tasks done

passing variable from globalSetup to test suites #2238

Madvinking opened this issue Oct 30, 2022 · 5 comments

Comments

@Madvinking
Copy link

Madvinking commented Oct 30, 2022

Clear and concise description of the problem

i would like to use a global puppeteer instance to run different test files on different puppeteer tabs.
so for that, I want to initialize a global puppeteer instance and pass It down to each test Suite
Unfortunately, the test files are different than the globalSetup file, so i can't attach it to the instance to the globalSetup file global.

Suggested solution

maybe have the ability to share the global variable between test files and globalsetup

Alternative

No response

Additional context

No response

Validations

@sheremet-va
Copy link
Member

I highly doubt we will do this, since each test file is isolated and you will need to run globalSetup again, which is just a setupFile, but it's still possible to have a single puppeteer instance and share some context. You can see how it's done in Vite tests: https://github.com/vitejs/vite/tree/main/playground

@Madvinking
Copy link
Author

mm ok, u wrote the wsEndpoint to a file and then connect to it each time...
nice solution but a little bit messy.

with jest, I created a test environment and then attach the instance to global.
but for some reason custom environment doesn't work the same way, or at least I wasn't able to configure one

@sheremet-va
Copy link
Member

Jest has it's own system, we only provide similar API. The internals are very different. Environments are basically the same as using setupFiles.

@brc-dd
Copy link

brc-dd commented Nov 7, 2022

Just wanted to ask, is there a drawback in directly adding the ws endpoint to process.env.something (instead of writing it to a file and reading later)?

@sheremet-va
Copy link
Member

Just wanted to ask, is there a drawback in directly adding the ws endpoint to process.env.something (instead of writing it to a file and reading later)?

If it works, it works 😄

We can't provide this API, so I am closing the issue.

@sheremet-va sheremet-va closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants