我正在与WebdriverIO和Cucumber一起构建一个TypeScript项目。我运行的巫师,似乎是直截了当。我选择了黄瓜,TypeScript和页面对象模型。
这将生成一个test/wdio.conf.ts和test/tsconfig.json文件以及一个样板特性文件。
但是,当我使用命令wdio run test/wdio.conf.ts运行测试时
我得到以下错误:
export const config = {
^^^^^^
SyntaxError: Unexpected token 'export'有什么问题吗?
test/wdio.conf.ts
export const config = {
// ...
autoCompileOpts: {
autoCompile: true,
// see https://github.com/TypeStrong/ts-node#cli-and-programmatic-options
// for all available options
tsNodeOpts: {
transpileOnly: true,
project: 'tsconfig.json'
},
// tsconfig-paths is only used if "tsConfigPathsOpts" are provided, if you
// do please make sure "tsconfig-paths" is installed as dependency
tsConfigPathsOpts: {
baseUrl: './'
}
}
}test/tsconfig.json
{
"compilerOptions": {
"types": [
"node",
"webdriverio/async",
"@wdio/cucumber-framework",
"expect-webdriverio"
],
"target": "ES5"
}
}package.json
{
"name": "e2e-wdio",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"wdio": "wdio run test/wdio.conf.ts"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@wdio/cli": "^7.16.13",
"@wdio/cucumber-framework": "^7.16.13",
"@wdio/local-runner": "^7.16.13",
"@wdio/spec-reporter": "^7.16.13",
"chromedriver": "^97.0.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.5",
"wdio-chromedriver-service": "^7.2.6",
"webdriverio": "^7.16.13"
}
}发布于 2022-01-25 14:51:46
因此,我在一个已经有其他tsconfig文件和安装程序的目录中对项目进行了分类。我在一个单独的项目中创建了这个目录,现在它可以工作了。
我确实需要将脚本命令更新为"wdio":"wdio运行测试/wdio.conf. to“
https://stackoverflow.com/questions/70838340
复制相似问题