在这里,我试图阻止嘲笑单元测试。有2个文件test和模拟。在下面的代码中,我要执行测试文件(npm运行测试Contactdetails-test)。但是出现错误 失败测试 /Contactdetails-test.js ×查找联系方式信息(5毫秒) ●查找联系方式信息
ReferenceError: MockedProvider is not defined
Contactdetails-mock.js
import react from 'react-native';
import Contactdetails from '../app/components/container/ContactdetailsContainer';
import { __generator } from 'tslib';
const contactDetails = `[{"contactDetails":{"isContactBySms":"Y","mobileNo":"8880995809","isContactByPost":"N","isContactByEmail":"Y","emailId":"test@test.com"},"socialMediaDetails":{"socialMediaDetail":[{"name":"twitter","link":"HARIRAM@twitter.com","__typename":"SocialMediaDetail"},{"name":"facebook","link":"VarnaHERO@facebook.com","__typename":"SocialMediaDetail"},{"name":"linkedIn","link":"linkedIn@linkedin.com","__typename":"SocialMediaDetail"},{"name":"instagram","link":"instagram@instagram.com","__typename":"SocialMediaDetail"},{"name":"telegram","link":"kaushik@telegram.com","__typename":"SocialMediaDetail"}]}}]`;
const contactDetailsinfo = JSON.parse(contactDetails);
console.log("contact info", contactDetailsinfo);
export const ContactDetailsData = {
customerInfo: { contactDetailsinfo },
}
// Contactdetails-test.js
import React from 'react';
import renderer from 'react-test-renderer';
import ContactDetailsData from '../__mocks__/Contactdetails-mock';
expect(findElement(tree,'Contactdetails.customerInfo','Contactdetails.navigation','')).toBeDefined();
// });
it('find Contact details info', () => {
renderer.create(
<MockedProvider mocks={mocks} addTypename={false}>
<ContactDetailsData />
</MockedProvider>,
);
});
请帮助