Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
Fix JS test workflow (#143)
Browse files Browse the repository at this point in the history
* import correct App module

* update jest related dependencies, mock async storage and static files

* enable app rendering CI

* run app rendering step before building APK

* ignore scripts in CI to prevent Snyk from applying patches

* call jest.useFakeTimers() to mock setTimeout

* do not ignore npm scripts after installing
  • Loading branch information
haveyaseen authored May 4, 2020
1 parent 35b413a commit 1e25030
Show file tree
Hide file tree
Showing 8 changed files with 4,149 additions and 1,524 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ jobs:
java-package: jdk
- name: Install Android SDK
run: sh ci/install-android-sdk.sh
- name: Ignore snyk protect script that would take too long
run: npm config set ignore-scripts true
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: No longer ignore npm scripts
run: npm config set ignore-scripts false
- name: Run tests
run: npm run test
- name: Build APK
run: npm run android:build-apk
# Tests currently disabled because of broken test setup
# - name: Run tests
# run: npm run test
- name: Archive APK
uses: actions/upload-artifact@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion __tests__/App-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'react-native';
import React from 'react';
import App from '../App';
import App from '../App/App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.horcrux.svg.SvgPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
Expand Down
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
rootProject.name = 'ReactNativeApp'
include ':@react-native-community_async-storage'
project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android')
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')

Expand Down
2 changes: 2 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ target 'ReactNativeApp' do

pod 'RNSVG', :path => '../node_modules/react-native-svg'

pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

target 'ReactNativeAppTests' do
inherit! :complete
# Pods for testing
Expand Down
6 changes: 6 additions & 0 deletions jestSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable no-undef */

import mockAsyncStorage from '@react-native-community/async-storage/jest/async-storage-mock';

jest.mock('@react-native-community/async-storage', () => mockAsyncStorage);
jest.useFakeTimers();
Loading

0 comments on commit 1e25030

Please sign in to comment.