fix(tests): accomodate isplaywrightready (#1746)
This commit is contained in:
parent
cd2ecb2212
commit
bf656ea318
19
test/test.js
19
test/test.js
|
|
@ -20,6 +20,7 @@ const readline = require('readline');
|
||||||
const TestRunner = require('../utils/testrunner/');
|
const TestRunner = require('../utils/testrunner/');
|
||||||
const {Environment} = require('../utils/testrunner/Test');
|
const {Environment} = require('../utils/testrunner/Test');
|
||||||
|
|
||||||
|
function collect(browserNames) {
|
||||||
let parallel = 1;
|
let parallel = 1;
|
||||||
if (process.env.PW_PARALLEL_TESTS)
|
if (process.env.PW_PARALLEL_TESTS)
|
||||||
parallel = parseInt(process.env.PW_PARALLEL_TESTS.trim(), 10);
|
parallel = parseInt(process.env.PW_PARALLEL_TESTS.trim(), 10);
|
||||||
|
|
@ -52,12 +53,6 @@ const testRunner = new TestRunner({
|
||||||
if (config.setupTestRunner)
|
if (config.setupTestRunner)
|
||||||
config.setupTestRunner(testRunner);
|
config.setupTestRunner(testRunner);
|
||||||
|
|
||||||
console.log('Testing on Node', process.version);
|
|
||||||
|
|
||||||
const browserNames = ['chromium', 'firefox', 'webkit'].filter(name => {
|
|
||||||
return process.env.BROWSER === name || process.env.BROWSER === 'all';
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(testRunner.api()))
|
for (const [key, value] of Object.entries(testRunner.api()))
|
||||||
global[key] = value;
|
global[key] = value;
|
||||||
|
|
||||||
|
|
@ -205,4 +200,16 @@ if (filterArgIndex !== -1) {
|
||||||
testRunner.focusMatchingTests(new RegExp(filter, 'i'));
|
testRunner.focusMatchingTests(new RegExp(filter, 'i'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return testRunner;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = collect;
|
||||||
|
|
||||||
|
if (require.main === module) {
|
||||||
|
console.log('Testing on Node', process.version);
|
||||||
|
const browserNames = ['chromium', 'firefox', 'webkit'].filter(name => {
|
||||||
|
return process.env.BROWSER === name || process.env.BROWSER === 'all';
|
||||||
|
});
|
||||||
|
const testRunner = collect(browserNames);
|
||||||
testRunner.run().then(() => { delete global.expect; });
|
testRunner.run().then(() => { delete global.expect; });
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ const PROJECT_ROOT = fs.existsSync(path.join(__dirname, '..', 'package.json')) ?
|
||||||
const mkdtempAsync = util.promisify(require('fs').mkdtemp);
|
const mkdtempAsync = util.promisify(require('fs').mkdtemp);
|
||||||
const removeFolderAsync = util.promisify(removeFolder);
|
const removeFolderAsync = util.promisify(removeFolder);
|
||||||
|
|
||||||
|
let platform = os.platform();
|
||||||
|
|
||||||
const utils = module.exports = {
|
const utils = module.exports = {
|
||||||
/**
|
/**
|
||||||
* @return {string}
|
* @return {string}
|
||||||
|
|
@ -182,9 +184,9 @@ const utils = module.exports = {
|
||||||
FFOX: browserType.name() === 'firefox',
|
FFOX: browserType.name() === 'firefox',
|
||||||
WEBKIT: browserType.name() === 'webkit',
|
WEBKIT: browserType.name() === 'webkit',
|
||||||
CHROMIUM: browserType.name() === 'chromium',
|
CHROMIUM: browserType.name() === 'chromium',
|
||||||
MAC: os.platform() === 'darwin',
|
MAC: platform === 'darwin',
|
||||||
LINUX: os.platform() === 'linux',
|
LINUX: platform === 'linux',
|
||||||
WIN: os.platform() === 'win32',
|
WIN: platform === 'win32',
|
||||||
browserType,
|
browserType,
|
||||||
defaultBrowserOptions,
|
defaultBrowserOptions,
|
||||||
playwrightPath: PROJECT_ROOT,
|
playwrightPath: PROJECT_ROOT,
|
||||||
|
|
@ -193,6 +195,11 @@ const utils = module.exports = {
|
||||||
OUTPUT_DIR,
|
OUTPUT_DIR,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setPlatform(p) {
|
||||||
|
// To support isplaywrightready.
|
||||||
|
platform = p;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function valueFromEnv(name, defaultValue) {
|
function valueFromEnv(name, defaultValue) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue