Skip to content

Commit b5ae647

Browse files
committed
Refactor README.md to improve structure and content
1 parent 7ffd448 commit b5ae647

File tree

1 file changed

+188
-2
lines changed

1 file changed

+188
-2
lines changed

README.md

+188-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,188 @@
1-
# node-testrunner
2-
NodeJS native test runner template
1+
# Node.js Native Test Runner Template
2+
3+
[![CI Status](https://github.com/tryb3l/node-testrunner/actions/workflows/nodetest.yml/badge.svg)](https://github.com/tryb3l/node-testrunner/actions)
4+
5+
## Table of Contents
6+
7+
- [Introduction](#introduction)
8+
- [Best Practices and Design Decisions](#best-practices-and-design-decisions)
9+
- [Project Structure](#project-structure)
10+
- Features
11+
- [Native Node.js Test Runner](#native-nodejs-test-runner)
12+
- [Minimal Dependencies](#minimal-dependencies)
13+
- [Modular and Scalable Structure](#modular-and-scalable-structure)
14+
- [Undici HTTP Client](#undici-http-client)
15+
- [Continuous Integration and Continuous Deployment (CI/CD)](#continuous-integration-and-continuous-deployment-cicd)
16+
- [Future Enhancements](#future-enhancements)
17+
- [Getting Started](#getting-started)
18+
- [Prerequisites](#prerequisites)
19+
- [Installation](#installation)
20+
- [Running the Tests](#running-the-tests)
21+
- [Project Details](#project-details)
22+
- [Important Files and Directories](#important-files-and-directories)
23+
- [Contributing](#contributing)
24+
- [License](#license)
25+
26+
## Introduction
27+
28+
This project is a template for demonstrating the capabilities and features of the native Node.js test runner with minimal dependencies. It leverages the latest features of Node.js to provide a modular, scalable, and efficient testing framework suitable for modern JavaScript applications.
29+
30+
### Best Practices and Design Decisions
31+
32+
- **Modular Architecture**: The project is structured in a modular way to improve readability and maintainability. Each module is responsible for a specific functionality, making the codebase easier to understand and extend.
33+
- **Scalability**: The project structure is designed to be easily scalable. New features and tests can be added without disrupting the existing codebase.
34+
- **Separation of Concerns**: The project separates unit tests and integration tests to ensure that each type of test is focused on its specific purpose.
35+
- **Efficient HTTP Client**: The project uses [`undici`](https://github.com/nodejs/undici 'Go to definition') for HTTP requests due to its speed and memory efficiency. [`undici`](https://github.com/nodejs/undici 'Go to definition') is maintained by the Node.js development team, ensuring compatibility and performance.
36+
- **Continuous Integration**: The project includes a CI/CD pipeline using GitHub Actions to automatically run tests on each push or pull request, ensuring code quality and reliability.
37+
38+
## Project Structure
39+
40+
```
41+
node-testrunner/
42+
├── .env
43+
├── .eslintrc.json
44+
├── .github/
45+
│ └── workflows/
46+
│ └── nodetest.yml
47+
├── .gitignore
48+
├── .prettierrc
49+
├── logger.cjs
50+
├── Makefile
51+
├── package.json
52+
├── README.md
53+
├── test-settings.json
54+
├── tests/
55+
│ ├── integration/
56+
│ │ └── auth/
57+
│ │ ├── login.test.cjs
58+
│ │ └── register.test.cjs
59+
│ ├── unit/
60+
│ │ ├── data-generators.test.cjs
61+
│ │ ├── http-utils.test.cjs
62+
│ │ └── user-utils.test.cjs
63+
│ └── utils/
64+
│ ├── crypto/
65+
│ │ └── crypto.cjs
66+
│ ├── data/
67+
│ │ └── data-generators.cjs
68+
│ ├── env.cjs
69+
│ ├── http/
70+
│ │ └── http-utils.cjs
71+
│ └── user/
72+
│ └── user-utils.cjs
73+
```
74+
75+
## Features
76+
77+
### Native Node.js Test Runner
78+
79+
- Utilizes the **native Node.js test runner** introduced in recent versions of Node.js, eliminating the need for external testing libraries.
80+
- Provides a simple and efficient way to write and run tests using the built-in `node:test` module.
81+
- Demonstrates the capabilities of the Node.js test runner for both **unit tests** and **integration tests**.
82+
83+
### Minimal Dependencies
84+
85+
- Focuses on minimizing external dependencies to reduce overhead and simplify the project.
86+
- Relies mainly on Node.js core modules and a few carefully selected packages.
87+
88+
### Modular and Scalable Structure
89+
90+
- Employs a **modular project structure** to improve the readability and maintainability of tests.
91+
- Easily **scalable** to accommodate additional tests and features as the project grows.
92+
93+
### Undici HTTP Client
94+
95+
- Uses [`undici`](https://github.com/nodejs/undici) as the HTTP client for its **exceptional speed** and **memory efficiency**.
96+
- [`undici`](command:_github.copilot.openSymbolFromReferences?%5B%22%22%2C%5B%7B%22uri%22%3A%7B%22scheme%22%3A%22file%22%2C%22authority%22%3A%22%22%2C%22path%22%3A%22%2FUsers%2Fbohdan%2FDocuments%2Fprojects%2Fnode-testrunner%2FREADME.md%22%2C%22query%22%3A%22%22%2C%22fragment%22%3A%22%22%7D%2C%22pos%22%3A%7B%22line%22%3A226%2C%22character%22%3A43%7D%7D%5D%2C%22950925b3-d226-43ae-bf14-7582f6085a12%22%5D 'Go to definition') is maintained by the Node.js development team, ensuring compatibility and performance.
97+
- Simplifies HTTP request handling in tests with modern APIs.
98+
99+
### Continuous Integration and Continuous Deployment (CI/CD)
100+
101+
- Includes a **CI/CD pipeline** using GitHub Actions.
102+
- Automatically runs tests on each **push** or **pull request**, ensuring code quality and reliability.
103+
104+
### Future Enhancements
105+
106+
- Plans to add **Docker support** to run tests inside an isolated, containerized environment.
107+
- Aims to improve portability and ease of deployment across different systems.
108+
109+
## Getting Started
110+
111+
### Prerequisites
112+
113+
- **Node.js v23 or later** is required to utilize the latest features.
114+
- **npm** is needed for package management.
115+
116+
### Installation
117+
118+
Clone the repository and install the dependencies:
119+
120+
```sh
121+
git clone https://github.com/yourusername/node-testrunner.git
122+
cd node-testrunner
123+
make install-dependencies
124+
```
125+
126+
### Running the Tests
127+
128+
Run all tests using the makefile:
129+
130+
```sh
131+
make run-all-tests
132+
```
133+
134+
Or run specific tests:
135+
136+
- **Unit Tests**:
137+
138+
```sh
139+
make run-unit-tests
140+
```
141+
142+
- **Integration Tests**:
143+
144+
```sh
145+
make run-integration-tests
146+
```
147+
148+
## Project Details
149+
150+
### Important Files and Directories
151+
152+
- **tests/**: Contains all test files organized into unit and integration tests.
153+
- **unit/**: Holds unit tests for individual modules.
154+
- **data-generators.test.cjs**: Tests for data generation utilities.
155+
- **http-utils.test.cjs**: Tests for HTTP utility functions.
156+
- **user-utils.test.cjs**: Tests for user-related utilities.
157+
- **integration/**: Contains integration tests that test the interaction between different modules and external APIs.
158+
- **auth/**:
159+
- **login.test.cjs**: Integration tests for the login functionality.
160+
- **register.test.cjs**: Integration tests for the user registration functionality.
161+
- **utils/**: Includes utility modules used across tests.
162+
- **crypto/**:
163+
- **crypto.cjs**: Cryptographic utility functions.
164+
- **data/**:
165+
- **data-generators.cjs**: Functions to generate random test data.
166+
- **env.cjs**: Environment configuration loader.
167+
- **http/**:
168+
- **http-utils.cjs**: HTTP request utility functions using [`undici`](command:_github.copilot.openSymbolFromReferences?%5B%22%22%2C%5B%7B%22uri%22%3A%7B%22scheme%22%3A%22file%22%2C%22authority%22%3A%22%22%2C%22path%22%3A%22%2FUsers%2Fbohdan%2FDocuments%2Fprojects%2Fnode-testrunner%2FREADME.md%22%2C%22query%22%3A%22%22%2C%22fragment%22%3A%22%22%7D%2C%22pos%22%3A%7B%22line%22%3A226%2C%22character%22%3A43%7D%7D%5D%2C%22950925b3-d226-43ae-bf14-7582f6085a12%22%5D 'Go to definition').
169+
- **user/**:
170+
- **user-utils.cjs**: Utility functions for user operations in tests.
171+
- **Makefile**: Provides convenient commands for installing dependencies and running tests.
172+
- **package.json**: Manages project metadata and scripts.
173+
- **.github/workflows/nodetest.yml**: Defines the GitHub Actions workflow for CI/CD.
174+
- **logger.cjs**: Sets up application logging using [`pino`](command:_github.copilot.openSymbolFromReferences?%5B%22%22%2C%5B%7B%22uri%22%3A%7B%22scheme%22%3A%22file%22%2C%22authority%22%3A%22%22%2C%22path%22%3A%22%2FUsers%2Fbohdan%2FDocuments%2Fprojects%2Fnode-testrunner%2FREADME.md%22%2C%22query%22%3A%22%22%2C%22fragment%22%3A%22%22%7D%2C%22pos%22%3A%7B%22line%22%3A168%2C%22character%22%3A40%7D%7D%5D%2C%22950925b3-d226-43ae-bf14-7582f6085a12%22%5D 'Go to definition') and `pino-pretty` for readable console output.
175+
- **test-settings.json**: Stores configuration settings for tests, such as test user data.
176+
- **.env**: Loads environment variables from the
177+
178+
.env
179+
180+
file.
181+
182+
## Contributing
183+
184+
Contributions are welcome! Please open an issue or submit a pull request for any improvements or suggestions.
185+
186+
## License
187+
188+
This project is licensed under the MIT License.

0 commit comments

Comments
 (0)