今日から毎日ReactNativeを学ぶことにした(29日目)
スケジュールって大事だよと3人に説いた。集めてまとめりゃよかった。
前回
本日
App Signing
Home / EAS Build / App Sining 以下は著名周り。ストアにあげるなどまだしないので割愛
Get started with custom builds
EAS Buildを拡張できるらしい。この例ではテストを追加しているので参考に動かしてみる。
// jestをインストール
npx expo install -- --save-dev jest-expo jest react-test-renderer
scriptにテスト追加
// package.json
"scripts": {
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)"
]
},
テストコード追加
// App.test.js
import renderer from 'react-test-renderer';
import App from './App';
describe('<App />', () => {
it('has 1 child', () => {
const tree = renderer.create(<App />).toJSON();
expect(tree.children.length).toBe(1);
});
});
ワークフローを追加
// .eas/build/test.yml
build:
name: Run tests
steps:
- eas/checkout
- run:
name: Install dependencies
command: npm install
- run:
name: Run tests
command: |
echo "Running tests..."
npm test
easのconfigに追加
{
"build": {
"test": {
"config": "test.yml",
"withoutCredentials": true
},
}
実行
eas build -p android -e test
![](https://assets.st-note.com/img/1724850527812-P1o4T08VAe.png?width=1200)
buildにテストが差し込まれた!
本日のまとめ
ビルドのワークフローの中にカスタムで差し込むことができる。
※注意
buildでエラーが起きると止まらない?おそらくある程度たつとタイムアウトするのだろうが、数分程度では終わらなかったので手動で止めた。
![](https://assets.st-note.com/img/1724850211080-0IoochQkGy.png?width=1200)