Skip to content

Latest commit

 

History

History
73 lines (66 loc) · 2.33 KB

README.md

File metadata and controls

73 lines (66 loc) · 2.33 KB

JavaScript Testing

Testing in software development is a crucial process aimed at ensuring the quality, functionality, and reliability of software applications. It involves executing software with the intent of identifying errors, gaps, or missing requirements compared to the desired outcomes. The process of software testing can be broadly categorized into several key types, each serving a specific purpose within the development lifecycle

You can also read:

Initial setup

  1. Initialize your project
    npm init
  2. Install Vitest as a development dependency
    npm i -D vitest
  3. Add the test command to your package.json
    scripts: {
        ...
        "test": "vitest"
    }
    
  4. Run your tests in watch mode
    npm run test

1 - vitest running 2 - vitest commands

Test UI

  1. Install @vitest/ui
    npm i -D @vitest/ui
  2. Add test:ui command to package.json
    scripts: {
        ...
        "test:ui": "vitest --ui"
    }
    
  3. Run the test:ui command
    npm run test:ui

3 - vitest ui 4 - vitest ui 2

Code Coverage

  1. Add the command to package.json
    scripts: {
        ...
        "coverage": "vitest run --coverage"
    }
    
  2. Run the coverage command and install the dependencies
    npm run coverage
  3. Re-run the command
    npm run coverage
  4. Go to the generated coverage directory
  5. Open your index.html file (recommended extension - LiveServer)

5 - vitest coverage 6 - vitest coverage 2