[英]Using @wdio/sync from a react typescript project
我正在向我的 react/typescript 应用程序添加一些浏览器测试。
编译器选项:
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"lib": ["es2017", "dom"],
"module": "esnext",
"moduleResolution": "node",
"target": "es6"
}
我在这里遵循样板示例: https : //github.com/erwinheitzman/jest-webdriverio-standalone-boilerplate
在测试中有这样的语句(在一些 mods 之后):
import { BrowserObject } from '@wdio/sync';
const **sync** = require('@wdio/sync').default; // Warnings here
test('synchronous WebdriverIO test', () => **sync**(() => {
...snip...
}));
我收到警告:
require statement not part of an import statement (no-var-requires)tslint(1)
我到底如何在这里使用导入语句?
import sync = require('...').default; // Doesn't work. Says Declaration or statement expected.ts(1128)
import sync from '...'; // Doesn't work. Says Cannot use namespace 'sync' as a value.ts(2708)
我对这整件事感到很困惑。 据我所知,同步意味着“使用 wdio/sync 中的 WebDriverIO 命名空间”。 有办法导入吗?!?
import * as sync from '@wdio/sync';
和
const sync = import("@wdio/sync");
两者都适合我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.