chore: normalize NPM scripts (#1285)
This patch: - makes `npm run cunit/wunit/funit` and `npm run ctest/ftest/wtest` run browser-specific tests only - makes `npm run unit` and `npm run test` run *all* browser tests - runs *all* our infrastructure tests as part of `npm run lint` As a result, if there's one test to be tested across all three browsers, you can focus it and do `npm run test`;
This commit is contained in:
parent
e78f0f71df
commit
071ee06404
23
package.json
23
package.json
|
|
@ -16,20 +16,23 @@
|
||||||
"ctest": "cross-env BROWSER=chromium node test/test.js",
|
"ctest": "cross-env BROWSER=chromium node test/test.js",
|
||||||
"ftest": "cross-env BROWSER=firefox node test/test.js",
|
"ftest": "cross-env BROWSER=firefox node test/test.js",
|
||||||
"wtest": "cross-env BROWSER=webkit node test/test.js",
|
"wtest": "cross-env BROWSER=webkit node test/test.js",
|
||||||
"unit": "npm run ctest",
|
"test": "cross-env BROWSER=all node test/test.js",
|
||||||
"funit": "npm run ftest",
|
"cunit": "cross-env BROWSER=chromium node test/test.js",
|
||||||
"wunit": "npm run wtest",
|
"funit": "cross-env BROWSER=firefox node test/test.js",
|
||||||
"debug-test": "node --inspect-brk test/test.js",
|
"wunit": "cross-env BROWSER=webkit node test/test.js",
|
||||||
"test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
|
"unit": "cross-env BROWSER=all node test/test.js",
|
||||||
"test": "npm run lint --silent && npm run ccoverage && npm run fcoverage && npm run wcoverage && npm run test-doclint && node utils/testrunner/test/test.js",
|
"ccoverage": "cross-env COVERAGE=true BROWSER=chromium node test/test.js",
|
||||||
"prepare": "node install-from-github.js",
|
|
||||||
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src) && npm run tsc && npm run doc",
|
|
||||||
"doc": "node utils/doclint/cli.js",
|
|
||||||
"ccoverage": "cross-env COVERAGE=true npm run ctest",
|
|
||||||
"fcoverage": "cross-env COVERAGE=true BROWSER=firefox node test/test.js",
|
"fcoverage": "cross-env COVERAGE=true BROWSER=firefox node test/test.js",
|
||||||
"wcoverage": "cross-env COVERAGE=true BROWSER=webkit node test/test.js",
|
"wcoverage": "cross-env COVERAGE=true BROWSER=webkit node test/test.js",
|
||||||
|
"coverage": "cross-env COVERAGE=true BROWSER=all node test/test.js",
|
||||||
|
"eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src",
|
||||||
"tsc": "tsc -p .",
|
"tsc": "tsc -p .",
|
||||||
|
"doc": "node utils/doclint/cli.js",
|
||||||
|
"test-infra": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js && node utils/testrunner/test/test.js",
|
||||||
|
"lint": "npm run eslint && npm run tsc && npm run doc && npm run test-infra",
|
||||||
|
"debug-test": "node --inspect-brk test/test.js",
|
||||||
"clean": "rimraf lib",
|
"clean": "rimraf lib",
|
||||||
|
"prepare": "node install-from-github.js",
|
||||||
"build": "node utils/runWebpack.js --mode='development' && tsc -p .",
|
"build": "node utils/runWebpack.js --mode='development' && tsc -p .",
|
||||||
"watch": "node utils/runWebpack.js --mode='development' --watch --silent | tsc -w -p .",
|
"watch": "node utils/runWebpack.js --mode='development' --watch --silent | tsc -w -p .",
|
||||||
"version": "node utils/sync_package_versions.js && npm run doc"
|
"version": "node utils/sync_package_versions.js && npm run doc"
|
||||||
|
|
|
||||||
79
test/test.js
79
test/test.js
|
|
@ -77,44 +77,51 @@ beforeEach(async({server, httpsServer}) => {
|
||||||
httpsServer.reset();
|
httpsServer.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
const products = ['WebKit', 'Firefox', 'Chromium'];
|
const BROWSER_CONFIGS = [
|
||||||
let product;
|
{
|
||||||
let events;
|
name: 'Firefox',
|
||||||
let missingCoverage;
|
events: {
|
||||||
if (process.env.BROWSER === 'firefox') {
|
...require('../lib/events').Events,
|
||||||
product = 'Firefox';
|
...require('../lib/chromium/events').Events,
|
||||||
events = {
|
},
|
||||||
...require('../lib/events').Events,
|
missingCoverage: ['browserContext.setGeolocation', 'browserContext.setOffline'],
|
||||||
...require('../lib/chromium/events').Events,
|
},
|
||||||
};
|
{
|
||||||
missingCoverage = ['browserContext.setGeolocation', 'browserContext.setOffline'];
|
name: 'WebKit',
|
||||||
} else if (process.env.BROWSER === 'webkit') {
|
events: require('../lib/events').Events,
|
||||||
product = 'WebKit';
|
missingCoverage: ['browserContext.clearPermissions'],
|
||||||
events = require('../lib/events').Events;
|
},
|
||||||
missingCoverage = ['browserContext.clearPermissions'];
|
{
|
||||||
} else {
|
name: 'Chromium',
|
||||||
product = 'Chromium';
|
events: require('../lib/events').Events,
|
||||||
events = require('../lib/events').Events;
|
missingCoverage: [],
|
||||||
missingCoverage = [];
|
},
|
||||||
}
|
];
|
||||||
|
|
||||||
describe(product, () => {
|
const browserNames = BROWSER_CONFIGS.map(config => config.name);
|
||||||
testRunner.loadTests(require('./playwright.spec.js'), {
|
|
||||||
product,
|
for (const browserConfig of BROWSER_CONFIGS) {
|
||||||
playwrightPath: utils.projectRoot(),
|
if (process.env.BROWSER !== browserConfig.name.toLowerCase() && process.env.BROWSER !== 'all')
|
||||||
testRunner,
|
continue;
|
||||||
});
|
const product = browserConfig.name;
|
||||||
if (process.env.COVERAGE) {
|
describe(product, () => {
|
||||||
const api = require('../lib/api');
|
testRunner.loadTests(require('./playwright.spec.js'), {
|
||||||
const filteredApi = {};
|
product,
|
||||||
Object.keys(api).forEach(name => {
|
playwrightPath: utils.projectRoot(),
|
||||||
if (products.some(p => name.startsWith(p)) && !name.startsWith(product))
|
testRunner,
|
||||||
return;
|
|
||||||
filteredApi[name] = api[name];
|
|
||||||
});
|
});
|
||||||
utils.recordAPICoverage(testRunner, filteredApi, events, missingCoverage);
|
if (process.env.COVERAGE) {
|
||||||
}
|
const api = require('../lib/api');
|
||||||
});
|
const filteredApi = {};
|
||||||
|
Object.keys(api).forEach(apiName => {
|
||||||
|
if (browserNames.some(browserName => apiName.startsWith(browserName)) && !apiName.startsWith(product))
|
||||||
|
return;
|
||||||
|
filteredApi[apiName] = api[apiName];
|
||||||
|
});
|
||||||
|
utils.recordAPICoverage(testRunner, filteredApi, browserConfig.events, browserConfig.missingCoverage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.CI && testRunner.hasFocusedTestsOrSuites()) {
|
if (process.env.CI && testRunner.hasFocusedTestsOrSuites()) {
|
||||||
console.error('ERROR: "focused" tests/suites are prohibited on bots. Remove any "fit"/"fdescribe" declarations.');
|
console.error('ERROR: "focused" tests/suites are prohibited on bots. Remove any "fit"/"fdescribe" declarations.');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue