facebook-atom / jest-electron-runner

custom test runner for Jest that allows tests to be run in Electron environment
MIT License
189 stars 33 forks source link

Running in Bitbucket pipeline: --no-sandbox #51

Open coltpini opened 4 years ago

coltpini commented 4 years ago

I am trying to run test through out pipeline in Bitbucket. I keep hitting this error:

[973:1011/205026.940590:FATAL:atom_main_delegate.cc(210)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

Is there a way to pass the --no-sandbox flag through? Or use a user other than root? Or maybe some other solution?

I tried this: adduser temp && adduser temp sudo && su - temp && yarn test but I am the first to admit I am not a Systems person.

-- Update: I am passed that one, but am now hitting an error that says (electron:987): Gtk-WARNING **: cannot open display: that I can't seem to get around.

-- another update: I am passed that one, and am now hitting xhost: unable to open display ":0.0" :sigh:

coltpini commented 4 years ago

I got passed the '--no-sandbox' error by using the a temp sudo user like above, but that wasn't quite the right script, here is the script:

script:
  # we need to get the needed libs and commands to run headless chrome / electron
  - apt-get -y update && apt-get -y install libgconf-2-4 libnss3 libgtk-3-0 libxss1 libasound2
  # we need to create a temp user to run the test because it is better to run as root, and chrome doesn't let you.
  - adduser temp && usermod -aG sudo temp
  # now we need to run the test as the new user.
  - su temp -c "yarn test-coverage --maxWorkers=4"
skeggse commented 4 years ago

Did you also find a way to pass --no-sandbox to electron, or did you just solve it with the temporary sudo user?

coltpini commented 4 years ago

@skeggse I actually never got it working. We ended up having to bypass. :(

The above code bypasses the no-sandbox but there were several other layers we kept running into.

skeggse commented 4 years ago

For future reference, electron supports a ELECTRON_DISABLE_SANDBOX flag! https://github.com/electron/electron/pull/16576