GithubHelp home page GithubHelp logo

Comments (4)

alisha avatar alisha commented on June 2, 2024

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.

from jest-puppeteer.

alisha avatar alisha commented on June 2, 2024

Update: was actually able to solve this issue by modifying my Jest config file to have maxWorkers set to 1. I'm now able to specify the userDataDir parameter in the launch options, and have tests run and user profile state persisted.

I realized this because when I specified the userDataDir parameter (set to ./tmp) with headless set to true, I got this error:

Error: Jest: Got error running globalSetup - node_modules/jest-environment-puppeteer/setup.js, reason: Failed to launch the browser process! undefined
[83873:259:0405/141345.099847:ERROR:process_singleton_posix.cc(335)] Failed to create tmp/SingletonLock: File exists (17)
[83873:259:0405/141345.106931:ERROR:chrome_main_delegate.cc(590)] Failed to create a ProcessSingleton for your profile directory. This means that running multiple instances would start multiple browser processes rather than opening a new window in the existing process. Aborting now to avoid profile corruption.

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

from jest-puppeteer.

gregberge avatar gregberge commented on June 2, 2024

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

from jest-puppeteer.

alisha avatar alisha commented on June 2, 2024

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.

from jest-puppeteer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.