Tauri 配置
你可能已经注意到我们package.json
中的测试脚本提到了一个文件wdio.conf.js
。这就是WebdriverIO配置文件,它控制了我们测试套件的大部分方面。
wdio.conf.js:
const os = require('os')
const path = require('path')
const { spawn, spawnSync } = require('child_process')
// keep track of the `tauri-driver` child process
let tauriDriver
exports.config = {
specs: ['./test/specs/**/*.js'],
maxInstances: 1,
capabilities: [
{
maxInstances: 1,
'tauri:options': {
application: '../../target/release/hello-tauri-webdriver',
},
},
],
reporters: ['spec'],
framework: 'mocha',
mochaOpts: {
ui: 'bdd',
timeout: 60000,
},
// ensure the rust project is built since we expect this binary to exist for the webdriver sessions
onPrepare: () => spawnSync('cargo', ['build', '--release']),
// ensure we are running `tauri-driver` before the session starts so that we can proxy the webdriver requests
beforeSession: () =>
(tauriDriver = spawn(
path.resolve(os.homedir(), '.cargo', 'bin', 'tauri-driver'),
[],
{ stdio: [null, process.stdout, process.stderr] }
)),
// clean up the `tauri-driver` process we spawned at the start of the session
afterSession: () => tauriDriver.kill(),
}
如果你对`exports.config`对象上的属性感兴趣,我建议阅读文档。对于非WDIO特定的项目,有注释解释为什么我们在onPrepare
、beforeSession
和afterSession
中运行命令。我们还将我们的规范设置为"./test/specs/**/*.js"
,所以让我们现在创建一个规范文件。