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

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs