Skip to content

Commit

Permalink
test: remove module.export.describe wrapper (#1716)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman authored Apr 8, 2020
1 parent 2ef8e26 commit ade9d23
Show file tree
Hide file tree
Showing 44 changed files with 10,408 additions and 10,620 deletions.
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

0 comments on commit ade9d23

Please sign in to comment.