Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env node
const yargs = require('yargs');
const createTestCafe = require('testcafe');
const { getInstallations } = require('testcafe-browser-tools');
const DELAY = 10000;
let testcafe = null;
const argv = yargs
.option('browser', {
alias: 'b',
default: false
})
.help().argv;
getInstallations().then(browsers =>
createTestCafe('localhost', 1337, 1338)
.then((tc) => {
testcafe = tc;
const runner = testcafe.createRunner();
const browser = argv.browser || Object.keys(browsers).slice(0, 1);
return runner
.startApp('npm run start', DELAY)
.src(['./testcafe/index.tests.js'])
.browsers(browser)
.run();
})
.then((exitCode) => {
testcafe.close();
process.exit(exitCode);
})
);
function testClient (tests, settings, envSettings, cliMode) {
function runTests (env, runOpts) {
return gulp
.src(tests)
.pipe(qunitHarness(settings, env, runOpts));
}
if (!cliMode)
return runTests(envSettings);
return listBrowsers().then(browsers => {
const browserNames = Object.keys(browsers);
const targetBrowsers = [];
browserNames.forEach(browserName => {
if (CLIENT_TEST_LOCAL_BROWSERS_ALIASES.includes(browserName))
targetBrowsers.push({ browserInfo: browsers[browserName], browserName: browserName });
});
return runTests({ browsers: targetBrowsers }, { cliMode: true });
});
}
async getBrowserList () {
const installations = await browserTools.getInstallations();
return Object.keys(installations);
},