Retrofitting

In the most basic scenario, Serenity/JS can act as an integration layer between the Protractor test runner and either of the Cucumber or Mocha test frameworks.

Using Serenity/JS as a drop-in replacement of the cucumber-protractor-framework or the mocha framework adapter that ships with Protractor enables you to:

  • Run your tests in parallel and still get the aggregated test reports.
  • Enhance your test reports with screenshots of your app's UI without any additional plugins.
  • Fix some common problems related to Cucumber/WebDriver ControlFlow synchronisation and inaccurate reporting with just a single config change.
  • Try the Screenplay Pattern in some part of your project while keeping your other tests working as they used to. This way you minimise the risk of disrupting the work of your team while improving your tool set.

To use Serenity/JS as an integration layer between Protractor and Cucumber or Mocha, execute the below terminal command in your project directory to install the serenity-js module and save it as a devDependency in your package.json file:

$> npm install serenity-js --save-dev

With the serenity-js module installed, you can update your Protractor configuration file to include:

exports.config = {
    framework: 'custom',
    frameworkPath: require.resolve('serenity-js'), 
    // ...
}

Serenity/JS detects whether to use Cucumber or Mocha based on the presence of cucumberOpts or mochaOpts, respectively. If you prefer, you can tell Serenity/JS which test framework you'd like to use explicitly too:

exports.config = {
    framework: 'custom',
    frameworkPath: require.resolve('serenity-js'),

    serenity: {
        dialect: 'cucumber'     // or 'mocha'
    }
    // ...
}

That's it! You can execute your tests the same way you used to.

Now you can learn more about the configuration options supported by serenity-mocha and serenity-cucumber adapters and running the tests using their respective test frameworks, or configure the reporting to convert the intermediary JSON reports produced by serenity-js to HTML.


Your feedback matters!

Suggest features and improvements on github, get in touch on twitter, and if you found Serenity/JS useful - don't forget to give it a star! ★

Star

results matching ""

    No results matching ""