mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: fix fixtures test when run with env DUMPIO=1 (#4123)
The DUMPIO env variable is propagated to a spawned process and results in unfortunate stdout.
This commit is contained in:
parent
808d1bb597
commit
3511a35fa4
@ -7,7 +7,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 8
|
||||
"ecmaVersion": 9
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@
|
||||
"@types/ws": "^6.0.1",
|
||||
"commonmark": "^0.28.1",
|
||||
"cross-env": "^5.0.5",
|
||||
"eslint": "^5.9.0",
|
||||
"eslint": "^5.15.1",
|
||||
"esprima": "^4.0.0",
|
||||
"jpeg-js": "^0.3.4",
|
||||
"minimist": "^1.2.0",
|
||||
|
@ -41,7 +41,11 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
||||
});
|
||||
it('should close the browser when the node process closes', async({ server }) => {
|
||||
const {spawn, execSync} = require('child_process');
|
||||
const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), puppeteerPath, JSON.stringify(defaultBrowserOptions)]);
|
||||
const options = Object.assign({}, defaultBrowserOptions, {
|
||||
// Disable DUMPIO to cleanly read stdout.
|
||||
dumpio: false,
|
||||
});
|
||||
const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), puppeteerPath, JSON.stringify(options)]);
|
||||
let wsEndPointCallback;
|
||||
const wsEndPointPromise = new Promise(x => wsEndPointCallback = x);
|
||||
let output = '';
|
||||
|
@ -22,6 +22,10 @@ const transformAsyncFunctions = require('./TransformAsyncFunctions');
|
||||
const root = path.join(__dirname, '..', '..');
|
||||
const dest = path.join(__dirname, '..', '..', 'node6');
|
||||
|
||||
const excludes = [
|
||||
path.resolve(root, 'test', 'assets'),
|
||||
];
|
||||
|
||||
if (fs.existsSync(dest))
|
||||
removeRecursive(dest);
|
||||
fs.mkdirSync(dest);
|
||||
@ -29,7 +33,8 @@ fs.mkdirSync(path.join(dest, 'utils'));
|
||||
|
||||
copyFolder(path.join(root, 'lib'), path.join(dest, 'lib'));
|
||||
copyFolder(path.join(root, 'test'), path.join(dest, 'test'));
|
||||
copyFolder(path.join(root, 'utils'), path.join(dest, 'utils'));
|
||||
copyFolder(path.join(root, 'utils', 'testrunner'), path.join(dest, 'utils', 'testrunner'));
|
||||
copyFolder(path.join(root, 'utils', 'testserver'), path.join(dest, 'utils', 'testserver'));
|
||||
|
||||
function copyFolder(source, target) {
|
||||
if (fs.existsSync(target))
|
||||
@ -48,7 +53,8 @@ function copyFolder(source, target) {
|
||||
|
||||
function copyFile(from, to) {
|
||||
let text = fs.readFileSync(from);
|
||||
if (from.endsWith('.js')) {
|
||||
const isExcluded = excludes.some(exclude => from.startsWith(exclude));
|
||||
if (!isExcluded && from.endsWith('.js')) {
|
||||
text = text.toString();
|
||||
const prefix = text.startsWith('#!') ? text.substring(0, text.indexOf('\n')) : '';
|
||||
text = prefix + transformAsyncFunctions(text.substring(prefix.length));
|
||||
|
Loading…
Reference in New Issue
Block a user