Santosh Rai

Santosh Rai

Full Stack Engineer | RPA Engineer

How to apply automated unit testing and continuous integration to a simple JavaScript project?

By rai24 on

What is automated testing?

Automated Testing is testing where tests are run without human intervention.

What is Continuous Integration?

Continuous Integration is the practice of integrating of code change into single codebase continuously.

Steps

Let’s make pipeline for software development

Concept:

These can be done with the help of continuous integration.

Preparation:

Let’s get into Github actions as a CI/CD service.

For CI/CD service, there needs to be configured with a YAML file which takes:

Github search config file under ./github/workflows so let’s create javascript.yaml file under ./github/workflows

    name: JavaScript workflow
    on: [push]
    jobs:
      test:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v1
        - name: Use Node.js 12.x
          uses: actions/setup-node@v1
          with:
            node-version: "12.x"
        - name: npm install, and test
          run: |
            npm install
            npm test
          env:
            CI: true

Action:

Now commit the code and push it to github.

Observation:

You will see the running job on the GitHub Actions Tab. I committed two times, one for the wrong script and another for the correct script.