nvim-neotest / neotest-jest

MIT License
116 stars 79 forks source link

Enhance jest detection #80

Closed Jamie-505 closed 5 months ago

Jamie-505 commented 11 months ago

adds another check to see if jest should be used to test. For some repositories the jest dependency is not in the nearest package.json (relative to the test file) nor in the root of the project. In this case the former approach would return No tests found

But imo if we have the package.json test script set to jest it indicates that we want to use jest for testing.

This might also solve the issue #74

mikaoelitiana commented 8 months ago

@Jamie-505 I have another case where the project does not have a jest script but has a jest configuration inside package.json like this : https://github.com/kentcdodds/advanced-react-hooks/blob/92003d082d565e7a8cfb26387d91b89e040065ae/package.json#L27-L57

"devDependencies": {
    "@craco/craco": "^6.4.3",
    "@types/react": "^18.0.14",
    "@types/react-dom": "^18.0.5",
    "husky": "^4.3.8",
    "npm-run-all": "^4.1.5",
    "prettier": "^2.7.1",
    "react-scripts": "^5.0.1"
  },
  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "craco test",
    "test:coverage": "npm run test -- --watchAll=false",
    "test:exercises": "npm run test -- testing.*exercises\\/ --onlyChanged",
    "setup": "node setup",
    "lint": "eslint .",
    "format": "prettier --write \"./src\"",
    "validate": "npm-run-all --parallel build test:coverage lint"
  },
  "husky": {
    "hooks": {
      "pre-commit": "node ./scripts/pre-commit",
      "pre-push": "node ./scripts/pre-push"
    }
  },
  "jest": {
    "collectCoverageFrom": [
      "src/final/**/*.js"
    ]
  },

It would be great if we could also check the jest configuration key