Skip to content

Allow to pass custom naming strategyΒ #74

@vitalets

Description

@vitalets

πŸ€” What's the problem you're trying to solve?

I need to use custom strategy for testcase naming, actually adding a Playwright project name (see microsoft/playwright#23432).
Currently, naming strategy is hardcoded.

✨ What's your proposed solution?

Something like:

  formatter({
    options,
    on,
    write,
+    namingStrategy = NAMING_STRATEGY
  }: {
    options: { suiteName?: string }
    on: (type: 'message', handler: (message: Envelope) => void) => void
    write: (content: string) => void
+    namingStrategy: NamingStrategy
  }) {
    const query = new Query()
    const builder = xmlbuilder
      .create('testsuite', { invalidCharReplacement: '' })
      .att('name', options.suiteName || 'Cucumber')

    on('message', (message) => {
      query.update(message)

      if (message.testRunFinished) {
-        const testSuite = makeReport(query)
+       const testSuite = makeReport(query, { namingStrategy })

Ideally, it would be great to be able to pass arbitrary function, e.g. (lineage: Lineage) => string.

⛏ Have you considered any alternatives or workarounds?

No response

πŸ“š Any additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions