Skip to content

Commit

Permalink
chore: add test for npm package installing correctly (#5714)
Browse files Browse the repository at this point in the history
* chore: add test for npm package installing correctly

This command packs up the module and installs it again to check we're
correctly bundling everything we need to allow users to do a fresh
install.

* install realpath
  • Loading branch information
jackfranklin committed Apr 22, 2020
1 parent 1615c9c commit feec588
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Expand Up @@ -6,6 +6,8 @@ addons:
packages:
# This is required to run new chrome on old trusty
- libnss3
# Needed for realpath which we use in npm run test-install
- realpath
notifications:
email: false
cache:
Expand Down Expand Up @@ -33,7 +35,9 @@ jobs:
- "sh -e /etc/init.d/xvfb start"
# populate .local-firefox for launcher tests
- PUPPETEER_PRODUCT=firefox npm install
script: ./travis/chromium.sh
script:
- npm run test-install
- travis/chromium.sh
- node_js: "10.19.0"
dist: trusty
env:
Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -30,14 +30,16 @@
"bundle": "npm run tsc && npx browserify -r ./index.js:puppeteer -o utils/browser/puppeteer-web.js",
"test-types": "node utils/doclint/generate_types && tsc --version && tsc -p utils/doclint/generate_types/test/",
"unit-bundle": "mocha --config mocha-config/browser-bundle-tests.js",
"update-protocol-d-ts": "node utils/protocol-types-generator"
"update-protocol-d-ts": "node utils/protocol-types-generator",
"test-install": "scripts/test-install.sh"
},
"files": [
"lib/",
"Errors.js",
"DeviceDescriptors.js",
"index.js",
"install.js"
"install.js",
"typescript-if-required.js"
],
"author": "The Chromium Authors",
"license": "Apache-2.0",
Expand Down
15 changes: 15 additions & 0 deletions scripts/test-install.sh
@@ -0,0 +1,15 @@
#!/usr/bin/env sh
set -e

# Pack the module into a tarball
npm pack
tarball="$(realpath puppeteer-*.tgz)"
cd "$(mktemp -d)"
# Check we can install from the tarball.
# This emulates installing from npm and ensures that:
# 1. we publish the right files in the `files` list from package.json
# 2. The install script works and correctly exits without errors
# 3. Requiring Puppeteer from Node works.
npm install --loglevel silent "${tarball}"
node --eval="require('puppeteer')"
rm "${tarball}"

0 comments on commit feec588

Please sign in to comment.