[英]Using @wdio/sync from a react typescript project
I'm adding some browser tests to my react/typescript app.我正在向我的 react/typescript 应用程序添加一些浏览器测试。
Compiler options:编译器选项:
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"lib": ["es2017", "dom"],
"module": "esnext",
"moduleResolution": "node",
"target": "es6"
}
I'm following the boilerplate example here: https://github.com/erwinheitzman/jest-webdriverio-standalone-boilerplate我在这里遵循样板示例: https : //github.com/erwinheitzman/jest-webdriverio-standalone-boilerplate
Which has a statement in the test like (after some mods):在测试中有这样的语句(在一些 mods 之后):
import { BrowserObject } from '@wdio/sync';
const **sync** = require('@wdio/sync').default; // Warnings here
test('synchronous WebdriverIO test', () => **sync**(() => {
...snip...
}));
I get a warning:我收到警告:
require statement not part of an import statement (no-var-requires)tslint(1)
How on earth do I use an import statement here?我到底如何在这里使用导入语句?
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)
I'm so confused by this whole thing.我对这整件事感到很困惑。 From what I can tell sync means "use WebDriverIO namespace from wdio/sync".据我所知,同步意味着“使用 wdio/sync 中的 WebDriverIO 命名空间”。 Is there a way to import that?!?有办法导入吗?!?
import * as sync from '@wdio/sync';
and和
const sync = import("@wdio/sync");
both works for me.两者都适合我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.