allure-js icon indicating copy to clipboard operation
allure-js copied to clipboard

[allure-js] Cannot start new step using v.2.0.0-beta.18 with cucumber-js

Open fguidobaldi opened this issue 2 years ago • 13 comments

currentExecutable throws "No executable!" error when trying to execute startStep function.

Error: No executable!
           at CucumberAllureInterface.get currentExecutable [as currentExecutable] (/Users/fguidobaldi/Repositorios/fury_qaautomation/node_modules/allure-cucumberjs/dist/src/CucumberAllureInterface.js:65:15)
           at CucumberAllureInterface.startStep (/Users/fguidobaldi/Repositorios/fury_qaautomation/node_modules/allure-cucumberjs/dist/src/CucumberAllureInterface.js:74:33)
           at attachRequestAndResponse (/Users/fguidobaldi/Repositorios/fury_qaautomation/features/steps/when.js:410:33)
           at World.<anonymous> (/Users/fguidobaldi/Repositorios/fury_qaautomation/features/steps/when.js:176:7)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)

I added plain Reporter code following the docs (https://github.com/allure-framework/allure-js/blob/master/packages/allure-cucumberjs/README.md), but it doesn't work out.

const { CucumberJSAllureFormatter } = require('allure-cucumberjs');
const { AllureRuntime } = require('allure-cucumberjs');

function Reporter(options) {
  return new CucumberJSAllureFormatter(
    options,
    new AllureRuntime({ resultsDir: './allure-results' }),
    {},
  );
}
Reporter.prototype = Object.create(CucumberJSAllureFormatter.prototype);
Reporter.prototype.constructor = Reporter;

exports.default = Reporter;

This code was working with v.2.0.0-beta.9 and Cucumber 6

Expected behavior I should be able to create new steps using newer versions of allure-js.

fguidobaldi avatar Aug 03 '22 17:08 fguidobaldi

Hi @baev! Sorry to tag you, but since you were working on Cucumber integration, do you have any thoughts about this?

I'm glad to contribute with some PR, but I'm not sure about this error I'm getting. In fact, that currentExecutable getter is explicitly throwing an error, there's no additional code inside that function (https://github.com/allure-framework/allure-js/blob/master/packages/allure-cucumberjs/src/CucumberAllureInterface.ts#L88).

Am I using this library the wrong way?

fguidobaldi avatar Aug 04 '22 21:08 fguidobaldi

Hey, @fguidobaldi! Thank you for the issue! Could you please try next code for your reporter?

const { CucumberJSAllureFormatter } = require("allure-cucumberjs");
const { AllureRuntime } = require("allure-cucumberjs");

class Reporter extends CucumberJSAllureFormatter {
  constructor(options) {
    super(
      options,
      new AllureRuntime({ resultsDir: "./allure-results" }),
      {}
    );
  }
}

module.exports = Reporter;

class supports widely even in early node.js version, there shouldn't be any problem to use them.

epszaw avatar Aug 05 '22 10:08 epszaw

Hi @lamartire! I tried the snippet you shared, but I'm getting the same error. This is my code, working just fine with v.2.0.0-beta.9

function attachRequestAndResponse(world, response) {
  const testStep = world.allure.startStep(`Test #${world.count}`);

  const step = world.allure.startStep('Request');
  world.attach(JSON.stringify(response.request._data), 'application/json');
  step.endStep();

  attachResponse(world, response);

  testStep.endStep();

  world.count += 1;
}

Currently, when execution reaches world.allure.startStep('Request'), it throws the "No executable" error mentioned above.

fguidobaldi avatar Aug 05 '22 13:08 fguidobaldi

Is it possible to share the repository code or create an example where I can reproduce the problem?

epszaw avatar Aug 05 '22 13:08 epszaw

I'm working on PoC to reproduce this issue, I'll send it as soon as I finish it.

fguidobaldi avatar Aug 05 '22 21:08 fguidobaldi

Hi @lamartire! I created this repo with the minimum code to reproduce the issue. I created two branches to compare expected (with cucumber 6 and allure-cucumberjs beta.9) and actual (cucumber 8 and allure-cucumberjs beta.18) behaviors.

Please let me know if I can help you with anything else!

fguidobaldi avatar Aug 08 '22 14:08 fguidobaldi

Thank you! Will check it as soon as it possible

epszaw avatar Aug 13 '22 16:08 epszaw

I can' reproduce the problem on my local machine. Which environment do you have?

image

epszaw avatar Aug 13 '22 16:08 epszaw

Hi @lamartire! Yes, in master branch, with older versions of cucumber and allure-js, it works just fine.

If you switch to test/allure_v2.0.0-beta.18 branch (which only has a dependency update to cucumber 8 and allure-js beta 18), you should be able to reproduce the issue.

Please let me know!

fguidobaldi avatar Aug 16 '22 13:08 fguidobaldi

Hi @lamartire! Were you able to reproduce the issue in branch test/allure_v2.0.0-beta.18?

fguidobaldi avatar Aug 23 '22 12:08 fguidobaldi

Yes, I've reproduced the issue, still working on that. Will notify you as soon as I get any working result

epszaw avatar Aug 24 '22 13:08 epszaw

So, I found the problem. The reporter broke after we had merged commit introducing ability to keep all the running tests for parallel mode in the reporter. Need some time to understand, how I can solve the problem

epszaw avatar Aug 25 '22 19:08 epszaw

Glad to know that you were able to find the problem! Let me know if I can help with anything, I'll be looking forward for this!

fguidobaldi avatar Aug 30 '22 19:08 fguidobaldi

Hi @epszaw! Are there any news on this?

fguidobaldi avatar Nov 16 '22 18:11 fguidobaldi

Hey, @fguidobaldi! It's almost ready. After a long break I returned back to the issue

epszaw avatar Nov 17 '22 07:11 epszaw

@fguidobaldi the latest release contains the fix. Please, write updated documentation before use :)

epszaw avatar Nov 23 '22 14:11 epszaw

Hi @epszaw! Great news! I'll give it a try as soon as I can, thank you!

fguidobaldi avatar Dec 07 '22 12:12 fguidobaldi

Hi @epszaw! I was trying to implement the same structure, with nested steps like these, but I didn't find any reference in docs.

image

My code looks like this:

await world.step(`Test 1`, async () => {
    await world.step(`Request`, (step) => {
      step.attach(JSON.stringify(request.data), 'application/json');
    });
    await world.step(`Response`, (step) => {
      step.attach(JSON.stringify(response.data), 'application/json');
    });
  });

But the steps are created all at the same level, not "Request" and Response inside "Test 1". The fix includes any limitation related to sub-steps? Or am I implementing it the wrong way?

fguidobaldi avatar Dec 22 '22 19:12 fguidobaldi