-2

I can't commit and push my code in git. What i do:

  1. git add .
  2. git commit -m "init commit"

What i get: enter image description here after that nothing works for me, I can't click anything.

My package.json

"devDependencies": {
    "husky": "^8.0.2",
    "lint-staged": "^13.1.0",
    "prettier": "^2.8.1",
   }
   
scripts": {
    "start": "cross-env PORT=3006 react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-scripts test --watchAll",
    "test:ci": "cross-env CI=true react-scripts test",
    "eslint": "eslint -c .eslintrc.js --ext .ts src/ --max-warnings=0",
    "eslint:fix": "npm run eslint -- --fix",
    "prepare": "husky install"
},

My .lintstagedrc

{
    "*.{ts,tsx}": "npm run eslint",
    "*.test.{ts,tsx}": "npm run test:ci"
}

npm install does not help(

torek
  • 448,244
  • 59
  • 642
  • 775
  • 1
    I guess your question is not actually related to the pre-commit.com framework, right? Please read the descriptions of the tags you are adding to make sure they actually match your question. – CherryDT Dec 26 '22 at 12:54
  • 3
    It looks like when you commit you're running a git hook that runs the tests in watch mode which is blocking the terminal process. – Andy Dec 26 '22 at 12:54
  • 1
    Check your scripts section. It seems you have configured the script that should run tests once to actually start the test framework in watch mode. (of course you can exit watch mode by pressing `q` as the console output explains to you, but it's better to actually fix the root cause.) – CherryDT Dec 26 '22 at 12:56
  • 1
    None of these 3 screenshots is even remotely related to `git` commands or `git` output. `git` !== `nodejs`, `npm` or `typescript`. – Peter B Dec 26 '22 at 12:56
  • Also, thanks for updating tags, but you added another probably unrelated tag (github) - the description there also explains to only use this tag for issues with functionality specific to GitHub and not for a Git issue where the repo simply happens to be hosted there. This is not just nitpicking, tags have a purpose, for example users can have watched tags with which they get notified when new questions are posted relevant to their expertise, so using the right tags is important. – CherryDT Dec 26 '22 at 12:58
  • @CherryDT when i press any key nothing is going on( – Vadym Korzhynovskyi Dec 26 '22 at 12:59
  • As mentioned, check your scripts section in your package.json. If you don't know what to look out for, edit it into your question so we can know what's going on. (But I guess `test:ci` has an incorrect command that enables watch mode) – CherryDT Dec 26 '22 at 13:01
  • Your watch script is not connected to your keyboard, so you can't control it here. It's still waiting anyway, in spite of the fact that it will never get what it's waiting for! Don't use the watch script here. – torek Dec 26 '22 at 14:57
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 26 '22 at 17:48

1 Answers1

0

You tests are being run in watch mode, as people have said in the comments.

The test:ci command you have is intended to disable watching by creating the CI environment variable, but you're probably not running on the platform that command was written for.

The simplest solution is to add the --watchAll=false command line option in the test:ci script:

"test:ci": "cross-env CI=true react-scripts --watchAll=false test",

Ref: https://create-react-app.dev/docs/running-tests/#on-your-own-environment

PS: I'm not familiar with cross-env, but that reference shows ways you might configure test:ci on various platforms.

joanis
  • 10,635
  • 14
  • 30
  • 40