This guide explains how to test your npm-practice changes on Linux using Docker.
Make sure the Linux Docker image is built with your latest changes:
docker build -f Dockerfile.linux -t npm-practice-linux .Note: You need to rebuild the image every time you make code changes!
npm run test-linuxThis builds the image and runs all automated tests. Full output is displayed.
npm run test-linux-quickShows only the last 25 lines (test summary).
- ✅ 89 tasks run automatically
- ⏭️ 18 tasks skipped (require authentication or user input)
- ⏱️ ~60-75 seconds execution time
docker run -it --rm npm-practice-linuxOr use the helper script:
./test-linux-interactive.shYou'll get a bash shell inside the Linux container.
cd /home/tester/npm-practice-source
node test-cli.jsOutput: Runs all 107 tasks, skips 18 that need authentication.
Example: Run tasks 10 to 20
cd /home/tester/npm-practice-source
node test-cli.js 10 20Syntax: node test-cli.js [start] [end]
More Examples:
# Run just task 5
node test-cli.js 5 5
# Run first 10 tasks
node test-cli.js 1 10
# Run tasks 50-60
node test-cli.js 50 60
# Run last 10 tasks
node test-cli.js 98 107If you want to be prompted for authentication tasks:
cd /home/tester/npm-practice-source
node test-cli.js --interactiveOr with a range:
node test-cli.js 46 58 --interactiveNote: You'll need to provide npm login credentials for authentication tasks.
To use the interactive CLI app and practice npm commands yourself:
cd /home/tester/npm-practice-sourcesudo npm linkOutput: Makes npm-practice command available globally.
cd /home/tester/test-workspacenpm-practiceNow you can:
- Practice npm commands task by task
- Get hints with
hint - Skip tasks with
skip - See correct answers with
show - Fast-forward with
fforfast-forward
# Inside npm-practice
quit
# or
exit
# Then exit the container
exit# 1. Make changes to your code
vim tasks.json
# 2. Rebuild Docker image with changes
docker build -f Dockerfile.linux -t npm-practice-linux .
# 3. Run quick test
npm run test-linux-quick
# 4. If tests pass, commit
git add .
git commit -m "Updated tasks"# 1. Rebuild image with latest code
docker build -f Dockerfile.linux -t npm-practice-linux .
# 2. Start interactive container
docker run -it --rm npm-practice-linux
# 3. Inside container: Test specific task range
cd /home/tester/npm-practice-source
node test-cli.js 42 42 # Test just task 42
# 4. Or test manually
sudo npm link
cd /home/tester/test-workspace
npm-practice
# Navigate to task 42 and test it# 1. Start interactive container
docker run -it --rm npm-practice-linux
# 2. Inside container: Run specific auth tasks interactively
cd /home/tester/npm-practice-source
node test-cli.js 46 58 --interactive
# You'll be prompted to login when needed| Command | Description |
|---|---|
npm run test-linux |
Full Linux test with complete output |
npm run test-linux-quick |
Shows last 25 lines (summary only) |
| Command | Description |
|---|---|
docker build -f Dockerfile.linux -t npm-practice-linux . |
Rebuild image with latest code |
docker run -it --rm npm-practice-linux |
Start interactive container |
./test-linux-interactive.sh |
Start interactive container (helper script) |
| Command | Description |
|---|---|
node test-cli.js |
Run all tests (automated mode) |
node test-cli.js 10 20 |
Run tasks 10-20 |
node test-cli.js --interactive |
Run all tests with prompts |
node test-cli.js 10 20 --interactive |
Run tasks 10-20 with prompts |
# Setup
cd /home/tester/npm-practice-source
sudo npm link
# Use
cd /home/tester/test-workspace
npm-practice
# Commands inside npm-practice
hint # Get a hint
show # Show correct answer
skip # Skip current task
ff # Fast-forward to specific task
quit/exit # Exit app| Feature | Mac | Linux (Docker) |
|---|---|---|
| Global installs | No sudo needed | Requires sudo |
| sqlite3 tasks | ✅ Works | ⏭️ Skipped (SSL issues) |
| Test speed | ~162 seconds | ~62 seconds |
| Tasks passed | 89 | 85 |
| Tasks skipped | 18 | 22 |
Problem: Docker image doesn't exist or is outdated.
Solution: Rebuild the image
docker build -f Dockerfile.linux -t npm-practice-linux .Problem: You made code changes but tests still use old code.
Solution: Always rebuild after code changes
docker build -f Dockerfile.linux -t npm-practice-linux .
npm run test-linux-quickProblem: Global npm operations need elevated permissions.
Solution: Use sudo inside container
sudo npm link
sudo npm install -g verdaccioThe test runner automatically adds sudo for tasks marked with requireSudo: true.
Problem: Using docker run without -it flags.
Solution: Always use -it for interactive mode
docker run -it --rm npm-practice-linuxProblem: App not linked globally.
Solution: Run sudo npm link first
cd /home/tester/npm-practice-source
sudo npm link
cd /home/tester/test-workspace
npm-practiceIf you're iterating on a specific task:
# Test just that task instead of all 107
node test-cli.js 42 42Want to run multiple test commands without restarting?
# Start container once
docker run -it --rm npm-practice-linux
# Inside container, run multiple commands
node test-cli.js 1 10
node test-cli.js 20 30
node test-cli.js 50 60
exit # When doneBefore rebuilding, check what changed:
git diff tasks.json
git diff test-cli.js# Test on Mac (native)
npm test
# Test on Linux (Docker)
npm run test-linux-quick
# Compare results- ✅ Test locally on both Mac and Linux
- ✅ Push to GitHub to test on Windows via Actions
- ✅ Check Actions tab for cross-platform results
- ✅ Add status badges to your README (see
.github/BADGES.md)