DEV Community

loading...
Cover image for The lazy CI - Running tests on git push!

The lazy CI - Running tests on git push!

qmenoret profile image Quentin Ménoret Updated on ・1 min read

The lazy way

I love to start projects with other people. And when we start, we want two things:

  • Build features!
  • Make sure they work

So of course, we're building a few automated tests to ensure we don't break each other code (it becomes quite fast exhausting to test everything manually).

But there is something I really don't want to spend time on. Setting up a CI! I know it can be super fast, but I just don't want to! So here I come with my stupid, but 100% working solution: the "test on push" CI.

Setup

As a lot of people, I use Husky for commit hooks. It allows me to run Prettier and Eslint in fixing mode on every commit to format and fix any error that might be around in the code.

Well, it's also possible to run some commands on push!

First, let's install Husky:
npm install husky

Then add this to your package.json:

{
  "husky": {
    "hooks": {
      "pre-push": "npm test",
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

And voilà! Whenever you'll try to push, the tests will run first to make sure you didn't break anything!


Photo by Trym Nilsen on Unsplash

Discussion (0)

pic
Editor guide