Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const main = async (args: Arguments) => {
const { EvaluatedScript, nullRuntimeEnvironment } = require('@flood/element-api')
const script = await EvaluatedScript.mustCompileFile(args.file, nullRuntimeEnvironment)
if (args.json) return printJSON(script)
const { settings, steps } = script
console.log(
boxen(
chalk`test script
{blue ${settings.name || ''}}
{blue ${settings.description || ''}}`,
{ padding: 1, margin: 1, align: 'center' },
),
)
console.log(chalk`{blue Settings}:`)
console.log(inspect(settings, { colors: true }))
runUntilExit(() => runCommandLine(opts))
},
function initRunEnv(root: string, testDataRoot: string) {
const workRoot = new WorkRoot(root, {
'test-data': testDataRoot,
})
return {
workRoot,
stepEnv(): FloodProcessEnv {
return {
BROWSER_ID: 0,
FLOOD_GRID_REGION: 'local',
FLOOD_GRID_SQEUENCE_ID: 0,
FLOOD_GRID_SEQUENCE_ID: 0,
FLOOD_GRID_INDEX: 0,
FLOOD_GRID_NODE_SEQUENCE_ID: 0,
FLOOD_NODE_INDEX: 0,
FLOOD_SEQUENCE_ID: 0,
FLOOD_PROJECT_ID: 0,
testLifecycle(stage: TestEvent, label: string): void {
switch (stage) {
case TestEvent.AfterStepAction:
this.logger.info(`---> ${label}()`)
break
case TestEvent.BeforeStep:
this.logger.info('')
this.logger.info(`===> Step '${label}'`)
break
case TestEvent.AfterStep:
this.logger.info(`---> Step '${label}' finished`)
break
case TestEvent.StepSkipped:
this.logger.info(`---- Step '${label}' skipped`)
break
case TestEvent.StepFailed:
this.logger.error(`xxxx Step '${label}' failed`)
break
}
}
testLifecycle(stage: TestEvent, label: string): void {
switch (stage) {
case TestEvent.AfterStepAction:
this.logger.info(`---> ${label}()`)
break
case TestEvent.BeforeStep:
this.logger.info('')
this.logger.info(`===> Step '${label}'`)
break
case TestEvent.AfterStep:
this.logger.info(`---> Step '${label}' finished`)
break
case TestEvent.StepSkipped:
this.logger.info(`---- Step '${label}' skipped`)
break
case TestEvent.StepFailed:
this.logger.error(`xxxx Step '${label}' failed`)
break
}
testLifecycle(stage: TestEvent, label: string): void {
switch (stage) {
case TestEvent.AfterStepAction:
this.logger.info(`---> ${label}()`)
break
case TestEvent.BeforeStep:
this.logger.info('')
this.logger.info(`===> Step '${label}'`)
break
case TestEvent.AfterStep:
this.logger.info(`---> Step '${label}' finished`)
break
case TestEvent.StepSkipped:
this.logger.info(`---- Step '${label}' skipped`)
break
case TestEvent.StepFailed:
this.logger.error(`xxxx Step '${label}' failed`)
break
}
}
testLifecycle(stage: TestEvent, label: string): void {
switch (stage) {
case TestEvent.AfterStepAction:
this.logger.info(`---> ${label}()`)
break
case TestEvent.BeforeStep:
this.logger.info('')
this.logger.info(`===> Step '${label}'`)
break
case TestEvent.AfterStep:
this.logger.info(`---> Step '${label}' finished`)
break
case TestEvent.StepSkipped:
this.logger.info(`---- Step '${label}' skipped`)
break
case TestEvent.StepFailed:
this.logger.error(`xxxx Step '${label}' failed`)
break
}
}
testLifecycle(stage: TestEvent, label: string): void {
switch (stage) {
case TestEvent.AfterStepAction:
this.logger.info(`---> ${label}()`)
break
case TestEvent.BeforeStep:
this.logger.info('')
this.logger.info(`===> Step '${label}'`)
break
case TestEvent.AfterStep:
this.logger.info(`---> Step '${label}' finished`)
break
case TestEvent.StepSkipped:
this.logger.info(`---- Step '${label}' skipped`)
break
case TestEvent.StepFailed:
this.logger.error(`xxxx Step '${label}' failed`)
break
}
}