Skip to content

Commit af8de03

Browse files
author
DavertMik
committed
Merge branch '4.x' of github.com:codeceptjs/CodeceptJS into 4.x
2 parents a57d587 + 890ca6d commit af8de03

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

bin/codecept.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ program
258258
.option(commandFlags.steps.flag, commandFlags.steps.description)
259259
.option(commandFlags.verbose.flag, commandFlags.verbose.description)
260260
.option(commandFlags.debug.flag, commandFlags.debug.description)
261+
.option('--no-ansi', 'disable colored / ANSI-styled output')
262+
.option('--numbers', 'prefix each step with a per-test index number')
261263
.action(commandHandler('../lib/command/dryRun.js'))
262264

263265
program

lib/command/dryRun.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import chalk from 'chalk'
12
import { getConfig, getTestRoot } from './utils.js'
23
import Config from '../config.js'
34
import Codecept from '../codecept.js'
@@ -8,6 +9,7 @@ import Container from '../container.js'
89

910
export default async function (test, options) {
1011
if (options.grep) process.env.grep = options.grep
12+
if (options.ansi === false) chalk.level = 0
1113
const configFile = options.config
1214
let codecept
1315

@@ -37,6 +39,7 @@ export default async function (test, options) {
3739
await printTests(codecept.testFiles)
3840
return
3941
}
42+
if (options.numbers) numberSteps()
4043
event.dispatcher.on(event.all.result, printFooter)
4144
await codecept.run(test)
4245
} catch (err) {
@@ -45,6 +48,17 @@ export default async function (test, options) {
4548
}
4649
}
4750

51+
function numberSteps() {
52+
let stepIndex = 0
53+
event.dispatcher.on(event.test.before, () => {
54+
stepIndex = 0
55+
})
56+
event.dispatcher.prependListener(event.step.before, step => {
57+
stepIndex++
58+
step.prefix = `${stepIndex}. ${step.prefix || ''}`
59+
})
60+
}
61+
4862
async function printTests(files) {
4963
const { default: figures } = await import('figures')
5064
const { default: colors } = await import('chalk')

0 commit comments

Comments
 (0)