你好朋友我用量角器和黄瓜js测试我的角度2应用程序,但它给了我这个错误我尝试了几个解决方案,但没有人可以解决我的问题。如果你知道任何溶胶它会很好谢谢你..
[1]未处理的拒绝TypeError:this.registerHandler不是函数 [1]在Object.registerHandlers上(/home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:16:8) [1] /home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:6:22 [1]在Object.defineSupportCode(/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/support_code_library_builder/index.js:20:9) [1]在Object。 (/home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:5:12) [1]在Module._compile(module.js:570:32) [1]在Object.Module._extensions..js(module.js:579:10) [1]在Module.load(module.js:487:32) [1]在tryModuleLoad(module.js:446:12) [1]在Function.Module._load(module.js:438:3) [1]在Module.require(module.js:497:17) [1] at require(internal / module.js:20:19) [1] /home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:61:42 [1]在Array.forEach(原生) [1]在Cli.getSupportCodeLibrary(/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:61:22) [1]在Cli。 (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:76:37) [1]在下一个(本地) [1] [17:30:50] E /发射器 - BUG:发射器退出并剩下1个任务
这是我的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": {}
}
和我的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() {}
}*/
}
答案 0 :(得分:0)
只需将黄瓜版本3降级为2即可解决此问题。