This project demonstrates advanced Test-Driven Development practices using Node.js with the built-in test runner.
- Current Version: Node.js v20.9.0
- Target Version: Node.js v22.20.0 (Latest LTS)
- Current npm: v10.8.3
You have several options to upgrade Node.js to the latest LTS version (v22.20.0):
# Install the latest LTS version
volta install node@lts
# Pin this version to your project
volta pin node@lts# Install latest LTS (requires sudo)
sudo n lts
# Or install specific version
sudo n 22.20.0# Install nvm first if not installed
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Then install and use Node.js LTS
nvm install --lts
nvm use --lts
nvm alias default lts/*- Visit https://nodejs.org/
- Download the LTS version (v22.20.0)
- Install the package
-
Verify the installation:
node --version # Should show v22.20.0 npm --version # Should show v10.x.x or higher
-
Update npm to latest version:
npm install -g npm@latest
-
Install project dependencies (when you add them):
npm install
-
Run tests to verify everything works:
npm test
Advanced-TDD-with-NodeJS/
├── package.json # Project configuration with Node.js v22 requirements
├── .nvmrc # Node.js version pinning (22.20.0)
├── index.js # Main application with sample functions
├── test/
│ └── index.test.js # Test files using Node.js built-in test runner
└── README.md # This file
- Modern ES Modules: Uses
"type": "module"for native ES6 imports/exports - Built-in Test Runner: Uses Node.js native test runner (no external dependencies)
- Version Constraints: Enforces Node.js >=22.0.0 and npm >=10.0.0
- Watch Mode: Supports
--watchflag for development and testing - TDD Ready: Pre-configured for Test-Driven Development workflow
npm test- Run all testsnpm run test:watch- Run tests in watch modenpm start- Start the applicationnpm run dev- Start the application in watch mode
- Performance improvements: Better V8 engine performance
- Enhanced security: Updated security features and patches
- Better ES modules support: Improved ESM compatibility
- New built-in test runner features: Enhanced testing capabilities
- Updated dependencies: Latest versions of core dependencies
- Write a failing test in the
test/directory - Run the test with
npm testto see it fail - Write minimal code to make the test pass
- Refactor while keeping tests green
- Repeat the cycle
- Upgrade Node.js following the instructions above
- Run
npm testto verify the setup - Start writing your tests and implementation following TDD principles
If you encounter issues after upgrading:
- Clear npm cache:
npm cache clean --force - Delete node_modules:
rm -rf node_modules package-lock.json - Reinstall dependencies:
npm install - Check Node.js version:
node --version - Check npm version:
npm --version
- Add more sophisticated testing scenarios
- Implement CI/CD pipeline
- Add code coverage reporting
- Integrate with testing frameworks like Jest or Mocha if needed
- Add linting and formatting tools (ESLint, Prettier)
Néo BOUGIO & Paqui ESTHER