bingnz / cucumber-teamcity-formatter

Formatter for cucumber-js to write test output to the console in a format parsable by TeamCity.
MIT License
4 stars 3 forks source link

Cucumber 7 support #80

Open ghost opened 3 years ago

ghost commented 3 years ago

This package doesn't work with the latest version of cucumber, nor does it work with the new @cucumber/cucumber packages.

I get this error when attempting to run with cucumber 7.0.0-rc.0:

Error: Cannot find module 'cucumber/lib/formatter/get_color_fns'
Require stack:
- <project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js
- <project>\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (<project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js:1:1228)
    at n (<project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js:1:349)
    at Module.<anonymous> (<project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js:1:1364)
    at n (<project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js:1:349)
    at <project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js:1:1148
    at <project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js:1:1157
    at <project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js:1:81
    at Object.<anonymous> (<project>\node_modules\cucumber-teamcity-formatter\dist\cucumber-teamcity-formatter.js:1:215)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
ghost commented 3 years ago

I've spent a little bit of time attempting to get this working with the latest version of cucumber by upgrading versions, but the unit tests are failing to pass and don't have the domain knowledge to understand how to fix this.

Please see the attached for an attempted patch.

Unit test errors:

 1 passing (35ms)
  7 failing

  1) TeamCityFormatter
       one scenario with one step
         passed
           "before each" hook for "outputs the TeamCity markers for the feature and scenario":
     TypeError: Cannot read property 'testCaseId' of undefined
      at EventDataCollector.getTestCaseAttempt (node_modules\@cucumber\cucumber\src\formatter\helpers\event_data_collector.ts:53:59)
      at TeamCityFormatter.getTestCaseAttempt (src/cucumber-teamcity-formatter.js:42:37)
      at Context.emit (test\unit/cucumber-teamcity-formatter.js:75:39)
      at processImmediate (internal/timers.js:461:21)

  2) TeamCityFormatter
       one scenario with one step
         test has failed status
           "before each" hook for "includes the error message in the TeamCity markers":
     TypeError: Cannot read property 'testCaseId' of undefined
      at EventDataCollector.getTestCaseAttempt (node_modules\@cucumber\cucumber\src\formatter\helpers\event_data_collector.ts:53:59)
      at TeamCityFormatter.getTestCaseAttempt (src/cucumber-teamcity-formatter.js:42:37)
      at Context.emit (test\unit/cucumber-teamcity-formatter.js:111:43)
      at processImmediate (internal/timers.js:461:21)

  3) TeamCityFormatter
       one scenario with one step
         test has ambiguous status
           "before each" hook for "includes the error message in the TeamCity markers":
     TypeError: Cannot read property 'testCaseId' of undefined
      at EventDataCollector.getTestCaseAttempt (node_modules\@cucumber\cucumber\src\formatter\helpers\event_data_collector.ts:53:59)
      at TeamCityFormatter.getTestCaseAttempt (src/cucumber-teamcity-formatter.js:42:37)
      at Context.emit (test\unit/cucumber-teamcity-formatter.js:111:43)
      at processImmediate (internal/timers.js:461:21)

  4) TeamCityFormatter
       multiple scenarios with multiple steps
         passed
           "before each" hook for "outputs the TeamCity markers for the feature and scenario":
     TypeError: Cannot read property 'testCaseId' of undefined
      at EventDataCollector.getTestCaseAttempt (node_modules\@cucumber\cucumber\src\formatter\helpers\event_data_collector.ts:53:59)
      at TeamCityFormatter.getTestCaseAttempt (src/cucumber-teamcity-formatter.js:42:37)
      at Context.emit (test\unit/cucumber-teamcity-formatter.js:184:39)
      at processImmediate (internal/timers.js:461:21)

  5) TeamCityFormatter
       multiple scenarios with multiple steps
         skipped
           "before each" hook for "outputs the TeamCity markers for the feature and scenario":
     TypeError: Cannot read property 'testCaseId' of undefined
      at EventDataCollector.getTestCaseAttempt (node_modules\@cucumber\cucumber\src\formatter\helpers\event_data_collector.ts:53:59)
      at TeamCityFormatter.getTestCaseAttempt (src/cucumber-teamcity-formatter.js:42:37)
      at Context.emit (test\unit/cucumber-teamcity-formatter.js:258:39)
      at processImmediate (internal/timers.js:461:21)

  6) TeamCityFormatter
       multiple scenarios with multiple steps
         test has failed status
           "before each" hook for "includes the error message in the TeamCity markers":
     TypeError: Cannot read property 'testCaseId' of undefined
      at EventDataCollector.getTestCaseAttempt (node_modules\@cucumber\cucumber\src\formatter\helpers\event_data_collector.ts:53:59)
      at TeamCityFormatter.getTestCaseAttempt (src/cucumber-teamcity-formatter.js:42:37)
      at Context.emit (test\unit/cucumber-teamcity-formatter.js:333:43)
      at processImmediate (internal/timers.js:461:21)

  7) TeamCityFormatter
       multiple scenarios with multiple steps
         test has ambiguous status
           "before each" hook for "includes the error message in the TeamCity markers":
     TypeError: Cannot read property 'testCaseId' of undefined
      at EventDataCollector.getTestCaseAttempt (node_modules\@cucumber\cucumber\src\formatter\helpers\event_data_collector.ts:53:59)
      at TeamCityFormatter.getTestCaseAttempt (src/cucumber-teamcity-formatter.js:42:37)
      at Context.emit (test\unit/cucumber-teamcity-formatter.js:333:43)
      at processImmediate (internal/timers.js:461:21)
bingnz commented 2 years ago

Hi @irismartinkennish, sorry for the very late reply. I don't have any projects that use cucumberjs any more, but in the latest version they've completely changed the way reporters work and I'd have to rewrite this from scratch. It's not really something I have the capacity to do right now.