node -v: v12.1.0npm -v: 6.9.0npm ls jest or npm ls react-scripts (if you haven’t ejected): Noyour vscode-jest settings if customized:
Operating system: MACOS MOJAVE - 10.14.5
npm run test or node_modules/.bin/jest) npm test -- -uwhen 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"
]
},
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.
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 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.
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.
see my comment in https://github.com/facebook/jest/issues/8769#issuecomment-558670948
Confirmed fix upgrade from 13.2.0 to 13.3.0
any fixed on this?
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
Most helpful comment
In one of our projects,
-iresults 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.