8000 Jest tests taking longer than they should · Issue #71 · react-everywhere/re-start · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Jest tests taking longer than they should #71
Open
@thorakmedichi

Description

@thorakmedichi
  • template name : (re-start)
  • template version : ??? from last month
  • react-native version: 0.55.4 (what came in this repo)
  • OS : Linux Mint
  • Platform causing error: all?? CI?

Step 3: Describe the problem (try to include screenshots):

Running yarn test or even just yarn test:native seems to take much longer than it should. Running locally on my machine, running in a docker container and running it GitLab CI/CD all do this, which leads me to think its some setup here.

Steps to reproduce:

I am not sure if it is one file or all or what. I have 8 test files and 32 tests... nothing big at all. One test that continually seems to take over 50 seconds to run is this component and this test. As you will see this is not a complex file or test.

Yet I continually get the following:
PASS src/components/__tests__/HR.test.js (52.81s)

Well... its actually more like this - again... none of these files is bigger than maybe 50 lines of code:

 PASS  src/common/__tests__/globalFunctions.test.js
 PASS  src/common/actions/__tests__/logs.test.js
 PASS  src/common/immutability-helper/__tests__/extensions.test.js
 PASS  src/common/reducers/__tests__/logs.test.js (13.786s)
 PASS  src/components/__tests__/HR.test.js (52.81s)
 PASS  src/components/__tests__/Counter.test.js (53.169s)
 PASS  src/components/inputs/__tests__/Input.test.js (53.27s)
 PASS  src/components/inputs/__tests__/SelectList.test.js (57.242s)

HR.js

const HR = ({ color, style }) => (
    <View style={[styles.underline, { borderColor: color }, style]} />
);

HR.propTypes = {
    color: PropTypes.string,
    style: ViewPropTypes.style
};

HR.defaultProps = {
    color: 'white',
    style: null
};

export default HR;

HR.test.js

import React from 'react';
import Adapter from 'enzyme-adapter-react-16';

import { View } from 'react-native';
import Enzyme, { shallow } from 'enzyme';

// Components
import HR from '../HR';

Enzyme.configure({ adapter: new Adapter() });

describe('HR', () => {
    test('renders the HR component', () => {
        const wrapper = shallow(<HR />);

        expect(wrapper.find(View)).toHaveLength(1);
        expect(wrapper.find(View).props().style[1].borderColor).toEqual('white');
    });

    test('renders the HR component with custom color prop', () => {
        const wrapper = shallow(<HR color="#3F3F3F" />);

        expect(wrapper.find(View)).toHaveLength(1);
        expect(wrapper.find(View).props().style[1].borderColor).toEqual('#3F3F3F');
    });
});

Observed Results:

When running locally I see PASS src/components/__tests__/HR.test.js (52.81s)

When watching in GitLab CI/CD I get

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with '--detectOpenHandles' to troubleshoot this issue.

--detectOpenHandles does nothing given all the routing through config files that you have setup. So not sure how to implement that.

Expected Results:

The test should run in a second or two... not 50+ seconds

Additional information

Here are the contents of my gitlab-ci.yml file

stages:
  - lint
  - test

lint:
  stage: lint
  image: node:10.15
  script:
    - yarn
    - yarn lint

test:
  stage: test
  image: node:10.15
  script:
    - yarn
    - yarn test:native --ci

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0