Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove module.export.describe wrapper #1716

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
600 changes: 298 additions & 302 deletions test/accessibility.spec.js

Large diffs are not rendered by default.

96 changes: 47 additions & 49 deletions test/apicoverage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,56 +48,54 @@ function traceAPICoverage(apiCoverage, events, className, classType) {
}
}

module.exports.describe = function({browserType}) {
describe('**API COVERAGE**', () => {
const BROWSER_CONFIGS = [
{
name: 'Firefox',
events: require('../lib/events').Events,
missingCoverage: ['browserContext.setGeolocation', 'browserContext.setOffline', 'cDPSession.send', 'cDPSession.detach'],
describe.skip(!process.env.COVERAGE)('**API COVERAGE**', () => {
const BROWSER_CONFIGS = [
{
name: 'Firefox',
events: require('../lib/events').Events,
missingCoverage: ['browserContext.setGeolocation', 'browserContext.setOffline', 'cDPSession.send', 'cDPSession.detach'],
},
{
name: 'WebKit',
events: require('../lib/events').Events,
missingCoverage: ['browserContext.clearPermissions', 'cDPSession.send', 'cDPSession.detach'],
},
{
name: 'Chromium',
events: {
...require('../lib/events').Events,
...require('../lib/chromium/events').Events,
},
{
name: 'WebKit',
events: require('../lib/events').Events,
missingCoverage: ['browserContext.clearPermissions', 'cDPSession.send', 'cDPSession.detach'],
},
{
name: 'Chromium',
events: {
...require('../lib/events').Events,
...require('../lib/chromium/events').Events,
},
missingCoverage: [],
},
];
const browserConfig = BROWSER_CONFIGS.find(config => config.name.toLowerCase() === browserType.name());
const events = browserConfig.events;
const api = require('../lib/api');
missingCoverage: [],
},
];
const browserConfig = BROWSER_CONFIGS.find(config => config.name.toLowerCase() === browserType.name());
const events = browserConfig.events;
const api = require('../lib/api');

const coverage = new Map();
Object.keys(api).forEach(apiName => {
if (BROWSER_CONFIGS.some(config => apiName.startsWith(config.name)) && !apiName.startsWith(browserConfig.name))
return;
traceAPICoverage(coverage, events, apiName, api[apiName]);
});
const coverage = new Map();
Object.keys(api).forEach(apiName => {
if (BROWSER_CONFIGS.some(config => apiName.startsWith(config.name)) && !apiName.startsWith(browserConfig.name))
return;
traceAPICoverage(coverage, events, apiName, api[apiName]);
});

it('should call all API methods', () => {
const ignoredMethods = new Set(browserConfig.missingCoverage);
const missingMethods = [];
const extraIgnoredMethods = [];
for (const method of coverage.keys()) {
// Sometimes we already have a background page while launching, before adding a listener.
if (method === 'chromiumBrowserContext.emit("backgroundpage")')
continue;
if (!coverage.get(method) && !ignoredMethods.has(method))
missingMethods.push(method);
else if (coverage.get(method) && ignoredMethods.has(method))
extraIgnoredMethods.push(method);
}
if (extraIgnoredMethods.length)
throw new Error('Certain API Methods are called and should not be ignored: ' + extraIgnoredMethods.join(', '));
if (missingMethods.length)
throw new Error('Certain API Methods are not called: ' + missingMethods.join(', '));
});
it('should call all API methods', () => {
const ignoredMethods = new Set(browserConfig.missingCoverage);
const missingMethods = [];
const extraIgnoredMethods = [];
for (const method of coverage.keys()) {
// Sometimes we already have a background page while launching, before adding a listener.
if (method === 'chromiumBrowserContext.emit("backgroundpage")')
continue;
if (!coverage.get(method) && !ignoredMethods.has(method))
missingMethods.push(method);
else if (coverage.get(method) && ignoredMethods.has(method))
extraIgnoredMethods.push(method);
}
if (extraIgnoredMethods.length)
throw new Error('Certain API Methods are called and should not be ignored: ' + extraIgnoredMethods.join(', '));
if (missingMethods.length)
throw new Error('Certain API Methods are not called: ' + missingMethods.join(', '));
});
};
});
Loading