Tôi không thể chạy các kiểm tra Jest và có một thông báo lỗi rất mơ hồ. Tôi đã tìm thấy một vấn đề tương tự trên StackOverflow và tôi không thể giải quyết vấn đề đó với đề xuất thêm jestSupport vào thư mục phản hồi trong node_module.Lỗi thời gian chạy Chạy Jest: trong React
vấn đề tham chiếu: How to use Jest with React Native
__tests__/profile-test.js
● Runtime Error
TypeError: Cannot read property 'DEFINE_MANY' of undefined
// Snippet từ package.JSON
"scripts": {
"test": "jest"
},
"jest": {
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest"
},
// test tập tin
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import Profile from '../components/profile';
jest.setMock('react', {}); // put this in after reading a troubleshooting article
//jest.autoMockOff(Profile);
describe('Profile'),() => {
it("renders a form containing user information", function() {
let Profile = TestUtils.renderIntoDocument(<Profile/>);
let renderedDOM =() => React.findDOMNode(Profile);
expect(renderedDOM.tagName).toBe('div');
expect(renderedDOM.classList).toEqual(['value', 'image', 'btn btn-primary', 'btn btn-danger' ]);
var children = renderedDOM.querySelectorAll('fieldConfig.type'); //created a custom
expect(children.length).toBe(3);
expect(children[0]).toEqual({name: 'test mc nameyname', email: '[email protected]'});
});
};
Có ai chạy vào vấn đề này trước, & có đề xuất?
bạn có tìm thấy giải pháp không? – inquisitive
Tôi xin lỗi vì không. Tôi quyết định xoay quanh Mocha, Chai và Enzyme một cách rõ ràng cho sự rõ ràng của các thông báo lỗi sau khi nói chuyện với một đồng nghiệp. –