Skip to content

Latest commit

 

History

History
130 lines (92 loc) · 3.72 KB

File metadata and controls

130 lines (92 loc) · 3.72 KB

🧪 Fullstack App Testing Suite

This project includes comprehensive testing for the fullstack web application, covering integration tests, unit tests, UI automation using Selenium, and performance/load testing.


📂 Directory Structure

tests/
├── integration/
│ ├── auth.test.js
│ ├── inMemory.js
│ └── task.test.js
├── selenium-tests/
│ ├── loginAutomation.js
│ └── taskDetailAutomation.js
├── unit/
│ └── utility.test.js
└── performance/
  └── loadtest.js

🛠️ Testing Tools & Libraries Used

Tool Purpose
jest JavaScript test runner used for unit and integration tests
supertest HTTP assertions for API endpoint testing
mongodb-memory-server Creates an ephemeral in-memory MongoDB instance for testing
selenium-webdriver + chromedriver Browser automation for UI testing
k6 Performance and load testing tool

✅ Test Categories

🔹 1. Integration Tests (tests/integration/)

auth.test.js

  • Tests user creation and authentication routes using supertest.
  • Validates response structure and status codes.

inMemory.js

  • Connects to an in-memory MongoDB instance using mongodb-memory-server.
  • Inserts and retrieves a user document to confirm DB operations work in isolation.

task.test.js

  • Verifies /task/new and /task/update endpoints.
  • Ensures task creation and update flows are functional.

🔹 2. Unit Tests (tests/unit/)

utility.test.js

  • Unit test for assembleUserState utility function.
  • Validates correct session and task data retrieval.
  • Uses test fixtures for users, tasks, and comments in MongoDB.

🔹 3. UI Automation Tests (tests/selenium-tests/)

loginAutomation.js

  • Automates login form interaction on the frontend using Selenium.
  • Verifies if login is successful by checking for presence of dashboard header.

taskDetailAutomation.js

  • Simulates a user interacting with a task detail page:
    • Updates task name
    • Toggles task completion status
    • Changes task group
    • Adds a comment
    • Navigates back to dashboard
  • Waits for each step using Selenium's until feature for reliability.

🔹 4. Load Testing (tests/performance/loadtest.js)

loadtest.js

  • Uses k6 to simulate concurrent user traffic:
    • Gradually ramps up to 100 virtual users
    • Measures response time performance
  • Checks that homepage loads within 500ms for each request.

🧪 How to Run the Tests

✅ Unit & Integration Tests (Jest)

npm install
npm test

✅ Selenium UI Tests

Ensure you have Chrome installed and chromedriver is available in PATH.

node tests/selenium-tests/loginAutomation.js
node tests/selenium-tests/taskDetailAutomation.js

✅ Load Testing with k6

Install k6 from https://k6.io/docs/getting-started/installation/

k6 run tests/performance/loadtest.js

📌 Summary

  • ✔️ End-to-end testing coverage across API, UI, DB, and performance layers.

  • ⚙️ Simulated real-world browser usage via Selenium.

  • 🧠 Isolated DB testing with no side effects using in-memory MongoDB.

  • 📈 Scalable load simulation via k6 to ensure system stability under load.

📎 Notes

  • All tests assume the application is running locally on http://localhost:8080/.

  • For Selenium, ensure forms have accessible input field names (e.g., name="username").

  • Load testing is read-only — no data is posted or mutated.