Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wallet] Fix OOM error from jest and update Readme #278

Merged
merged 4 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ jobs:
command: |
mkdir -p test-results/jest
# Tests fail with https://stackoverflow.com/questions/38558989/node-js-heap-out-of-memory without this
NODE_OPTIONS="--max-old-space-size=4096" yarn --cwd packages/mobile test
NODE_OPTIONS="--max-old-space-size=4096" yarn --cwd packages/mobile test:ci
environment:
JEST_JUNIT_OUTPUT: test-results/jest/junit.xml

Expand Down
34 changes: 22 additions & 12 deletions packages/mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export GRADLE_OPTS='-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gr

**Note:** We've seen some issues running the metro bundler from iTerm

## Debugging
### Debugging

In order to debug, you should run:

Expand All @@ -55,12 +55,12 @@ console. In order to get a full picture, the console's filter should be set to
You will probably want to open the dev menu again and enable `Live Reloading`
and `Hot Reloading` to make development faster.

### (_Optional_) React Native debugger app
#### (_Optional_) React Native debugger app

The [RN debugger app][rn debugger] bundles together the Redux and Chrome dev
tools nicely.

## App Profiling
### App Profiling

Start the emulator and load up the app. Then run the following to start react
devtools.
Expand All @@ -79,7 +79,7 @@ renders when no state has changed. Reducing renders can be done via pure
components in react or overloading the should component update method
[example here][rn optimize example].

## Connecting to networks
### Connecting to networks

By default, we have the `alfajores` network set up. If you have other testnets
that you want to use with the app, you can run
Expand All @@ -88,22 +88,31 @@ that you want to use with the app, you can run
yarn run build-sdk TESTNET
```

## Snapshot Testing
## Testing

To execute the suite of tests, run `yarn test`

## Snapshot testing

We use Jest [snapshot testing][jest] to assert that no intentional changes to the
component tree have been made without explicit developer intention. See an
example at [`src/send/SendAmount.test.tsx`]. If your snapshot is
expected to deviate, you can update the snapshot with the `--updateSnapshot`
example at [`src/send/SendAmount.test.tsx`]. If your snapshot is expected
to deviate, you can update the snapshot with the `-u` or `--updateSnapshot`
flag when running the test.

## React Component Unit Testing
### React Component Unit Testing

We use [react-native-testing-library][react-native-testing-library] to unit test react components. It allows for deep rendering
and interaction with the rendered tree to assert proper reactions to user
interaction and input. See an example at
We use [react-native-testing-library][react-native-testing-library] to unit test
react components. It allows for deep rendering and interaction with the rendered
tree to assert proper reactions to user interaction and input. See an example at
[`src/send/SendAmount.test.tsx`] or read more about the [docs][rntl-docs]

## E2E testing
## Saga testing

We use [redux-saga-test-plan][redux-saga-test-plan] to test complex sagas.
See [`src/identity/verification.test.ts`] for an example.

### E2E testing

We use [Detox][detox] for E2E testing. In order to run the tests locally, you
must have the proper emulator set up. Emulator installation instructions are in
Expand Down Expand Up @@ -168,3 +177,4 @@ $ adb kill-server && adb start-server
[react-native-testing-library]: https://github.com/callstack/react-native-testing-library
[rntl-docs]: https://callstack.github.io/react-native-testing-library/
[jest]: https://jestjs.io/docs/en/snapshot-testing
[redux-saga-test-plan]: https://github.com/jfairbank/redux-saga-test-plan
11 changes: 6 additions & 5 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"start:bg": "react-native start &",
"start:android": "react-native run-android",
"start:ios": "react-native run-ios",
"lint-checks": "yarn run lint && yarn run build:typescript --noEmit",
"lint-checks": "yarn run lint && yarn run build:typescript",
"lint": "tslint -c tslint.json --project tsconfig.json",
"build": "yarn run build:typescript && yarn run build:metro",
"build:sdk": "build-sdk",
"build:typescript": "tsc",
"build:typescript": "tsc --noEmit",
"build:metro": "echo 'NOT WORKING RIGHT NOW'",
"build:gen-graphql-types": "gql-gen --schema http://localhost:8080/graphql --template graphql-codegen-typescript-template --out ./typings/ 'src/**/*.tsx'",
"dev": "react-native run-android --appIdSuffix \"debug\"",
Expand All @@ -24,9 +24,10 @@
"dev:send-debug-invite-code": "adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n org.celo.mobile.debug/com.androidbroadcastreceiverforreferrer.ReferrerBroadcastReceiver --es referrer \"invite-code%3D123\"",
"dev:emulator": "emulator -avd Nexus_5X_API_28 &",
"dev:remote": "remotedev --hostname=localhost --port=8000",
"test": "export TZ=UTC && jest --ci --silent --coverage --runInBand",
"test:verbose": "export TZ=UTC && jest --ci --verbose --runInBand",
"test:watch": "export TZ=UTC && jest --watch",
"test": "export TZ=UTC && jest --silent",
"test:ci": "yarn test --coverage --runInBand",
"test:watch": "yarn test --watch",
"test:verbose": "export TZ=UTC && jest --verbose",
"test:build-e2e": "./scripts/build_e2e.sh",
"test:run-e2e": "./scripts/run_e2e.sh",
"test:detox": "CELO_TEST_CONFIG=e2e detox test -c android.emu.debug -a e2e/tmp/ --take-screenshots=failing --record-logs=failing --detectOpenHandles",
Expand Down
4 changes: 4 additions & 0 deletions packages/mobile/src/account/InviteReview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jest.mock('src/geth/GethAwareButton', () => {
return Button
})

jest.mock('src/identity/verification', () => {
return { isPhoneVerified: jest.fn(() => true) }
})

describe('InviteReview', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down