lundi 2 mai 2016

Runtime error Running Jest : in React

I'm unable to run Jest tests and have a very vague error message. I found a similar issue on StackOverflow, and I wasn't able to solve it with their suggestion of adding jestSupport in the react folder in the node_module.

issue referenced: How to use Jest with React Native

    __tests__/profile-test.js
● Runtime Error
TypeError: Cannot read property 'DEFINE_MANY' of undefined

// Snippet from package.JSON

"scripts": {
    "test": "jest"
  },
  "jest": {
    "scriptPreprocessor": "<rootDir>/node_modules/babel-jest"
  },

// test file

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: 'testmcnameyname@gmail.com'}); 
          });
        };

Has anyone run into this issue before, & have suggestions?

Aucun commentaire:

Enregistrer un commentaire