vscode-jest icon indicating copy to clipboard operation
vscode-jest copied to clipboard

Test suite failed to run- Call retries were exceeded

Open Dr1992 opened this issue 5 years ago • 7 comments

Environment

  1. node -v: v12.1.0

  2. npm -v: 6.9.0

  3. npm ls jest or npm ls react-scripts (if you haven’t ejected): No

  4. your vscode-jest settings if customized:

    • jest.pathToJest? No
    • jest.pathToConfig? package.json
    • anything else that you think might be relevant? No
  5. Operating system: MACOS MOJAVE - 10.14.5

Prerequisite

  • are you able to run jest test from command line? Yes
  • how do you run your tests from command line? (for example: npm run test or node_modules/.bin/jest) npm test -- -u

Steps to Reproduce

when I run npm test -- -u the coverage is really bad and the test Fail. I don't know why this error is happenig....

CLASS

import React, { Component } from 'react';
import {
  View,
  Text,
  TouchableOpacity,
  Image,
  Modal,
} from 'react-native';
import PropTypes from 'prop-types';
import { SafeAreaView } from 'react-navigation';
import styles from './Style';

const bag = require('../../assets/images/icons/addedBag/added_bag.png');

class AddedToBag extends Component {
  static propTypes = {
    hideModal: PropTypes.func,
    modalVisible: PropTypes.bool,
    image: PropTypes.string.isRequired,
    productName: PropTypes.string.isRequired,
    price: PropTypes.string.isRequired,
  };

  static defaultProps = {
    hideModal: () => {},
    modalVisible: false,
  }

  hideModalComponent = () => {
    const { hideModal } = this.props;
    hideModal();
  }

  render() {
    const {
      modalVisible, image, productName, price,
    } = this.props;
    return (
      <Modal
        animationType="slide"
        transparent
        visible={modalVisible}
      >
        <View style={styles.flexView} />

        <SafeAreaView style={styles.view}>
          <View style={styles.titleView}>
            <Text style={styles.titleText}>
              ADICIONADO
            </Text>
          </View>
          <View style={styles.productView}>
            <View>
              <Image
                style={styles.productImage}
                source={{ uri: image }}
              />
            </View>
            <View style={styles.flexView}>
              <Text
                style={styles.productText}
                numberOfLines={1}
                ellipsizeMode="tail"
              >
                {productName}
              </Text>
              <Text style={styles.productPriceText}>
                R$ 69,90
              </Text>
            </View>
          </View>
          <View style={styles.buttonView}>
            <TouchableOpacity
              style={styles.buttonTouchable}
              onPress={this.hideModalComponent}
            >
              <Image
                source={bag}
              />
              <Text style={styles.buttonText}>
                IR PARA SACOLA
              </Text>
            </TouchableOpacity>
          </View>
        </SafeAreaView>
      </Modal>
    );
  }
}

export default AddedToBag;

TEST

import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import AddedToBag from '../../src/components/modalBag/AddedToBag';

describe('Test Added To Bag', () => {
  function doWork() {
    console.log('Back button was clicked!');
  }

  test('Added to bag renders correctly', () => {
    const props = {
      hideModal: doWork,
      modalVisible: true,
      image: '',
      productName: 'Test Bag',
      price: '500,50',
    };

    const addedToBag = renderer
      .create(<AddedToBag {...props} />)
      .toJSON();
    expect(addedToBag).toMatchSnapshot();
  });
});


CONSOLE

FAIL  __tests__/components/AddedToBag-test.js
 ● Test suite failed to run

   Call retries were exceeded

     at ChildProcessWorker.initialize (node_modules/jest-runner/node_modules/jest-worker/build/workers/ChildProcessWorker.js:193:21)

PACKAGE.JSON "jest": { "preset": "react-native", "transformIgnorePatterns": [ "node_modules/(?!(jest-)?react-native|react-navigation|react-navigation-redux-helpers|@react-navigation|@react-native-community|rn-sliding-up-panel|react-native-safe-area/.*)" ], "setupFiles": [ "./node_modules/react-native-gesture-handler/jestSetup.js", "./__mocks__/@react-native-community/jestSetupFile.js" ], "testMatch": [ "<rootDir>/__tests__/**/*-test.js?(x)" ], "testPathIgnorePatterns": [ "/node_modules/", "<rootDir>/ios" ], "verbose": true, "setupFilesAfterEnv": [ "<rootDir>/__tests__/setup-tests.js" ] },

Dr1992 avatar Jul 20 '19 15:07 Dr1992

Seeing this as well when running in CI (CircleCI). Locally (macOS) the tests run fine.

EDIT: Adding -i (run in band) works around the problem for me.

martijnthe avatar Jul 31 '19 14:07 martijnthe

Hi @martijnthe – I found your issue here when a colleague approached me with the same error. Has there been any progress on your side?

Our call stack is: yarn test > gulp test > gulp-jest > jest. Further, we use ts-jest since we're writing typescript, and don't execute with runInBand.

It turns out that after running a jest directly, also the yarn test worked. Do you have a similar experience?

andypillip avatar Oct 21 '19 19:10 andypillip

@andypillip no, still using -i in CI. Maybe it has something to do with our use of webassembly -- I had cut another ticket here https://github.com/facebook/jest/issues/8769 but haven't found the time to create minimal repro case.

martijnthe avatar Oct 21 '19 19:10 martijnthe

In one of our projects, -i results in segmentation fault. Node version: 13.2.0. The observation is same as mentioned here: https://github.com/facebook/jest/issues/8769#issuecomment-558670948

Tests run fine with Node version 12.13.1.

creativecomposer avatar Nov 27 '19 13:11 creativecomposer

see my comment in https://github.com/facebook/jest/issues/8769#issuecomment-558670948 Confirmed fix upgrade from 13.2.0 to 13.3.0

JimiSweden avatar Dec 09 '19 10:12 JimiSweden

any fixed on this?

justinlazaro-iselect avatar Sep 18 '20 13:09 justinlazaro-iselect

I'm having the same issue with below configurations:

  Binaries:
    Node: 15.2.1 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.0.10 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  ...
    react: 16.9.0 => 16.13.1
    react-native: * => 0.62.2

namchuai avatar Dec 21 '20 07:12 namchuai