-
Notifications
You must be signed in to change notification settings - Fork 289
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
userDataDir must be specified in args
outside launch
, or else browser crashes
#583
Comments
Actually, I realized that the proposed fix I mentioned suppresses the error and lets the tests be run, but the user profile is not stored in the specified directory. So, the proposed fixes don't actually work. |
Update: was actually able to solve this issue by modifying my Jest config file to have I realized this because when I specified the
So it seems like having multiple Jest workers creates an issue with setting up a shared user profile. For now, I think it would be great if this issue is documented; I'm not sure what the fix for this would be |
Hello @alisha, I am not sure it's relative to jest-puppeteer itself then. So what is the issue exactly? Because this option is documented in Puppeteer: https://pptr.dev/api/puppeteer.browserlaunchargumentoptions |
Sorry the initial bug report was unclear -- I realized what the actual issue (mentioned here) is after submitting the initial report. The actual issue is how Jest and Puppeteer integrate together. If you have multiple Jest workers, they will all launch simultaneous browser processes. If you specify a single user data directory in your jest-puppeteer config, all of these processes will share the same user data directory; and Chromium will abort the processes because of potential file system concurrency issues. As a result, the user sees a generic error message and their tests never run. The fix is simple: use a single Jest worker if you need to specify the user data directory. I think it would be great for this to be documented somewhere, as I had to spend a lot of time to figure this out, and I'd love to spare other users that time spent debugging. |
🐛 Bug Report
At first I thought this was a bug where I couldn't specify the userDataDir parameter, as my browser would always crash and my tests would never run. I found out how to specify this parameter correctly and have the tests run, but it's unintuitive. I think this should either be documented, or be fixed to be more intiutive.
If your config file looks like this:
Or like this:
The browser will launch, immediately crash, and the tests are never run. I also get this error message:
However, if you have the following config file (where
args
is outside oflaunch
):It will work as expected. Note that if you want to specify other args for puppeteer, you must have another
args
array insidelaunch
(like the second config file I showed).To Reproduce
Use either of these config files:
Or
Expected behavior
The browser exits only after tests are run. I would also expect the second config file showed (where
launch
hasargs
, which in turn has--user-data-dir=...
) to work.Link to repl or repo (highly encouraged)
https://github.com/alisha/jest-bug-repro
The
jest-puppeteer.config.cjs
file contains 4 versions of a config file, 3 of which are commented out so you can run it. The first 2 versions reproduce the issue, while the last two versions work.Run
npx envinfo --system --binaries --npmPackages expect-puppeteer,jest-dev-server,jest-environment-puppeteer,jest-puppeteer,spawnd --markdown --clipboard
Paste the results here:
The text was updated successfully, but these errors were encountered: