Failed to launch chrome!, failed to launch chrome puppeteer in bamboo for jest image snapshot test

645 Views Asked by At

I am trying to run puppeteer in bamboo build run. But seems there is problem to execute it properly. The detail error below

enter image description here

I wonder if there is stuff I have to install to get it able to run in bamboo? or I have to do other alternative. There is no articles available online regarding this issue.

And a bit more background, I am trying to implement jest-image-snapshot into my test process. and making a call to generate snapshot like this

const puppeteer = require('puppeteer');

let browser;

  beforeAll(async () => {
    browser = await puppeteer.launch();
  });

  it('show correct page: variant', async () => {
    const page = await browser.newPage();
    await page.goto(
      'http://localhost:8080/app/register?experimentName=2018_12_STREAMLINED_ACCOUNT&experimentVariation=STREAMLINED#/'
    );
    const image = await page.screenshot();

    expect(image).toMatchImageSnapshot();
  });

  afterAll(async () => {
    await browser.close();
  });

the reason log of TypeError: Cannot read property 'newPage' of undefined is because const page = await browser.newPage();

1

There are 1 best solutions below

0
On

The important part is in your screenshot:

Failed to launch chrome! ... No usable sandbox!

Try to launch puppeteer without a sandbox like this:

await puppeteer.launch({
    args: ['--no-sandbox']
});

Depending on the platform, you might also want to try the following arguments (also in addition):

  • --disable-setuid-sandbox
  • --disable-dev-shm-usage

If all three do not work, the Troubleshooting guide might have additional information.