Reactjs 如何使用Jest在react native中模拟Auth0库

Reactjs 如何使用Jest在react native中模拟Auth0库,reactjs,react-native,unit-testing,jestjs,auth0,Reactjs,React Native,Unit Testing,Jestjs,Auth0,我正在尝试为auth0库模拟此代码 import Auth0 from 'react-native-auth0'; import React, { Component } from 'react'; var credential = { clientId: “dummy”, domain: “www.dummy.com” }; auth0Credentials = credentials; auth0 = new Auth0(auth0Credentials

我正在尝试为auth0库模拟此代码

import Auth0 from 'react-native-auth0';
import React, { Component } from 'react';

var credential = {
      clientId: “dummy”,
      domain: “www.dummy.com”
    };

auth0Credentials = credentials;

auth0 = new Auth0(auth0Credentials);

auth0.auth.userInfo({ token: “DUMMY” }).then(profile => {
})

我已经编写了单元测试用例

  beforeAll(() => {
    global.CLIENT_ID = "dummy";
    global.DOMAIN = "www.dummy.com";
    let promise = Promise.resolve(123);
    let auth0Credentials = {
      clientId: global.CLIENT_ID,
      domain: global.DOMAIN
    };
    var auth0 = new Auth0(auth0Credentials);
    auth0.auth = {
      userInfo: jest.fn(() => promise),
    };
  });
我试着这样嘲笑它不起作用。有人能帮我模仿一下这个身份吗