对单个测试服的依赖性导致其他测试服失败-开玩笑

时间:2019-01-09 17:03:42

标签: reactjs react-native ecmascript-6 jestjs enzyme

我正在对其中的一套测试服嘲笑以下库:

这是react-native-awesome-card.io:

jest.mock('react-native-awesome-card-io', () => {
  return {
    CardIOUtilities: {
      preload: jest.fn(() => Promise.resolve('the response')),
    },
  }
})

    describe('PaymentDetails', () => {
      test('snapshot = PaymentDetails not empty', () => {
        const options = {
          navigation: {
            state: {
              params: {
                paymentMethod: {
                  accountName: 'Test Account',
                  expMonth: 11,
                  expYear: 2021,
                  number: '4111111111111111',
                  type: 'Visa',
                  preferred: true,
                },
              },
            },
          },
          getUserInfo: { locale: 'en-US' },
        }
        snapshot(shallow(<PaymentDetails {...options} />))
      })

对于此测试,这似乎工作正常,但我注意到我的其他测试服因以下错误而开始失败: enter image description here

似乎他们所有人都需要对他们进行嘲笑的库。但为什么? 对此有什么解决方案?我讨厌其中的每一个上的复制模拟代码。

0 个答案:

没有答案
相关问题