mirror of
https://github.com/scratchfoundation/scratch-render.git
synced 2025-07-23 20:50:08 -04:00
download Chromium only when tests are run
This commit is contained in:
parent
ec141ff76d
commit
fdd02a6bd6
5 changed files with 33 additions and 7 deletions
|
@ -1,14 +1,10 @@
|
|||
language: node_js
|
||||
dist: trusty
|
||||
addons:
|
||||
chrome: stable
|
||||
node_js:
|
||||
- 8
|
||||
- node
|
||||
env:
|
||||
- NODE_ENV=production
|
||||
before_install:
|
||||
- google-chrome-stable --headless --no-sandbox --remote-debugging-port=9222 &
|
||||
install:
|
||||
- npm --production=false install
|
||||
- npm --production=false update
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"gh-pages": "^1.0.0",
|
||||
"jsdoc": "^3.5.5",
|
||||
"json": "^9.0.4",
|
||||
"puppeteer": "^2.0.0",
|
||||
"puppeteer-core": "^2.0.0",
|
||||
"scratch-vm": "0.2.0-prerelease.20191227164934",
|
||||
"tap": "^11.0.0",
|
||||
"travis-after-all": "^1.4.4",
|
||||
|
|
24
test/helper/download-chromium.js
Normal file
24
test/helper/download-chromium.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const packageJson = require('puppeteer-core/package.json');
|
||||
const puppeteer = require('puppeteer-core');
|
||||
|
||||
const fetcher = puppeteer.createBrowserFetcher();
|
||||
const revision = packageJson.puppeteer.chromium_revision;
|
||||
|
||||
/* eslint-disable no-console */
|
||||
module.exports = async () => {
|
||||
const downloadedRevisions = await fetcher.localRevisions();
|
||||
if (downloadedRevisions.indexOf(revision) !== -1) {
|
||||
console.log('Chromium already downloaded');
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
console.log('Downloading Chromium...');
|
||||
return fetcher.download(revision)
|
||||
.then(() => {
|
||||
console.log('Downloaded Chromium successfully');
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
};
|
|
@ -1,8 +1,10 @@
|
|||
/* global vm, render, Promise */
|
||||
const puppeteer = require('puppeteer');
|
||||
const puppeteer = require('puppeteer-core');
|
||||
const test = require('tap').test;
|
||||
const path = require('path');
|
||||
|
||||
const downloadChromium = require('../helper/download-chromium');
|
||||
|
||||
const indexHTML = path.resolve(__dirname, 'index.html');
|
||||
const testDir = (...args) => path.resolve(__dirname, 'pick-tests', ...args);
|
||||
|
||||
|
@ -19,6 +21,7 @@ const runFile = async (file, action, page, script) => {
|
|||
|
||||
// immediately invoked async function to let us wait for each test to finish before starting the next.
|
||||
(async () => {
|
||||
await downloadChromium();
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/* global vm, Promise */
|
||||
const puppeteer = require('puppeteer');
|
||||
const puppeteer = require('puppeteer-core');
|
||||
const test = require('tap').test;
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const downloadChromium = require('../helper/download-chromium');
|
||||
|
||||
const indexHTML = path.resolve(__dirname, 'index.html');
|
||||
const testDir = (...args) => path.resolve(__dirname, 'scratch-tests', ...args);
|
||||
|
||||
|
@ -103,6 +105,7 @@ const testFile = (file, page) => test(file, async t => {
|
|||
|
||||
// immediately invoked async function to let us wait for each test to finish before starting the next.
|
||||
(async () => {
|
||||
await downloadChromium();
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue