This document explains the cross-platform testing strategy for create-react-forge to ensure consistent user experience across Windows, macOS, and Linux.
The project includes comprehensive cross-platform testing to catch OS-specific issues early and ensure reliability across different environments.
Tests platform-specific behaviors:
- Path Handling: Tests path separators (
/vs\) on Windows vs Unix - Case Sensitivity: Verifies file system case sensitivity (case-insensitive on Windows/macOS, case-sensitive on Linux)
- Line Endings: Tests consistent handling of
LFvsCRLF - Special Characters: Tests directory names with hyphens, underscores, camelCase
- Permissions: Tests executable file permissions on Unix systems
- Package Manager Detection: Verifies correct detection of
npm,yarn,pnpmon each platform
Tests actual CLI command execution:
- Version & Help: Ensures
--versionand--helpflags work - Exit Codes: Verifies proper exit codes (0 for success, non-zero for errors)
- Output Consistency: Ensures output is consistent across multiple runs
- Concurrent Execution: Tests CLI behavior under concurrent invocations
- Environment Variables: Tests behavior with different env vars
- Error Handling: Tests graceful error handling for invalid inputs
npm testnpm test -- cross-platform-cli.test.tsnpm test -- e2e-cli.test.tsnpm run test:watchnpm run test:coverageThe project uses GitHub Actions for automated cross-platform testing:
Workflow: .github/workflows/cross-platform-tests.yml
- Operating Systems: Ubuntu Latest, Windows Latest, macOS Latest
- Node Versions: Node 20.x, Node 22.x
- Total Combinations: 6 OS/Node combinations
- test: Runs unit, integration, and platform-specific tests
- e2e-scaffold-test: Tests the actual scaffolding command
- lint: Runs linter and format checks
- build-artifacts: Verifies build output
- ✅ Installation of dependencies
- ✅ Project builds successfully
- ✅ All tests pass
- ✅ Linter rules pass
- ✅ CLI can be invoked
- ✅ TypeScript definitions are generated
// Path separator
sep === '\\';
// Case-insensitive file system
file.txt === FILE.TXT; // true
// CRLF line endings
lineEnding === '\r\n';// Path separator
sep === '/';
// Case-insensitive file system (by default)
file.txt === FILE.TXT; // true
// LF line endings
lineEnding === '\n';// Path separator
sep === '/';
// Case-sensitive file system
file.txt === FILE.TXT; // false
// LF line endings
lineEnding === '\n';Important: The @inquirer/core peer dependency is now explicitly listed in package.json to ensure proper resolution across all platforms. This fixes the module resolution error that occurred on some systems.
- Check for path separator issues (
/vs\) - Verify case sensitivity handling
- Check for line ending differences
- Check for code signing issues
- Verify file permission handling
- Check for environment variable differences
- Check for case sensitivity in file names
- Verify file permissions
- Check for path length issues
If you see errors like Cannot find package '@inquirer/core':
- Run
npm installto reinstall dependencies - Clear npm cache:
npm cache clean --force - Delete node_modules and package-lock.json, then reinstall
When adding new features, ensure cross-platform compatibility:
import os from 'node:os';
import { sep } from 'node:path';
describe('Feature', () => {
it('should work on all platforms', () => {
if (os.platform() === 'win32') {
// Windows-specific test
} else {
// Unix-specific test
}
});
it('should handle path separators correctly', () => {
const path = `src${sep}components`;
// Use sep instead of hardcoding / or \
});
});The testing infrastructure allows:
- ✅ Early detection of platform-specific bugs
- ✅ Validation of fixes across all platforms
- ✅ Prevention of regressions
- ✅ Confidence in releases
- ARCHITECTURE.md - Project architecture
- CODE_QUALITY.md - Code quality standards
- RELEASE_GUIDE.md - Release process