[英]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.