我正在使用带有茉莉花的量角器在测试执行后生成报告,为此,我在conf.js文件中调用jasmine.getEnv()
。
但是使用命令ng e2e
运行测试时,我看到以下错误:
[06:09:32] E/launcher - Error: TypeError: jasmine.getEnv is not a function
at onPrepare (E:\Projects\ProtractorDemo\workspace\frontend\e2e\protractor.conf.js:33:23)
at q_1.Promise (E:\Projects\ProtractorDemo\workspace\frontend\node_modules\protractor\built\util.js:46:49)
at Function.promise (E:\Projects\ProtractorDemo\workspace\frontend\node_modules\q\q.js:682:9)
at Object.runFilenameOrFn_ (E:\Projects\ProtractorDemo\workspace\frontend\node_modules\protractor\built\util.js:38:16)
at plugins_.onPrepare.then (E:\Projects\ProtractorDemo\workspace\frontend\node_modules\protractor\built\runner.js:98:27)
at _fulfilled (E:\Projects\ProtractorDemo\workspace\frontend\node_modules\q\q.js:834:54)
at E:\Projects\ProtractorDemo\workspace\frontend\node_modules\q\q.js:863:30
at Promise.promise.promiseDispatch (E:\Projects\ProtractorDemo\workspace\frontend\node_modules\q\q.js:796:13)
at E:\Projects\ProtractorDemo\workspace\frontend\node_modules\q\q.js:556:49
at runSingle (E:\Projects\ProtractorDemo\workspace\frontend\node_modules\q\q.js:137:13)
at flush (E:\Projects\ProtractorDemo\workspace\frontend\node_modules\q\q.js:125:13)
at processTicksAndRejections (internal/process/task_queues.js:79:9)
[06:09:32] E/launcher - Process exited with error code 100
An unexpected error occurred: undefined
注意:当我在这里找到其他线程时,答案是茉莉花,最新版本未更新getEnv()方法并要求降级。我在项目中也遵循相同的要求,但是没有运气。
还请注意,我使用的是protractor v5.4.2
和jasmine v2.7.0
有什么建议吗??
编辑:附加conf.js文件
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reportDirectory = './e2e/reports';
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reportDirectory = './e2e/reports';
var ScreenshotAndStackReporter = new HtmlScreenshotReporter({
dest: reportDirectory,
filename: 'E2ETestingReport.html',
reportTitle: "E2E Testing Report",
showSummary: true,
reportOnlyFailedSpecs: false,
captureOnlyFailedSpecs: false,
});
exports.config = {
//seleniumAddress: "http://127.0.0.1:4444/wd/hub",
allScriptsTimeout: 11000,
getPageTimeout: 30000,
baseUrl: 'http://localhost:4200/',
beforeLaunch: function () {
return new Promise(function (resolve) {
ScreenshotAndStackReporter.beforeLaunch(resolve);
});
},
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['disable-infobars', '--headless', '--no-sandbox']
}
},
cucumberOpts: {
compiler: "ts:ts-node/register",
require: ['./src/steps/**/*.steps.ts', './src/support/*.ts'],
tags: "@Smoke",
format: 'pretty',
profile: false,
},
directConnect: true,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
onPrepare() {
browser.ignoreSynchronization = true;
browser.manage().window().maximize();
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(ScreenshotAndStackReporter);
},
specs: ['./src/features/**/*.feature']
};
编辑#2:package.json包含具有版本的模块
"devDependencies": {
----
----
"jasmine-spec-reporter": "^4.2.1",
"protractor": "^5.4.2",
"cucumber": "^5.1.0",
"jasmine-core": "2.5.2",
----
----
}
"dependencies": {
-----
-----
"cucumber-html-reporter": "^5.0.0",
"jasmine": "^3.4.0",
"mkdirp": "^0.5.1",
"moment": "^2.24.0",
"protractor-cucumber-framework": "^6.1.1",
"protractor-jasmine2-screenshot-reporter": "^0.5.0",
-----
-----
}