Open angelcheung22 opened 2 months ago
Pretty stuck as the mocking failed. and MM QA team has a meeting on 20 June to discuss overall QA strategy, so put on hold
Quick statement on our findings:
But when doing so, we're facing an error with module loading.
I have setup a branch to test mocking strategy here: https://github.com/MetaMask/metamask-mobile/tree/feat/e2e-ledger
Instructions:
yarn && yarn setup
yarn watch:e2e
yarn test:e2e:android:debug:build
yarn test:e2e:android:debug:run e2e/specs/hardware-wallets/add-ledger-device.spec.js
If you have the same issue as me, you'll see that app is crashing :confused:
How mocks are working:
Basically It's needed to duplicate a file and add the mock.ts
extension instead of .ts
beside the original file. Then metro builder should take the mock file instead. Related logic based on env variable IS_TEST
can be seen inside metro.config.js
Some hooks have been mocked just to test if mocking strategy was working. But at the end we would like to mock the bluetooth library only (potentially react-native-ble-plx
or lower)
Add validation for the Ledger and HW wallet support in mobile (and extension) within the E2E tests? In the past we've discussed the potential of using software emulators (existing or custom) to mock the responses from the device as needed at the URL or library level.
We can try mock @ledgerhq/react-native-hw-transport-ble to bypass the bluetooth communication. and then we can try to see how to do it in e2e tests. the only downside is if library upgrade, we may need to change the mock again to refect the library API change.