Skip to content
2 changes: 2 additions & 0 deletions bin/codecept.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ program
.option(commandFlags.steps.flag, commandFlags.steps.description)
.option(commandFlags.verbose.flag, commandFlags.verbose.description)
.option(commandFlags.debug.flag, commandFlags.debug.description)
.option('--no-ansi', 'disable colored / ANSI-styled output')
.option('--numbers', 'prefix each step with a per-test index number')
.action(commandHandler('../lib/command/dryRun.js'))

program
Expand Down
14 changes: 14 additions & 0 deletions lib/command/dryRun.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chalk from 'chalk'
import { getConfig, getTestRoot } from './utils.js'
import Config from '../config.js'
import Codecept from '../codecept.js'
Expand All @@ -8,6 +9,7 @@ import Container from '../container.js'

export default async function (test, options) {
if (options.grep) process.env.grep = options.grep
if (options.ansi === false) chalk.level = 0
const configFile = options.config
let codecept

Expand Down Expand Up @@ -37,6 +39,7 @@ export default async function (test, options) {
await printTests(codecept.testFiles)
return
}
if (options.numbers) numberSteps()
event.dispatcher.on(event.all.result, printFooter)
await codecept.run(test)
} catch (err) {
Expand All @@ -45,6 +48,17 @@ export default async function (test, options) {
}
}

function numberSteps() {
let stepIndex = 0
event.dispatcher.on(event.test.before, () => {
stepIndex = 0
})
event.dispatcher.prependListener(event.step.before, step => {
stepIndex++
step.prefix = `${stepIndex}. ${step.prefix || ''}`
})
}

async function printTests(files) {
const { default: figures } = await import('figures')
const { default: colors } = await import('chalk')
Expand Down