This is a showcase project demonstrating how to use TWD (Test Web Dev) with Angular for testing web applications. TWD is a powerful testing framework that allows you to write tests that interact with your web app like a real user would.
TWD is a comprehensive testing framework for web applications. It provides:
- User-centric testing approach
- Integration with modern development workflows
- Support for multiple frameworks including Angular
This showcase includes:
- Home Page (
/) - Counter component demonstrating basic interactions - Todo List (
/todos) - Full CRUD operations with API integration - TWD Tests - Comprehensive test scenarios for both pages
To start a local development server, run:
npm startOr alternatively:
ng serveOnce the server is running, open your browser and navigate to http://localhost:4200/. The application will automatically reload whenever you modify any of the source files.
When running in development mode, TWD will automatically load and initialize its testing framework from the test files in src/twd-tests/.
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
ng generate component component-nameFor a complete list of available schematics (such as components, directives, or pipes), run:
ng generate --helpTo build the project for production, run:
npm run buildOr alternatively:
ng buildThis will compile your project and store the build artifacts in the dist/ directory. By default, the production build optimizes your application for performance and speed. TWD testing code will be tree-shaken and removed from production builds.
This project uses TWD for testing. Tests are automatically loaded in development mode and can be run through the TWD interface in your browser.
To run the development server with TWD:
npm startThen navigate to http://localhost:4200/ and access the TWD testing interface. The test files are located in src/twd-tests/:
helloWorld.twd.test.ts- Tests for the home page countertodoList.twd.test.ts- Tests for the todo list functionality
To add new TWD tests to this project:
- Create a new test file in
src/twd-tests/with the.twd.test.tsextension - Add the import path to the tests object in
src/main.ts:
const tests = {
'./twd-tests/helloWorld.twd.test.ts': () => import('./twd-tests/helloWorld.twd.test'),
'./twd-tests/todoList.twd.test.ts': () => import('./twd-tests/todoList.twd.test'),
'./twd-tests/your-new-test.twd.test.ts': () => import('./twd-tests/your-new-test.twd.test'),
};For more information on writing TWD tests, visit the TWD documentation.
To execute unit tests with the Vitest test runner, use the following command:
npm testOr alternatively:
ng testFor end-to-end (e2e) testing, run:
ng e2eAngular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
- TWD Documentation - Learn how to write and run tests with TWD
- Angular CLI Overview and Command Reference - Angular CLI documentation
- Angular Documentation - Complete Angular framework documentation