Cannot run component testing in pre-commit hook
See original GitHub issueCurrent behavior
If I add “npx cypress run-ct” in .git/pre-commit and use default vs code git GUI to make a commit I get an error:
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
> template@1.0.0 pre-commit
> npm run test-ci
> template@1.0.0 test-ci
> cross-env NODE_ENV=development cypress run-ct
We found an invalid configuration value:
Found an error while validating the `browsers` list. Expected `version` to be a non-empty string. Instead the value was: `{"name":"electron","channel":"stable","family":"chromium","displayName":"Electron","version":"","path":"","info":"Electron is the default browser that comes with Cypress. This is the default browser that runs in headless mode. Selecting this browser is useful when debugging. The version number indicates the underlying Chromium version that Electron uses."}`
husky - pre-commit hook exited with code 1 (error)
Desired behavior
The hook runs with no errors
Test code to reproduce
I added husky to make it easier to run hooks (the problem can be reproduced without it)
How to reproduce:
- Clone Repo
- npm i
- npm set-script new “cypress run-ct” # make changes to repo
- use vs code (version 1.59, all extensions disabled) to commit changes and click “Show command output”
Cypress Version
8.2.0
Other
If I change cypress version to 7.7.0 the error changes to something like this: “Cannot import module “–run-project”” If I run another command e.g. open-ct it succeeds If I commit without using VS Code git GUI then the hook with run-ct succeeds
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Precommit hook not triggering even after failures
If i dont add cross-env CI=true , the jest test cases wont break. I am trying to perform for both linting and unit...
Read more >Supported hooks - pre-commit
php-unit - Run the full php unit test. Checks which PHPUnit executable is available first and then runs it. Preference order is vendor/bin,...
Read more >How to lint and test your code using git pre-commit hooks
How to use Git hooks, husky and lint-staged to run scripts that run linting and testing tools before we make a commit or...
Read more >Run tests | IntelliJ IDEA Documentation - JetBrains
When you want to check that your changes wouldn't break the code before committing them, you can do that by running tests as...
Read more >How to run ESLint using a pre-commit hook - Level Up Coding
ESLint Git pre-commit hook · If you haven't initialized git for your repo then do so by running the command: git init ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I run into the same problem in VSCode. As @jennifer-shehane asked about the environment variables, I added an ‘export’ command before the test run. And yes, besided a lot of other stuff, it shows
export ELECTRON_RUN_AS_NODE=“1”
So VSCode sets this automatically.
I change my pre_commit file and it commited fine.
I experience the same problem on MacOS. I have the similar log as @JessicaSachs has.