Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Possible Get Json Report From CucumberJs Post Test Run #7

Open
bhreinb opened this issue Aug 15, 2018 · 12 comments
Open

Possible Get Json Report From CucumberJs Post Test Run #7

bhreinb opened this issue Aug 15, 2018 · 12 comments
Labels
enhancement New feature or request

Comments

@bhreinb
Copy link

bhreinb commented Aug 15, 2018

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
Copy link
Author

bhreinb commented Aug 17, 2018

Maybe this module

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

can help with this issue?

@Lukas-Kullmann
Copy link
Contributor

Hey @bhreinb!

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

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

@bhreinb
Copy link
Author

bhreinb commented Aug 17, 2018

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?

@Lukas-Kullmann
Copy link
Contributor

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.

@Ivan-Katovich
Copy link

Any updates about getting json report in cucumber format ?

@Lukas-Kullmann
Copy link
Contributor

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.

@maximkoev
Copy link

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

@Lukas-Kullmann
Copy link
Contributor

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

@christoph-daehne
Copy link

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
};

@dthisner
Copy link

dthisner commented Sep 4, 2019

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

@maximkoev
Copy link

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

@alexej-strelzow
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants