From dbf07544cf46560ea39de79ead7a827c6f390e15 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Fri, 1 May 2020 08:35:36 +0800 Subject: [PATCH] Mock random.js in tests using node crypto --- tests/setup.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/setup.js b/tests/setup.js index 061cc0e85..e8e3afcbd 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -1,3 +1,12 @@ +import crypto from 'crypto'; +import { promisify } from 'util'; + +jest.mock('../random', () => { + return { + randomBytes: jest.fn(size => promisify(crypto.randomBytes)(size)), + }; +}); + jest.mock('react-native-watch-connectivity', () => { return { getIsWatchAppInstalled: jest.fn(),