2
votes

Hello friends i testing my angular 2 app using protractor and cucumber js but it give me this error i try several solution for this issue but no one can solve my issue.if you know any sol it would be great thank u..

[1] Unhandled rejection TypeError: this.registerHandler is not a function [1] at Object.registerHandlers (/home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:16:8) [1] at /home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:6:22 [1] at Object.defineSupportCode (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/support_code_library_builder/index.js:20:9) [1] at Object. (/home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:5:12) [1] at Module._compile (module.js:570:32) [1] at Object.Module._extensions..js (module.js:579:10) [1] at Module.load (module.js:487:32) [1] at tryModuleLoad (module.js:446:12) [1] at Function.Module._load (module.js:438:3) [1] at Module.require (module.js:497:17) [1] at require (internal/module.js:20:19) [1] at /home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:61:42 [1] at Array.forEach (native) [1] at Cli.getSupportCodeLibrary (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:61:22) [1] at Cli. (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:76:37) [1] at next (native) [1] [17:30:50] E/launcher - BUG: launcher exited with 1 tasks remaining

here is my package.json

{
  "name": "dpt-angular",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "e2e": "concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "pree2e": "webdriver-manager update",
    "test": "concurrently \"tsc -w\" \"karma start karma.conf.js\"",
    "test-once": "karma start karma.conf.js --single-run",
    "tsc": "tsc",
    "tsc:w": "tsc -w"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~2.4.0",
    "@angular/compiler": "~2.4.0",
    "@angular/core": "~2.4.0",
    "@angular/forms": "~2.4.0",
    "@angular/http": "~2.4.0",
    "@angular/platform-browser": "~2.4.0",
    "@angular/platform-browser-dynamic": "~2.4.0",
    "@angular/router": "~3.4.0",
    "@types/file-saver": "0.0.1",
    "angular-in-memory-web-api": "~0.2.4",
    "angular2-moment": "^1.1.0",
    "core-js": "^2.4.1",
    "mydatepicker": "^2.0.25",
    "ng2-completer": "^1.5.2",
    "ng2-file-upload": "^1.2.1",
    "ng2-pdf-viewer": "^1.1.0",
    "rxjs": "5.0.1",
    "systemjs": "0.19.40",
    "zone.js": "^0.7.4"
  },
  "devDependencies": {
    "@types/jasmine": "^2.5.36",
    "@types/node": "^6.0.46",
    "canonical-path": "0.0.2",
    "concurrently": "^3.1.0",
    "cucumber": "^3.0.0",
    "cucumber-tsflow": "^2.2.0",
    "http-server": "^0.9.0",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.4",
    "protractor": "^4.0.14",
    "protractor-cucumber-framework": "^3.0.0",
    "rimraf": "^2.5.4",
    "ts-node": "^3.3.0",
    "tslint": "^3.15.1",
    "typescript": "~2.3.4",
    "webdriver-manager": "^12.0.6"
  },
  "repository": {}
}

and my protractor.conf.json

var fs = require('fs');
var path = require('canonical-path');
var _ = require('lodash');


exports.config = {
  directConnect: true,

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },

    allScriptsTimeout:90000,
    getPageTimeout:400000,
    ignoreUncaughtExceptions: true,
    framework: 'custom',

    frameworkPath: require.resolve('protractor-cucumber-framework'),

    // Spec patterns are relative to this config file
  specs: ['**/cucumber_test/*.feature' ],

    cucumberOpts: {
        compiler: "ts:ts-node/register",
        require: ['**/*e2e-spec.js'],  // require step definition files before executing features
        tags: '@TypeScriptScenario,@dev,@AddScenario,@SubtractScenario,@MultiplyScenario,@DivideScenario,@ModulusScenario',                      // <string[]> (expression) only execute the features or scenarios with tags matching the expression
        strict: true,                  // <boolean> fail if there are any undefined or pending steps
        format: ["pretty"],            // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
        dryRun: false,                 // <boolean> invoke formatters without executing steps
        'fail-fast': true
    },


  // For angular tests
  useAllAngular2AppRoots: true,

  // Base URL for application server
  baseUrl: 'http://localhost:3000',

  // doesn't seem to work.
  // resultJsonOutputFile: "foo.json",

  onPrepare: function() {
    //// SpecReporter
    //var SpecReporter = require('jasmine-spec-reporter');
    //jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'none'}));
    //// jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));

    // debugging
    // console.log('browser.params:' + JSON.stringify(browser.params));
    /*jasmine.getEnv().addReporter(new Reporter( browser.params )) ;*/

    // Allow changing bootstrap mode to NG1 for upgrade tests
    global.setProtractorToNg1Mode = function() {
      browser.useAllAngular2AppRoots = false;
      browser.rootEl = 'body';
    };
    //  browser.manage().window().maximize();
  },

  /*jasmineNodeOpts: {
    // defaultTimeoutInterval: 60000,
    defaultTimeoutInterval: 10000,
    showTiming: true,
    print: function() {}
  }*/
}
1

1 Answers

0
votes

This issue will be solved just downgrading the cucumber version 3 to 2.