kiwigrid/gherkin-testcafe

Possible Get Json Report From CucumberJs Post Test Run

Opened this issue ยท 12 comments

Hi there,

I checked out your project. Super work btw ๐Ÿ‘. I want to use testcafe but ideally I want to use it with Gherkin as it's good to present to the business how folk test. As you know DevExpress at this point in time don't support Cucumber/Gherkin hence I came across your project.

I notice you support pretty much all Testcafe functionality plus most Gherkin functionality. As Cucumber is been used to run the tests I don't see a way though of getting the JSON report that gets generated at the end of the test run. That JSON is very useful as it can be sent to other modules for reporting (for example https://github.com/jenkinsci/cucumber-reports-plugin)

Is that something that is supported out of the box at this point in time or not? Btw when is version 2.0 of this library coming? Many thanks for any help with any of the above.

Maybe this module

https://www.npmjs.com/package/testcafe-reporter-cucumber-json

can help with this issue?

Hey @bhreinb!

I'm sorry, but currently, this is not supported.

I will evaluate the possibility to add support for this next week.

Hey that's super. Let me know if I can help. Btw when do you plan to release version 2 if you don't mind me asking?

There is no plan yet. I want to rework the implementation for version 2, but in the upcoming weeks, I do not have the time so do it.

Any updates about getting json report in cucumber format ?

I'm sorry, there has been no progress so far.
And I also don't think that I will find the time to add this feature in the near future.

Hi @Lukas-Kullmann , excuse me for disturbing you, do u have any updates under this topic?

No, there have not been any updates on this topic.

I use this as a work-around

const cucumber = require('cucumber');

function Given(pattern, callback) {
    cucumber.Given(pattern, async (p1, p2, p3, p4) => {
        console.log('    Given ' + pattern);
        await callback(p1, p2, p3, p4);
    });
}

function When(pattern, callback) {
    cucumber.When(pattern, async (p1, p2, p3, p4) => {
        console.log('    When ' + pattern);
        await callback(p1, p2, p3, p4);
    });
}

function Then(pattern, callback) {
    cucumber.Then(pattern, async (p1, p2, p3, p4) => {
        console.log('    Then ' + pattern);
        await callback(p1, p2, p3, p4);
    });
}

module.exports = {
    Given,
    When,
    Then
};

@christoph-daehne your solution works, thinking about a neat way of turning it off/on, since it clutter up the console. Still, this is amazing and makes my life so much easier when I am trying to figure out: Where the #@%@#! did it break!

Hi @dthisner here is how I turn on/off logs.

import * as logger from 'pino'
import * as pinoCaller from 'pino-caller'
import { ensureProperties } from 'safe-json-stringify'
import { Stream } from 'stream'



const LEVEL = {
  60: 'fatal', 
  50: 'error', 
  40: 'warn', 
  30: 'info', 
  20: 'debug', 
  10: 'trace' .
}

export class LogStream extends Stream.Writable {
  write = data => {
    const { LOG_MODE } = process.env
    const obj = JSON.parse(data)

    if (LOG_MODE === 'json') {
      obj.time = undefined
      obj.level = LEVEL[obj.level]
      obj['log_time'] = Date.now()

      obj.request = obj.req
      obj.response = obj.res
      obj.req = undefined
      obj.res = undefined
      obj['response-hrtime'] = undefined
    }

    data = JSON.stringify(ensureProperties(obj))
    return process.stdout.write(data + '\n')
  }
}
export const log = pinoCaller(logger(new LogStream())).child({ level: process.env.LOG_LEVEL || 'info' })

Hi there!
I must say, really nice project! I was wondering, as I also started a gherkin-testcafe integration project (end of 2018), if you could maybe find sth useful (reporting, etc.) there (link below) that might be of help and can imporove this project?

https://github.com/alexej-strelzow/testcafe-cucumber-typescript

My solution does not support concurrency and live-mode, but does reporting (incl. screenshots) well and I am thinking to maybe switch to yours in future... Unfortunately I did not have the time yet to play around with it, so I don't know where my project could contribute.

Please let me know what you think and if you have any questions.