メインコンテンツまでスキップ
バージョン: v4.41

スクリーンショットコネクタ

You can configure a screenshot connector module to be used by the screenshot testing process, to modify the default behavior of the caching, comparing and publishing of your tests. コネクタクラスを定義するファイルを作成し、ステンシルテスト構成でそれを指すだけです。

export const config: Config = {
...
testing: {
screenshotConnector: './connector.js'
}
};

Writing a connector​

To write a connector, import the base ScreenshotConnector class from stencil and extend it:

const { ScreenshotConnector } = require('@stencil/core/screenshot');

module.exports = class ScreenshotCustomConnector extends ScreenshotConnector {
...
};
注記

For a good reference on how this can be done, have a look at the default StencilLocalConnector here

メソッド​

ステンシルからインポートおよび拡張できるベースコネクタには、上書き可能な次のメソッドがあります。

ScreenshotConnector
loading...

インターフェイスへの参照については、ここを参照

initBuild(options)​

このメソッドは、コネクタをセットアップし、テストを実行するためのすべての準備をするために呼び出されています。スクリーンショットテストの実行に必要な変数、ファイルパス、およびフォルダー構造の設定を担当します。

注記

Only overwrite this method if you know what you do! For easy extension, make sure to call super.initBuild

pullMasterBuild()​

After initializing the connector, and setting up the build, this method is being run to give the possibility to pull the master build. This can be very useful in case the screenshots are stored somewhere else then on the machine on which the tests are running.

getMasterBuild()​

テストがセットアップされたので、このメソッドを実行する準備ができて、マスタービルドを返すために呼び出されています。したがって、マスタービルドをファイルからロードする代わりに、APIからフェッチして、このメソッドで返すことができます。

getScreenshotCache()​

このメソッドは、現在のビルド結果で拡張されるスクリーンショットキャッシュを返すために呼び出されています。

completeBuild(masterBuild)​

テストを実行し、構成されたフォルダーにスクリーンショットを生成した後、このメソッドが呼び出されて、結果のjsonデータが作成されます。この時点で、イメージはそこにあり、マスタービルドはオプションとして渡されています。

注記

Only overwrite this method if you know what you do! For easy extension, make sure to call super.completeBuild

publishBuild(buildResults)​

ビルドが完了し、結果が生成されたので、このメソッドは結果データとともに呼び出されます。ここでは、結果をjsonファイルに書き込んだり、リモートの場所に送信したりできます。デフォルトの StencilLocalConnectorでは、このメソッドは比較アプリのhtmlを作成します。

updateScreenshotCache(screenshotCache, buildResults)​

実行全体の最後に、スクリーンショットキャッシュをこのメソッドで更新する必要があります。したがって、ここからファイルに書き込んだり、APIに送信したりできます。

インターフェース​

ScreenshotConnectorOptions
loading...
ScreenshotBuild
loading...
ScreenshotBuildResults
loading...
ScreenshotCompareResults
loading...
ScreenshotCache
loading...
Screenshot
loading...
ScreenshotDiff
loading...