wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
759 stars 45 forks source link

Can't run Wallaby with new npm package jest-runner-groups #2367

Closed blopez2010 closed 4 years ago

blopez2010 commented 4 years ago

Issue description or question

Because of the need to run unit tests and integration tests with Jest, we have to make use of this package jest-runner-groups (https://www.npmjs.com/package/jest-runner-groups).

After adding the specified configuration, Wallaby stops working.

We have to add the following lines to the jest.config.js:

  runner: "groups",
  extraGlobals: []

After running WallabyJs we have this error in the console:

[Info]  Started Wallaby.js Core v1.0.862
[Error] Failed to load configuration file: Automatic Jest configuration error: Can not find any Jest runner configurations in 'C:\Code\Web\next-js'. 

If I delete those lines and rerun WallabyJs, everything works as expected.

Current jest.config.js file

module.exports = {
  moduleDirectories: ["node_modules", "src", "static", "store"],
  modulePathIgnorePatterns: ["<rootDir>/node_modules/prismjs/plugins/line-numbers"],
  collectCoverage: true,
  verbose: false,
  automock: false,
  setupFiles: ["./setupTests.js"],
  moduleNameMapper: {
    "^functions/(.*)$": "<rootDir>/src/components/Functions/$1",
    "scripts(.*)$": "<rootDir>/src/scripts/$1",
    "^/(.*)$": "<rootDir>/src/$1",
    "^store(.*)$": "<rootDir>/store/$1",
    "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
  },
  coveragePathIgnorePatterns: ["/node_modules/"],
  coverageThreshold: {
    global: {
      branches: 25,
      functions: 20,
      lines: 40,
      statements: 40
    }
  },
  runner: "groups",
  extraGlobals: []
};

Current package.json

{
  "private": true,
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start -p $PORT",
    "postinstall": "next build",
    "test": "jest --maxWorkers=4 --colors --group=unit",
    "test:watch": "jest --watch --group=unit",
    "test:coverage": "jest --coverage --group=unit",
    "test:CI": "jest --maxWorkers=4 --colors --coverage --coverageReporters=cobertura --json --outputFile=coverage/testResults.json --ci --reporters=default --reporters=jest-junit --group=unit",
    "test:CI:Integration": "jest --maxWorkers=4 --colors --coverage --coverageReporters=cobertura --json --outputFile=coverage/testResults.json --ci --reporters=default --reporters=jest-junit --group=integration",
    "export": "next export"
  },
  "dependencies": {
    "@babel/core": "^7.8.6",
    "@contentful/rich-text-react-renderer": "^13.4.0",
    "@contentful/rich-text-types": "^14.0.1",
    "@fortawesome/fontawesome-pro": "^5.11.2",
    "@fortawesome/fontawesome-svg-core": "^1.2.25",
    "@fortawesome/free-brands-svg-icons": "^5.11.2",
    "@fortawesome/free-solid-svg-icons": "^5.11.2",
    "@fortawesome/pro-light-svg-icons": "^5.11.2",
    "@fortawesome/pro-regular-svg-icons": "^5.11.2",
    "@fortawesome/pro-solid-svg-icons": "^5.11.2",
    "@fortawesome/react-fontawesome": "^0.1.7",
    "@microsoft/applicationinsights-web": "^2.3.1",
    "@optimizely/react-sdk": "^1.0.1",
    "@types/react": "^16.9.14",
    "@zeit/next-css": "^1.0.1",
    "axios": "^0.19.0",
    "babel-plugin-prismjs": "^1.1.1",
    "compression": "^1.7.4",
    "contentful": "^7.10.0",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "google-map-react": "^1.1.5",
    "isomorphic-unfetch": "^3.0.0",
    "jest-junit": "^10.0.0",
    "jest-runner-groups": "^1.1.1",
    "js-cookie": "^2.2.1",
    "lodash": "^4.17.15",
    "next": "^9.2.2",
    "next-redux-wrapper": "^3.0.0",
    "nookies": "^2.0.8",
    "prismjs": "^1.17.1",
    "prop-types": "^15.7.2",
    "react": "^16.13.0",
    "react-click-outside": "^3.0.1",
    "react-dom": "^16.13.0",
    "react-loading-skeleton": "^1.3.0",
    "react-redux": "^7.1.3",
    "redux": "^4.0.4",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.2",
    "enzyme-to-json": "^3.4.3",
    "husky": "^4.2.3",
    "istanbul-reports": "^3.0.0",
    "jest": "^24.9.0",
    "jest-cli": "^25.1.0",
    "jest-fetch-mock": "^3.0.1",
    "react-media": "^1.10.0",
    "react-test-renderer": "^16.12.0",
    "redux-mock-store": "^1.5.4"
  }
}
smcenlly commented 4 years ago

Thanks for reporting the problem. We have added support for using jest-runner-groups. This is available in the latest version of Wallaby core, v1.0.863. Wallaby should update automatically with the latest version within a few minutes after starting your editor. If it does not, or you want to update sooner, you may force a core update.


Please note that while Wallaby now supports using jest-runner-groups, the way that Wallaby integrates with jest, and the way that the jest-runner-groups works means that it is not possible to tell wallaby to only run one group of tests. The jest-runner-groups assumes that tests are launched using the jest CLI and using the process argv to determine which groups to run.

If you would like Wallaby to only run a subset of your tests (e.g. for one group) then you may override automatic configuration defaults and add the tests you do not want to run in the tests setting of your overridden configuration.