Skip to content

Commit

Permalink
feat: add logging to launcher.js
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Mucha <jakub.mucha@icloud.com>
  • Loading branch information
drptbl committed Oct 7, 2022
1 parent c851ea1 commit b2e9f32
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions launcher.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const log = require('debug')('synpress:launcher');
const cypress = require('cypress');
const helpers = require('./helpers');
const synpressConfigPath = `${helpers.getSynpressPath()}/synpress.config.js`;
log(`Detected synpress config path is: ${synpressConfigPath}`);

process.env.CYPRESS_REMOTE_DEBUGGING_PORT = 9222;

Expand All @@ -23,58 +25,78 @@ const launcher = {
},
async run(arguments_) {
if (arguments_.configFile) {
log(`Custom config file arg detected: ${arguments_.configFile}`);
defaultArguments.push(`--config-file=${arguments_.configFile}`);
} else {
log('Using default config file');
defaultArguments.push(`--config-file=${synpressConfigPath}`);
}
log(`Tests will run on ${arguments_.browser} browser`);
defaultArguments.push(`--browser=${arguments_.browser}`);
if (arguments_.config) {
log(`Custom config arg detected: ${defaultConfig},${arguments_.config}`);
defaultArguments.push(`--config=${defaultConfig},${arguments_.config}`);
} else {
log(`Using default config: ${defaultConfig}`);
defaultArguments.push(`--config=${defaultConfig}`);
}
if (arguments_.env) {
log(`Custom env arg detected: ${arguments_.env}`);
defaultArguments.push(`--env=${arguments_.env}`);
}
if (arguments_.spec) {
log(`Custom spec arg detected: ${arguments_.spec}`);
defaultArguments.push(`--spec=${arguments_.spec}`);
}
if (arguments_.noExit) {
log(`noExit arg enabled`);
defaultArguments.push('--no-exit');
}
if (arguments_.project) {
log(`Custom project arg detected: ${arguments_.project}`);
defaultArguments.push(`--project=${arguments_.project}`);
}
if (arguments_.quiet) {
log(`quiet arg enabled`);
defaultArguments.push('--quiet');
}
if (arguments_.reporter) {
log(`Custom reporter arg detected: ${arguments_.reporter}`);
defaultArguments.push(`--reporter=${arguments_.reporter}`);
}
if (arguments_.reporterOptions) {
log(`Custom reporterOptions arg detected: ${arguments_.reporterOptions}`);
defaultArguments.push(`--reporter-options=${arguments_.reporterOptions}`);
}
if (arguments_.ciBuildId) {
log(`Custom ciBuildId arg detected: ${arguments_.ciBuildId}`);
defaultArguments.push(`--ci-build-id=${arguments_.ciBuildId}`);
}
if (arguments_.record) {
log(`record arg enabled`);
defaultArguments.push('--record');
}
if (arguments_.key) {
log(`Custom key arg detected: ${arguments_.key}`);
defaultArguments.push(`--key=${arguments_.key}`);
}
if (arguments_.parallel) {
log(`parallel arg enabled`);
defaultArguments.push('--parallel');
}
if (arguments_.group) {
log(`Custom group arg detected: ${arguments_.group}`);
defaultArguments.push(`--group=${arguments_.group}`);
}
if (arguments_.tag) {
log(`Custom tag arg detected: ${arguments_.tag}`);
defaultArguments.push(`--tag=${arguments_.tag}`);
}

const runOptions = await cypress.cli.parseRunArguments(defaultArguments);
log(
`Running synpress with following options: ${JSON.stringify(runOptions)}`,
);
const results = await cypress.run(runOptions);
if (results.failures) {
console.error('Failed to run Cypress');
Expand Down

0 comments on commit b2e9f32

Please sign in to comment.