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": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 8
|
"ecmaVersion": 9
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
"@types/ws": "^6.0.1",
|
"@types/ws": "^6.0.1",
|
||||||
"commonmark": "^0.28.1",
|
"commonmark": "^0.28.1",
|
||||||
"cross-env": "^5.0.5",
|
"cross-env": "^5.0.5",
|
||||||
"eslint": "^5.9.0",
|
"eslint": "^5.15.1",
|
||||||
"esprima": "^4.0.0",
|
"esprima": "^4.0.0",
|
||||||
"jpeg-js": "^0.3.4",
|
"jpeg-js": "^0.3.4",
|
||||||
"minimist": "^1.2.0",
|
"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 }) => {
|
it('should close the browser when the node process closes', async({ server }) => {
|
||||||
const {spawn, execSync} = require('child_process');
|
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;
|
let wsEndPointCallback;
|
||||||
const wsEndPointPromise = new Promise(x => wsEndPointCallback = x);
|
const wsEndPointPromise = new Promise(x => wsEndPointCallback = x);
|
||||||
let output = '';
|
let output = '';
|
||||||
|
@ -22,6 +22,10 @@ const transformAsyncFunctions = require('./TransformAsyncFunctions');
|
|||||||
const root = path.join(__dirname, '..', '..');
|
const root = path.join(__dirname, '..', '..');
|
||||||
const dest = path.join(__dirname, '..', '..', 'node6');
|
const dest = path.join(__dirname, '..', '..', 'node6');
|
||||||
|
|
||||||
|
const excludes = [
|
||||||
|
path.resolve(root, 'test', 'assets'),
|
||||||
|
];
|
||||||
|
|
||||||
if (fs.existsSync(dest))
|
if (fs.existsSync(dest))
|
||||||
removeRecursive(dest);
|
removeRecursive(dest);
|
||||||
fs.mkdirSync(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, 'lib'), path.join(dest, 'lib'));
|
||||||
copyFolder(path.join(root, 'test'), path.join(dest, 'test'));
|
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) {
|
function copyFolder(source, target) {
|
||||||
if (fs.existsSync(target))
|
if (fs.existsSync(target))
|
||||||
@ -48,7 +53,8 @@ function copyFolder(source, target) {
|
|||||||
|
|
||||||
function copyFile(from, to) {
|
function copyFile(from, to) {
|
||||||
let text = fs.readFileSync(from);
|
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();
|
text = text.toString();
|
||||||
const prefix = text.startsWith('#!') ? text.substring(0, text.indexOf('\n')) : '';
|
const prefix = text.startsWith('#!') ? text.substring(0, text.indexOf('\n')) : '';
|
||||||
text = prefix + transformAsyncFunctions(text.substring(prefix.length));
|
text = prefix + transformAsyncFunctions(text.substring(prefix.length));
|
||||||
|
Loading…
Reference in New Issue
Block a user