Skip to content

Unit testing demo using Jasmine and Karma with simulated login logic and test lifecycle hooks.

Notifications You must be signed in to change notification settings

bmensh821/jasmine-karma-login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ§ͺ Jasmine + Karma Unit Testing Demo

This project demonstrates how to write unit tests using Jasmine and Karma for a simple LoginService in JavaScript.

πŸ“‚ Project Structure

qa-jasmine-karma-login/
β”œβ”€β”€ src/              # Business logic (LoginService)
β”œβ”€β”€ spec/             # Jasmine tests
β”œβ”€β”€ karma.conf.js     # Karma configuration
β”œβ”€β”€ package.json
β”œβ”€β”€ .gitignore
└── README.md

## 🧠 Features

- Jasmine test structure using `describe`, `it`, `beforeEach`, `afterEach`, etc.
- Simulated in-memory mock data (`users`) to test login logic
- SQL injection pattern check
- Clean setup and teardown using Jasmine hooks

## πŸš€ Getting Started

### πŸ“¦ Install dependencies

```bash
npm install

▢️ Run the tests
npm run karma

πŸ”„ Lifecycle Hooks Used

| Hook         | Purpose                                |
| ------------ | -------------------------------------- |
| `beforeAll`  | Runs once before all tests             |
| `afterAll`   | Runs once after all tests              |
| `beforeEach` | Resets mock user data before each test |
| `afterEach`  | Clears mock data after each test       |


πŸ’‘ Why This Matters
This is useful for QA Engineers who want to:
- Contribute to frontend codebases (Angular, React)
- Collaborate with developers on unit testing
- Shift testing left and catch bugs earlier

πŸ‘€ Author
Benyapak Mensh

About

Unit testing demo using Jasmine and Karma with simulated login logic and test lifecycle hooks.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published