我正在尝试自动化Angular 4应用程序。当我运行“protractor config.js”
时案例1:当我的config.ts文件中有格式选项时,如下所示:
format: ['json:../reporting/results.json']
我收到错误消息:
Unhandled rejection Error: ENOENT: no such file or directory, open 'C:\MyWorkspace\ProtractorProjects\protractor-cucumber-sample\test\config\MyWorkspace\ProtractorProjects\protractor-cucumber-sample\node_modules\protractor-cucumber-framework\lib\resultsCapturer.js:.will-be-removed-after-cucumber-runs.tmp'
at Error (native)
Process finished with exit code 100
Empty test suite.
我理解的是,它无法达到“resultsCapturer.js”。随着 config.js 文件的相对路径被添加,我不知道如何解决这个问题。
案例2:当我将格式选项更改为:
时format: ['pretty']
我收到错误:
Unhandled rejection Error: Cannot find module 'C:\MyWorkspace\protractor-cucumber-sample\test\config\pretty'
at Function.Module._resolveFilename (module.js:469:15)
已检查this doc,但无法帮助我解决问题
以下是我的项目详情:
节点版本: v6.10.3
量角器版本: 5.1.2
config.ts:
import { Config } from 'protractor';
export let config: Config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ["../features/*.feature"],
framework: 'custom',
frameworkPath: require.resolve('node_modules/protractor-cucumber-framework'),
baseUrl: "http://localhost:4200/",
cucumberOpts: {
compiler: "ts:ts-node/register",
strict: true,
format: ['json:../reporting/results.json'],
require: ['../steps/*.js'],
tags: '@smoke'
}
}
的package.json:
{
"name": "protractor-cucumber-sample",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"@types/jasmine": "^2.5.53",
"body-parser": "~1.17.1",
"cookie-parser": "~1.4.3",
"debug": "~2.6.3",
"express": "~4.15.2",
"jade": "~1.11.0",
"morgan": "~1.8.1",
"serve-favicon": "~2.4.2"
},
"devDependencies": {
"@types/chai": "^4.0.3",
"@types/cucumber": "^2.0.3",
"@types/mkdirp": "^0.5.0",
"chai": "^4.1.1",
"chai-as-promised": "^7.1.1",
"cucumber": "^3.0.0",
"cucumber-html-reporter": "^2.0.3",
"jasmine": "^2.7.0",
"jasminewd2": "^2.1.0",
"protractor-cucumber-framework": "^4.0.2",
"ts-node": "^3.3.0",
"typescript": "^2.4.2"
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": false,
"sourceMap": true,
"typeRoots": [
"./node_modules/@types/"
],
"lib": ["es2015"],
"strict": true
},
"compileOnSave": true,
"exclude": [
"node_modules/*",
"**/*-aot.ts"
]
}
请告诉我如果我需要提供其他信息,以帮助您解决此问题。
另请注意,如果这不是发布此问题的正确论坛,或者您知道可以发布此问题的其他论坛。
提前致谢。
答案 0 :(得分:1)
案例1 :您收到没有此类文件或目录错误的原因是因为您的目录 reporting / results.json 没有存在。 Cucumber不在内部创建目录,您必须创建reporting
目录。它肯定会奏效。
案例2 :通过查看你的package.json,你正在使用黄瓜3.0 ,黄瓜已经删除了漂亮格式,因为最新的黄瓜3.0发布。有关详细信息,请查看官方cucumber changelog。你不能再使用它了,最好切换到其他格式化选项 - cucumber formats或降级你的黄瓜版本。