testing-library / react-testing-library

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.
https://testing-library.com/react
MIT License
19k stars 1.11k forks source link

Am getting this 'Error: Error: connect ECONNREFUSED' #547

Closed GnanaAjana closed 4 years ago

GnanaAjana commented 4 years ago

In react component am using useReducer to maintain data at top level component. While am running test case, its get more time reflect.


Previously i was using "react-testing-library": "^5.9.0", now i changed to latest version of testing-library.

Even after also am getting error for getting element. So i added 'waitForElement' to get element and checked condition. All test cases is passing but still getting this error: 'Error: Error: connect ECONNREFUSED'

Current version:

"devDependencies": { "@babel/core": "^7.1.0", "@babel/plugin-transform-runtime": "^7.7.6", "@babel/preset-env": "^7.0.0", "@babel/preset-react": "^7.0.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.3", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^9.0.0", "babel-jest": "^24.9.0", "babel-loader": "^8.0.2", "babel-plugin-dynamic-import-webpack": "^1.0.2", "babel-plugin-styled-components": "^1.7.1", "babel-plugin-transform-class-properties": "^6.24.1", "bundlesize": "^0.17.1", "clean-webpack-plugin": "^0.1.19", "copy-webpack-plugin": "^4.5.3", "eslint": "^5.6.0", "eslint-config-airbnb": "^17.1.0", "eslint-config-prettier": "^3.0.1", "eslint-import-resolver-webpack": "^0.10.1", "eslint-plugin-import": "^2.14.0", "eslint-plugin-jsx-a11y": "^6.1.1", "eslint-plugin-prettier": "^2.6.2", "eslint-plugin-react": "^7.11.1", "eslint-plugin-react-hooks": "^2.3.0", "file-loader": "^2.0.0", "husky": "^0.14.3", "jest": "^24.9.0", "jest-canvas-mock": "^2.1.2", "jest-cli": "^24.9.0", "jest-fetch-mock": "^2.1.1", "jest-styled-components": "^6.3.1", "json-server": "^0.14.0", "lint-staged": "^7.2.2", "mini-css-extract-plugin": "^0.4.2", "npm-run-all": "^4.1.3", "prettier": "^1.14.2", "pretty-quick": "^1.6.0", "style-loader": "^0.23.0", "stylelint": "^9.10.1", "stylelint-config-recommended": "^2.1.0", "stylelint-config-styled-components": "^0.1.1", "stylelint-processor-styled-components": "^1.6.0", "svg-react-loader": "^0.4.5", "webpack": "^4.19.0", "webpack-bundle-analyzer": "^3.0.2", "webpack-cli": "^3.1.0", "webpack-serve": "^2.0.2" },

Let me know if miss anything.

jamstooks commented 4 years ago

@GnanaAjana - do you have test and component code you can provide? Maybe even a working example in codesandbox?

kentcdodds commented 4 years ago

Thanks @jamstooks for the helpful comment :)

Hi @GnanaAjana,

My guess is that your test is making a request to some API. You typically only want to do that in E2E tests and when you do you'll want to make sure the API is up and running.

My suggestion is to make a codesandbox example as Benjamin suggested and post it to our spectrum. If you do find an issue with the library, please open a new issue and follow the template. Thanks!