libreoffice-online/cypress_test/plugins/index.js
Tamás Zolnai 5149305dba cypress: better way of filter out tests based on core version.
We use cypress-select-tests to filter out tests before
the tests are started. One advantage is that these tests
are showed as skipped in the log and also beforeAll() is
not called for these test cases which can speed things up.

Also we can avoid to add too much noise to the test code.
When we are working with more branches, we can just add
blacklists separately for all branches.

Change-Id: Ie7808614e42a19a0820f372720cc391511e165f5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95585
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2020-06-06 17:53:37 +02:00

57 lines
1.5 KiB
JavaScript

/* global require */
var process = require('process');
var tasks = require('./tasks');
var blacklists = require('./blacklists');
var selectTests = require('cypress-select-tests');
function plugin(on, config) {
on('task', {
copyFile: tasks.copyFile,
failed: require('cypress-failed-log/src/failed')()
});
on('before:browser:launch', function(browser, launchOptions) {
if (browser.family === 'chromium' && process.env.ENABLE_LOGGING) {
launchOptions.args.push('--enable-logging=stderr');
launchOptions.args.push('--v=2');
return launchOptions;
}
});
on('file:preprocessor', selectTests(config, pickTests));
return config;
}
function getLOVersion(config) {
var versionString = config.env.LO_CORE_VERSION;
if (versionString.includes('Collabora')) {
if (versionString.includes(' 6.2.')) {
return 'cp-6-2';
} else if (versionString.includes(' 6.4.')) {
return 'cp-6-4';
}
}
return 'master';
}
function pickTests(filename, foundTests, config) {
var coreVersion = getLOVersion(config);
var testsToRun = foundTests;
if (!(coreVersion in blacklists.testBlackLists))
return testsToRun;
var blackList = blacklists.testBlackLists[coreVersion];
for (var i = 0; i < blackList.length; i++) {
if (filename.endsWith(blackList[i][0])) {
if (blackList[i][1].length === 0) // skip the whole test suite
return [];
testsToRun = testsToRun.filter(fullTestName => !blackList[i][1].includes(fullTestName[1]));
}
}
return testsToRun;
}
module.exports = plugin;