首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获得wdio向导?

如何获得wdio向导?
EN

Stack Overflow用户
提问于 2022-01-24 17:57:58
回答 1查看 323关注 0票数 0

我正在与WebdriverIO和Cucumber一起构建一个TypeScript项目。我运行的巫师,似乎是直截了当。我选择了黄瓜,TypeScript和页面对象模型。

这将生成一个test/wdio.conf.tstest/tsconfig.json文件以及一个样板特性文件。

但是,当我使用命令wdio run test/wdio.conf.ts运行测试时

我得到以下错误:

代码语言:javascript
复制
export const config = {
^^^^^^

SyntaxError: Unexpected token 'export'

有什么问题吗?

test/wdio.conf.ts

代码语言:javascript
复制
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

代码语言:javascript
复制
{
    "compilerOptions": {
        "types": [
            "node",
            "webdriverio/async",
            "@wdio/cucumber-framework",
            "expect-webdriverio"
        ],
        "target": "ES5"
    }
}

package.json

代码语言:javascript
复制
{
    "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"
    }
}
EN

回答 1

Stack Overflow用户

发布于 2022-01-25 14:51:46

因此,我在一个已经有其他tsconfig文件和安装程序的目录中对项目进行了分类。我在一个单独的项目中创建了这个目录,现在它可以工作了。

我确实需要将脚本命令更新为"wdio":"wdio运行测试/wdio.conf. to“

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70838340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档