https://github.com/leonsilva15/javascript-testing
JavaScript unit testing using Vitest
https://github.com/leonsilva15/javascript-testing
aaa-testing code-coverage javascript unit-testing vite vitest vitest-ui
Last synced: 26 days ago
JSON representation
JavaScript unit testing using Vitest
- Host: GitHub
- URL: https://github.com/leonsilva15/javascript-testing
- Owner: LeonSilva15
- Created: 2024-06-15T00:05:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-28T09:42:08.000Z (almost 2 years ago)
- Last Synced: 2025-08-30T10:40:21.735Z (9 months ago)
- Topics: aaa-testing, code-coverage, javascript, unit-testing, vite, vitest, vitest-ui
- Language: JavaScript
- Homepage:
- Size: 133 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
* [Vitest](./Vitest.md)
* [Types of Testing](./Types%20of%20Testing.md)
* [Best Practices](./Best%20Practices.md)
## Initial setup
1. Initialize your project
```bash
npm init
```
2. Install Vitest as a development dependency
```bash
npm i -D vitest
```
3. Add the test command to your package.json
```text
scripts: {
...
"test": "vitest"
}
```
4. Run your tests in watch mode
```bash
npm run test
```


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


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

