Search code examples
typescriptjasmineprotractorallure

Allure.createStep is not a function


I wanted to add the Test Step to Allure Reporting and in Allure API its given that create step can be used.

I am using the function as

import {allureReporter} from "./../node_modules/jasmine-allure-reporter/src/Jasmine2AllureReporter.js";

allure.createStep('Outer step', function() {})

But it's throwed error that createStep is not function.

However, when i see the 'Jasmine2AllureReporter.js' file there is no function allure.createStep.

So can you please help me how to usee the allure API in my Protractor Test with jasmine2 framework?


Solution

  • You are trying to use Allure report incorrectly. Look at the Readme of Allure-jasmine package

    You need to add the following content into your protractor.conf.js file:

    exports.config = {
      // I assume that you already have this line
      framework: 'jasmine2',
      onPrepare: function() {
        var AllureReporter = require('jasmine-allure-reporter');
        jasmine.getEnv().addReporter(new AllureReporter({
          resultsDir: 'allure-results'
        }));
      }
    }
    

    Allure-reporter should be installed at onPrepare stage. Global allure object will be injected into your test code automatically with proper context. No need to import anything extra.

    Also, if you later see problems with Typescript, look at this issue for a solution.