Test node6 on travis (#551)
This patch starts running all puppeteer tests with node6 on travis-ci.
This commit is contained in:
parent
bd5b4fe963
commit
cd81944e66
@ -1,3 +1,4 @@
|
||||
third_party/*
|
||||
utils/doclint/check_public_api/test/
|
||||
node6/*
|
||||
node6/*
|
||||
node6-test/*
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@
|
||||
.vscode
|
||||
package-lock.json
|
||||
/node6
|
||||
/node6-test
|
||||
|
@ -11,3 +11,4 @@ node_modules
|
||||
*.pyc
|
||||
.vscode
|
||||
package-lock.json
|
||||
/node6-test
|
||||
|
@ -15,9 +15,8 @@ install:
|
||||
script:
|
||||
- 'if [ "$NODE7" = "true" ]; then yarn run lint; fi'
|
||||
- 'if [ "$NODE7" = "true" ]; then yarn run coverage; fi'
|
||||
- 'if [ "$NODE6" = "true" ]; then yarn run node6; fi'
|
||||
- 'if [ "$NODE6" = "true" ]; then yarn run test-node6; fi'
|
||||
- 'if [ "$NODE6" = "true" ]; then yarn run node6-sanity; fi'
|
||||
- 'if [ "$NODE6" = "true" ]; then yarn run test-node6-transformer; fi'
|
||||
- 'if [ "$NODE6" = "true" ]; then yarn run unit-node6; fi'
|
||||
jobs:
|
||||
include:
|
||||
- node_js: "7"
|
||||
|
@ -11,15 +11,14 @@
|
||||
"unit": "jasmine test/test.js",
|
||||
"debug-unit": "DEBUG_TEST=true node --inspect-brk ./node_modules/.bin/jasmine test/test.js",
|
||||
"test-doclint": "jasmine utils/doclint/check_public_api/test/test.js && jasmine utils/doclint/preprocessor/test.js",
|
||||
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6",
|
||||
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6-transformer",
|
||||
"install": "node install.js",
|
||||
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .) && npm run doc",
|
||||
"doc": "node utils/doclint/cli.js",
|
||||
"coverage": "COVERAGE=true npm run unit",
|
||||
"node6": "node utils/node6-transform/index.js",
|
||||
"test-node6": "jasmine utils/node6-transform/test/test.js",
|
||||
"build": "npm run node6",
|
||||
"node6-sanity": "jasmine test/sanity.js"
|
||||
"test-node6-transformer": "jasmine utils/node6-transform/test/test.js",
|
||||
"build": "node utils/node6-transform/index.js",
|
||||
"unit-node6": "jasmine node6-test/test.js"
|
||||
},
|
||||
"author": "The Chromium Authors",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
|
@ -1,33 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
console.log(process.version);
|
||||
|
||||
describe('Puppeteer Sanity', function() {
|
||||
it('should not be insane', function(done) {
|
||||
const puppeteer = require('..');
|
||||
puppeteer.launch().then(browser => {
|
||||
browser.newPage().then(page => {
|
||||
page.goto('data:text/html,hello').then(() => {
|
||||
page.evaluate(() => document.body.textContent).then(content => {
|
||||
expect(content).toBe('hello');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -20,6 +20,7 @@ const path = require('path');
|
||||
const helper = require('../lib/helper');
|
||||
if (process.env.COVERAGE)
|
||||
helper.recordPublicAPICoverage();
|
||||
console.log('Testing on Node', process.version);
|
||||
const puppeteer = require('..');
|
||||
const SimpleServer = require('./server/SimpleServer');
|
||||
const GoldenUtils = require('./golden-utils');
|
||||
|
@ -49,6 +49,7 @@ const asyncToGenerator = fn => {
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
* @return {string}
|
||||
*/
|
||||
function transformAsyncFunctions(text) {
|
||||
const edits = [];
|
||||
|
@ -19,18 +19,25 @@ const path = require('path');
|
||||
const removeRecursive = require('rimraf').sync;
|
||||
const transformAsyncFunctions = require('./TransformAsyncFunctions');
|
||||
|
||||
const dirPath = path.join(__dirname, '..', '..', 'lib');
|
||||
const outPath = path.join(__dirname, '..', '..', 'node6');
|
||||
const fileNames = fs.readdirSync(dirPath);
|
||||
const filePaths = fileNames.filter(fileName => fileName.endsWith('.js'));
|
||||
copyFolder(path.join(__dirname, '..', '..', 'lib'), path.join(__dirname, '..', '..', 'node6'));
|
||||
copyFolder(path.join(__dirname, '..', '..', 'test'), path.join(__dirname, '..', '..', 'node6-test'));
|
||||
|
||||
if (fs.existsSync(outPath))
|
||||
removeRecursive(outPath);
|
||||
fs.mkdirSync(outPath);
|
||||
|
||||
filePaths.forEach(filePath => {
|
||||
const content = fs.readFileSync(path.join(dirPath, filePath), 'utf8');
|
||||
const output = transformAsyncFunctions(content);
|
||||
fs.writeFileSync(path.resolve(outPath, filePath), output);
|
||||
});
|
||||
function copyFolder(source, target) {
|
||||
if (fs.existsSync(target))
|
||||
removeRecursive(target);
|
||||
fs.mkdirSync(target);
|
||||
|
||||
fs.readdirSync(source).forEach(file => {
|
||||
const from = path.join(source, file);
|
||||
const to = path.join(target, file);
|
||||
if (fs.lstatSync(from).isDirectory()) {
|
||||
copyFolder(from, to);
|
||||
} else {
|
||||
let text = fs.readFileSync(from);
|
||||
if (file.endsWith('.js'))
|
||||
text = transformAsyncFunctions(text.toString()).replace(/require\('\.\.\/lib\//g, `require('../node6/`);
|
||||
fs.writeFileSync(to, text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user