DEV Community

Cover image for The lazy CI - Running tests on git push!
Quentin Ménoret
Quentin Ménoret

Posted on • Edited on

2

The lazy CI - Running tests on git push!

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

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more