Tauri 配置

2023-10-17 15:53 更新

你可能已經(jīng)注意到我們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?中運行命令。我們還將我們的規(guī)范設(shè)置為?"./test/specs/**/*.js"?,所以讓我們現(xiàn)在創(chuàng)建一個規(guī)范文件。


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號