Closed jsgervais closed 3 years ago
Your problem should be solved by switching your project to use Wallaby's automatic configuration (released August 2019) for your project. This will allow Wallaby to automatically detect and configure itself to run based on your jest version and its configuration; we expect this to fix your problem.
To do this:
Wallaby.js: Select Configuration
and select Automatic Configuration <project directory>
.If jest is working for you using npx jest
then you don't need to do anything further. If for some reason, you have a non-standard configuration file location or jest is not installed in your node_modules
, you can also override the automatic configuration options (see our docs for more info).
I can give it a try, but it's an ejected react app, and some config files location aren't standard
unfortunately I'm getting more errors with the automatic configuration:
[Info] console.log: Jest: ● Test suite failed to run [Info] TypeError: this._resolver.resolveStubModuleName is not a function [Info] at Runtime._generateMock (node_modules/@jest/core/node_modules/jest-runtime/build/index.js:1477:22)
@jsgervais Can you please share your Jest config?
the jest config is in package.json :
{
...
"dependencies": {
"@aspnet/signalr": "1.1.4",
"@babel/polyfill": "7.4.4",
"@date-io/moment": "^1.3.13",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/pickers": "^3.2.10",
"@microsoft/signalr": "^3.0.0",
"@panzoom/panzoom": "^4.0.4",
"@react-google-maps/api": "^1.8.3",
"@toast-ui/react-editor": "^2.4.0",
"@types/he": "^1.1.0",
"@types/react-color": "^3.0.4",
"@types/react-tag-autocomplete": "^5.6.1",
"apexcharts": "^3.22.3",
"bluebird": "3.4.1",
"bootstrap": "3.3.6",
"bootstrap-notify": "3.1.3",
"bootstrap-select": "1.10.0",
"bootstrap-touch-carousel": "0.8.0",
"clean-webpack-plugin": "^3.0.0",
"connected-react-router": "^6.5.2",
"core-js": "^3.1.3",
"crypto-js": "^3.1.9-1",
"css-vars-ponyfill": "^2.1.2",
"dompurify": "^1.0.11",
"eligrey-classlist-js-polyfill": "^1.2.20180112",
"eligrey-classlist.js": "^1.2.20180112",
"es6-shim": "0.35.1",
"event": "1.0.0",
"file-saver": "1.3.2",
"findindex_polyfill_mdn": "^1.0.0",
"flux": "2.1.1",
"font-awesome": "^4.7.0",
"formBuilder": "^3.4.2",
"fuse.js": "^3.2.1",
"hammerjs": "2.0.8",
"he": "^1.2.0",
"history": "4.7.2",
"intl": "1.2.5",
"jquery": "2.1.4",
"lodash": "^4.17.11",
"lodash.product": "^18.9.19",
"markerclustererplus": "^2.1.4",
"metismenu": "3.0.4",
"moment": "^2.29.1",
"moment-timezone": "0.5.25",
"oidc-client": "^1.9.1",
"p-retry": "^2.0.0",
"points-cluster": "0.1.4",
"promise-polyfill": "^8.2.0",
"promise-queue": "2.2.3",
"prop-types": "15.6.1",
"query-string": "^6.1.0",
"raf": "^3.4.0",
"react": "16.11.0",
"react-apexcharts": "^1.3.7",
"react-app-polyfill": "^2.0.0",
"react-appinsights": "1.0.4",
"react-bootstrap": "0.32.1",
"react-color": "^2.19.3",
"react-copy-to-clipboard": "5.0.1",
"react-datetime": "2.14.0",
"react-dnd": "4.0.2",
"react-dnd-html5-backend": "4.0.2",
"react-dom": "^16.11.0",
"react-dropzone": "^10.1.5",
"react-ga": "2.5.6",
"react-intl": "2.4.0",
"react-intl-redux": "^2.1.0",
"react-overlays": "^0.8.3",
"react-query": "^3.2.0",
"react-redux": "^7.1.3",
"react-resizable": "^1.8.0",
"react-responsive": "^8.0.1",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-select": "^1.0.0-rc.5",
"react-switch": "^5.0.0",
"react-tag-autocomplete": "^5.11.1",
"react-textarea-autosize": "^7.1.0",
"react-toggle": "^4.0.2",
"react-transition-group": "2.4.0",
"react-visibility-sensor": "5.0.2",
"recompose": "0.27.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"sanitize-filename": "^1.6.3",
"streamsaver": "^1.0.1",
"styled-components": "^5.0.0",
"tui-editor": "^1.4.2",
"url-search-params-polyfill": "^4.0.1",
"video.js": "5.16.0",
"videojs-markers": "^1.0.1",
"videojs-youtube": "^2.6.1",
"webpack-merge": "^4.2.2",
"wellknown": "0.5.0",
"whatwg-fetch": "3.0.0",
"wicked-good-xpath": "1.3.0"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/plugin-proposal-export-default-from": "^7.2.0",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/plugin-transform-arrow-functions": "^7.2.0",
"@babel/plugin-transform-classes": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/plugin-transform-spread": "^7.2.2",
"@babel/preset-env": "7.4.5",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "7.0.0",
"@babel/preset-stage-2": "7.0.0",
"@babel/preset-typescript": "^7.7.2",
"@types/bluebird": "3.5.20",
"@types/crypto-js": "^3.1.47",
"@types/dompurify": "0.0.33",
"@types/enzyme": "^3.1.14",
"@types/enzyme-adapter-react-16": "^1.0.5",
"@types/flux": "^3.1.7",
"@types/googlemaps": "^3.39.3",
"@types/history": "4.6.2",
"@types/jest": "^23.3.14",
"@types/jquery": "^3.3.2",
"@types/lodash": "^4.14.109",
"@types/markerclustererplus": "^2.1.33",
"@types/moment": "^2.13.0",
"@types/promise-queue": "^2.2.0",
"@types/prop-types": "15.5.3",
"@types/query-string": "^5.1.0",
"@types/react": "^16.9.11",
"@types/react-bootstrap": "^0.32.9",
"@types/react-dom": "16.0.5",
"@types/react-intl": "^2.3.18",
"@types/react-intl-redux": "^0.1.14",
"@types/react-overlays": "^0.8.4",
"@types/react-redux": "^7.1.7",
"@types/react-router": "^5.1.2",
"@types/react-router-dom": "^5.1.2",
"@types/react-tag-input": "^4.7.4",
"@types/react-test-renderer": "^16.9.1",
"@types/react-visibility-sensor": "5.0.1",
"@types/redux-mock-store": "^1.0.2",
"@types/video.js": "5.16.0",
"babel-jest": "^26.6.3",
"babel-plugin-transform-es5-property-mutators": "^6.24.1",
"babelify": "10.0.0",
"browserify": "^13.0.0",
"enzyme": "~3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"fancy-log": "1.3.3",
"fetch-mock": "^9.3.1",
"file-loader": "^4.0.0",
"jest": "^26.6.3",
"jest-enzyme": "^6.0.2",
"jest-junit": "^6.4.0",
"less": "^3.9.0",
"less-loader": "^5.0.0",
"mini-css-extract-plugin": "^0.7.0",
"react-query-devtools": "^2.6.0",
"react-scripts": "2.1.8",
"react-test-renderer": "^16.12.0",
"redux-mock-store": "^1.5.3",
"rimraf": "2.2.8",
"run-sequence": "^1.1.3",
"string-replace-loader": "^2.2.0",
"ts-jest": "24.1.0",
"typescript": "^3.9.7",
"vinyl-buffer": "1.0.1",
"vinyl-source-stream": "2.0.0",
"vinyl-transform": "1.0.0",
"webfonts-generator": "^0.4.0",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.10"
},
"scripts": {
"type-check": "tsc --noEmit",
"testwatch": "jest --watch",
"test": "./node_modules/.bin/jest",
"buildwebpackdev": "webpack --config webpack.dev.js",
"buildwebpackprod": "webpack --config webpack.prod.js",
"build": "npm run type-check & npm run buildwebpackprod",
"dev": "npm run type-check & npm run buildwebpackdev",
"watch": "webpack --config webpack.dev.js --watch"
},
"eslintConfig": {
"extends": "react-app"
},
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/setupTests.ts",
"setupFiles": [
"raf/polyfill"
],
"reporters": [
"default",
"jest-junit"
],
"transform": {
"^.+\\.js?$": [
"babel-jest",
{
"rootMode": "upward-optional"
}
],
"^.+\\.tsx?$": "ts-jest"
},
"globals": {
"ts-jest": {
"tsConfig": "tsconfig.test.json",
"isolatedModules": true
}
},
"testRegex": "__tests__/.*.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"transformIgnorePatterns": [
"/node_modules/(?!promise-polyfill)"
],
"modulePathIgnorePatterns": [
"<rootDir>/wwwroot/",
"<rootDir>/__tests__/Helpers/",
"<rootDir>/__tests__/TestUtils/"
],
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react",
"<rootDir>/node_modules/react-dom",
"<rootDir>/node_modules/react-addons-test-utils",
"<rootDir>/node_modules/fbjs"
],
"modulePaths": [
"<rootDir>/src",
"<rootDir>/node_modules"
],
"verbose": true,
"testURL": "http://localhost/"
}
}
babel-jest rootMode was originaly 'upward' even though there's no other babel config files than the root.
Automatic config now reports coverage in the ui and in vscode, it's an improvement :)
Good to hear it! So the only error that you are getting now is:
[Info] console.log: Jest: ● Test suite failed to run
[Info] TypeError: this._resolver.resolveStubModuleName is not a function
[Info] at Runtime._generateMock (node_modules/@jest/core/node_modules/jest-runtime/build/index.js:1477:22)
or there're some more errors?
this._resolver.resolveStubModuleName is not a function
seems to be the main error, along with some TypeError: Cannot read property '1' of null
which I think is a missing babel config or related to the previous error
I have created this sample repo with your configs as is and a dummy test file, and automatic config is working for me (runs the test as expected). Can you please clone the repo, npm i
and see if Wallaby is working for you? If it is working, the issue is unlikely related to your configs, but may be specific to one of your tests. If it's the case, can you try cloning the sample repo and add the bits missing to reproduce the issue? Likely it is some test that is doing module mocking (judging from the error message).
Thanks for the update. Will look into it later tonight. Tests are using jest mocks and shallow rendering with enzyme. I'll keep you updated
Could not reproduce the issue with the sample repo and my configs; it's something else in the project or some outdated packages. Thanks for the help, I'll close the issue
Hello,
i'm having issues with wallaby; it was working well a couple months ago, now i'm back in this old project and wallaby was broken. I adjusted wallaby configs to reflect project changes, and now only some tests are running (approx 70 out of 1400+).
Jest tests are running when using npm run tests.
I renewed my license a couple days ago thinking it may be the issue or it required an update. The remaining issue now seems related to a missing babel config for polyfil ... did anyone see similar errors before?
wallabyjs.config
babel.config.js:
setupTests.ts:
tsconfig.json:
tsconfig.test.json:
diagnostic report: