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

Puppeteer can not launch on Ubuntu #5062

Closed
joe223 opened this issue Oct 22, 2019 · 1 comment
Closed

Puppeteer can not launch on Ubuntu #5062

joe223 opened this issue Oct 22, 2019 · 1 comment

Comments

@joe223
Copy link

joe223 commented Oct 22, 2019

Steps to reproduce

Tell us about your environment:

No LSB modules are available. 
Distributor ID: Ubuntu 
Description:    Ubuntu 18.04.3 LTS
Release:        18.04                                                                                                              
Codename:       bionic 
  • URLs (if applicable):
  • Node.js version: v10.16.3

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Run test case in Mocha, this is the setup
const path = require('path')
const expect = require('expect')
const puppeteer = require('puppeteer')
const createServer = require('./createServer')

const server = createServer()
const globalVariables = {
    browser: global.browser,
    expect: global.expect,
    entryPath: global.entryPath
}
const opts = {
    headless: true,
    timeout: 10000
}

before (async function () {
    global.expect = expect
    global.browser = await puppeteer.launch(opts)
    global.entryPath = `http://localhost:${server.address().port}/test/index.html`
})

after (function () {
    server.close()
    browser.close()
    global.browser = globalVariables.browser
    global.expect = globalVariables.expect
    global.entryPath = globalVariables.entryPath
})

test case test/unit/init.spec.js:

describe('Initialization', function () {
    let page = null

    before(async function () {
        page = await browser.newPage()
        await page.goto(global.entryPath)
    })

    after(async function () {
        await page.close()
    })

    beforeEach(async function () {
        await page.reload({
            timeout: 1000,
            waitUntil: 'load'
        })
    })

    it('default setup', function () {
        expect(true).toBeTruthy()
    })
})

npm script:

"test": "mocha test/setup.js test/**/*.spec.js"

setup_puppeteer.sh file

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
    libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
    libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
    libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
    ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget --fix-missing
  1. run setup_puppeteer.sh before npm install
  2. run npm run test

What is the expected result?
Test should pass

What happens instead?
this is terminal info:

Test server is running at: 3639


  1) "before all" hook in "{root}"
  2) "after all" hook in "{root}"

  0 passing (2s)
  1 failing

  1) "before all" hook in "{root}":
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.


  2) "after all" hook in "{root}":
     ReferenceError: browser is not defined
      at Context.<anonymous> (test/setup.js:25:5)                                                                        

It same with #3443 , but I had install puppeteer dependencies.

This is CI log https://travis-ci.com/joe223/tiny-swiper/jobs/248144769

@joe223
Copy link
Author

joe223 commented Oct 23, 2019

Update
This information is important Error: Timeout of 2000ms exceeded.
So I change timeout to 10000ms , the problem is gone.
Maybe TravisCI's computer performance is too low ?

@joe223 joe223 closed this as completed Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant