This project demonstrates how to write unit tests using Jasmine
and Karma for a simple LoginService in JavaScript.
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