gherkin-testcafe icon indicating copy to clipboard operation
gherkin-testcafe copied to clipboard

Possible Get Json Report From CucumberJs Post Test Run

Open bhreinb opened this issue 6 years ago • 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.

bhreinb avatar Aug 15 '18 14:08 bhreinb

Maybe this module

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

can help with this issue?

bhreinb avatar Aug 17 '18 10:08 bhreinb

Hey @bhreinb!

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

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

Lukas-Kullmann avatar Aug 17 '18 18:08 Lukas-Kullmann

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?

bhreinb avatar Aug 17 '18 19:08 bhreinb

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.

Lukas-Kullmann avatar Aug 20 '18 15:08 Lukas-Kullmann

Any updates about getting json report in cucumber format ?

Ivan-Katovich avatar Apr 16 '19 07:04 Ivan-Katovich

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.

Lukas-Kullmann avatar Apr 16 '19 08:04 Lukas-Kullmann

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

maximkoev avatar Jul 03 '19 12:07 maximkoev

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

Lukas-Kullmann avatar Jul 08 '19 07:07 Lukas-Kullmann

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 avatar Sep 02 '19 13:09 christoph-daehne

@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!

dthisner avatar Sep 04 '19 18:09 dthisner

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' })

maximkoev avatar Oct 28 '19 14:10 maximkoev

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.

alexej-strelzow avatar Feb 02 '20 11:02 alexej-strelzow