syndesisio / syndesis-ui

The front end application or UI for Syndesis - a flexible, customizable, cloud-hosted platform that provides core integration capabilities as a service. It leverages Red Hat's existing product architecture using OpenShift Online/Dedicated and Fuse Integration Services.
https://syndesis.io/
14 stars 28 forks source link

Use cucumber for e2e tests #190

Closed jludvice closed 7 years ago

jludvice commented 7 years ago

Consider https://github.com/samvloeberghs/protractor-gherkin-cucumberjs-angular2 EDIT this is just template project.

jludvice commented 7 years ago

Adding following npm dev dependencies

  "devDependencies": {
    "@types/cucumber": "^0.0.37",
    "cucumber": "^1.3.1",
    "cucumber-tsflow": "^1.1.2",
    "protractor-cucumber-framework": "^0.6.0",
  }

protractor-cucumber-framework configuration - protractor.conf.js

  specs: [
    // specs are feature files
    './features/**/*.feature'
  ],
 // switch jasmine to custom (cucumber is not supported framework) 
 framework: 'custom',
  frameworkPath: require.resolve('protractor-cucumber-framework'),
  cucumberOpts: {
    require: [
       // load steps definitions
      'features/**/*.steps.ts'
    ],
    format: 'pretty'
  },

include cucumber-tsflow to specify cucumber feautre <=> step binding with typescript annotations Example

  Scenario: Adding two numbers
    Given I enter '2' and '8'
  @given(/^I enter '(\d+)' and '(\d+)'$/)
  public givenTwoNumbers(num1: string, num2: string, callback: CallbackStepDefinition): void {
jludvice commented 7 years ago

Add chai and chai-as-promised for assert/expectations on promise objects https://github.com/domenic/chai-as-promised

jludvice commented 7 years ago

Added https://www.npmjs.com/package/cucumber-html-reporter to generate html report.

I needed to create env.js file where are some cucumber configurations, like

working example of env.js (note it must be included in protractor.conf.js)

module.exports = function () {

  this.setDefaultTimeout(400 * 1000);

  /**
   * create screenshot after each cucumber scenario
   */
  this.After(function (scenario, next) {
    browser.takeScreenshot().then(function (png) {
      var decodedImage = new Buffer(png, 'base64');
      scenario.attach(decodedImage, 'image/png', next);
    }, function (err) {
      next(err);
    });
  });

};

Lot of comments suggest this snipped for attaching screenshots, but it didn't work for me because data was encoded incorrectly - needed to remove .toString('binary');

      browser.takeScreenshot().then(function (png) {
        var fs = require('fs');

        //var base64Image = new Buffer(png, 'binary').toString('base64');
        var decodedImage = new Buffer(png, 'base64').toString('binary');

        scenario.attach(decodedImage, 'image/png');
      });
kahboom commented 7 years ago

Completed w/ https://github.com/redhat-ipaas/ipaas-ui/pull/308