LoginSignup
11
3

More than 5 years have passed since last update.

Expo環境のDetoxではテスト成果物(Artifacts)を利用できない話

Posted at

Detoxとは

https://github.com/wix/detox/
モバイルアプリでE2Eテストの自動化を行えるライブラリ

テスト成果物(Artifacts)とは

Detoxでは、v8からE2Eテストの結果を成果物(Artifacts)として記録しておくことができます。
https://github.com/wix/detox/blob/master/docs/APIRef.Artifacts.md
具体的には以下のような記録を残すことが可能です。
- .log形式のログ
- .png形式のテスト前後のスクリーンショット
- .mp4形式のテスト中の画面遷移の動画

何が問題か

React Native ExpoでDetoxを利用するときはdetox-expo-heplersを利用しなければなりません
https://github.com/expo/detox-expo-helpers

通常であれば、Expoを起動した後にreloadAppを呼び出して自分のアプリを読み込むのですが、Detoxの問題でv7.2.0以降は読み込み完了が取れずテストがここで止まってしまいます。

firstTest.spec.js
const { reloadApp } = require('detox-expo-helpers');

describe('Example', () => {
  beforeEach(async () => {
    await reloadApp();
    // これ以降には進まない
  });

  it('should have welcome screen', async () => {
    await expect(element(by.id('welcome'))).toBeVisible();
  });
});

結局

Expoでdetoxを使いたい場合、テスト成果物は諦めてv7.2.0を利用しましょう(React Nativeは大丈夫)

11
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
3