Sauceサービス
Sauce Labsとのより良い統合を提供するWebdriverIOサービスです。このサービスは、以下に使用できます。
- Sauce Labs仮想マシンクラウド(デスクトップWeb/エミュレーター/シミュレーター)
- Sauce Labs実機クラウド(iOSおよびAndroid)
ジョブメタデータ('name'*、'passed'、'tags'、'public'、'build'、'custom-data')を更新し、必要に応じてSauce Connectを実行できます。
このサービスが他に何をしてくれるか
- デフォルトでは、Sauceサービスはジョブ開始時にジョブの'name'を更新します。これにより、いつでも名前を更新できます。
setJobName
パラメーターを定義し、機能、オプション、スイートタイトルに基づいてジョブ名をカスタマイズできます。- Sauceサービスは、失敗したテストのエラースタックをSauce Labsコマンドタブにプッシュします。
- Sauce Connectを自動的に構成して起動できます。
- また、コマンドリストにコンテキストポイントを設定して、どのコマンドがどのテストで実行されたかを特定します。
インストール
最も簡単な方法は、@wdio/sauce-service
をpackage.json
のdevDependencyとして、以下のように保持することです。
npm install @wdio/sauce-service --save-dev
WebdriverIO
のインストール方法はこちらをご覧ください。
設定
仮想デスクトップ/エミュレーター/シミュレーターマシンと実機クラウドでサービスを使用するには、wdio.conf.js
ファイルでuser
とkey
を設定する必要があります。これにより、統合テストの実行にSauce Labsが自動的に使用されます。Sauce Labsでテストを実行する場合は、region
プロパティを使用してテストを実行するリージョンを指定できます。リージョンの利用可能な短いハンドルは、us
(デフォルト)とeu
です。これらのリージョンは、Sauce Labs VMクラウドとSauce Labs実機クラウドに使用されます。リージョンを指定しない場合、デフォルトでus
になります。
Sauce Connectトンネルを自動的に起動するには、sauceConnect: true
を設定する必要があります。データセンターをEUに変更するには、USデータセンターがデフォルトで設定されているため、region:'eu'
を追加します。
// wdio.conf.js
export const config = {
// ...
user: process.env.SAUCE_USERNAME,
key: process.env.SAUCE_ACCESS_KEY,
region: 'us', // or 'eu'
services: [
['sauce', {
sauceConnect: true,
sauceConnectOpts: {
// ...
}
}]
],
// ...
};
既存のSauce Connectトンネルを使用する場合は、tunnelIdentifier
を指定するだけで済みます。親トンネルを使用している場合は、次のように機能にparentTunnel
を含めます。
- トンネル識別子
- 親トンネル
export const config = {
// ...
{
browserName: 'chrome',
platformName: 'Windows 10',
browserVersion: 'latest',
// Sauce options can be found here https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options
'sauce:options': {
tunnelIdentifier: 'YourTunnelName',
// Example options
build: 'your-build-name',
screenResolution: '1600x1200',
// ...
},
},
// ...
};
export const config = {
// ...
{
browserName: 'chrome',
platformName: 'Windows 10',
browserVersion: 'latest',
// Sauce options can be found here https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options
'sauce:options': {
tunnelIdentifier: 'ParentTunnelName',
parentTunnel: '<username of parent>,
// Example options
build: 'your-build-name',
screenResolution: '1600x1200',
// ...
},
},
// ...
};
## Sauce Service Options
To authorize the Sauce Labs service your config needs to contain a [`user`](https://webdriverio.dokyumento.jp/docs/options#user) and [`key`](https://webdriverio.dokyumento.jp/docs/options#key) option.
### maxErrorStackLength
This service will automatically push the error stack to Sauce Labs when a test fails. By default, it will only push the first 5 lines, but if needed this can be changed. Be aware that more lines will result in more WebDriver calls which might slow down the execution.
Type: `number`<br />
Default: `5`
### sauceConnect
If `true` it runs Sauce Connect and opens a secure connection between a Sauce Labs virtual machine running your browser tests.
Type: `Boolean`<br />
Default: `false`
### sauceConnectOpts
Apply Sauce Connect options (e.g. to change port number or logFile settings). See [this list](https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy+Command-Line+Quick+Reference+Guide) for more information. Per default, the service disables SC proxy auto-detection via `noAutodetect`` as this can be unreliable for some machines.
NOTE: When specifying the options the `--` should be omitted. It can also be turned into camelCase (e.g. `shared-tunnel` or `sharedTunnel`).
Type: `Object`<br />
Default: `{ noAutodetect: true }`
### uploadLogs
If `true` this option uploads all WebdriverIO log files to the Sauce Labs platform for further inspection. Make sure you have [`outputDir`](https://webdriverio.dokyumento.jp/docs/options#outputdir) set in your wdio config to write logs into files, otherwise data will be streamed to stdout and can't get uploaded.
Type: `Boolean`<br />
Default: `true`
### setJobName
Allows users to dynamically set the job name based on worker parameters such as WebdriverIO configuration, used capabilities and the original suite title.
Type: `Function`<br />
Default: `(config, capabilities, suiteTitle) => suiteTitle`
----
## Overriding generated name metadata
The service automatically generates a name for each test from the suite name, browser name and other information.
You can override this by providing a value for the `name` desired capability, but this will have the side effect of giving all tests the same name.
----
For more information on WebdriverIO see the [homepage](https://webdriverio.dokyumento.jp).