A minimal web app that demonstrates a clickable counter with a reset button. It includes a small automated test suite using Jest and jsdom.
Features
- Click the Click me button to increment the counter.
- Click Reset to set the counter back to zero.
- Simple, accessible HTML and small JavaScript module.
- Automated tests using Jest +
jest-environment-jsdom.
Files
index.html— the page markup and UI.script.js— application logictest/app.test.js— Jest tests that simulate user clicks.package.json— test script and Jest configuration.
Requirements
- Node.js and npm (for running tests).
Install dependencies
npm installOption 1.
You can open index.html directly in your browser by double-clicking it.
Option 2.
# Using Python's simple server (if Python is installed). From the project root:
python -m http.server 8000
# then open http://localhost:8000 in your browser
'http://localhost:8000'Option 3.
# Install http-server if you don't have it
npm install -g http-server
# From the project root:
http-server .
# then open http://localhost:8000 in your browser
'http://localhost:8000'This project uses Jest for automated testing.
npm testNotes about the test environment
testEnvironmentis set tojsdominpackage.jsonandjest-environment-jsdomis installed as a dev dependency.- The test loads
index.htmlinto the test DOM, requiresscript.js, dispatches aDOMContentLoadedevent so the app initializes, simulates clicks withbutton.click(), and asserts thecounterDisplayvalue.