it-works-on-my-machine
v1.0.0
Published
Test local JS builds against live websites by intercepting and replacing remote files with Playwright
Downloads
14
Maintainers
Readme
it-works-on-my-machine
A CLI tool that lets you test your local JavaScript builds against live websites by intercepting and replacing remote JS files on-the-fly using Playwright.
Why?
Ever had a bug that only appears in production? Or need to test your local changes against a live environment without deploying? This tool intercepts requests to remote JavaScript files and serves your local build instead, letting you debug and test in real-time.
Installation
npm install -g it-works-on-my-machineOr run locally:
npm install
npm linkUsage
it-works-on-my-machine -u <url> -l <local-file> -r <remote-file> [options]Required Options
| Option | Description |
|--------|-------------|
| -u, --url <url> | The URL of the website to test |
| -l, --local <path> | Path to your local JS build file |
| -r, --remote <url> | The URL of the remote JS file to replace |
Optional Flags
| Option | Description | Default |
|--------|-------------|---------|
| --headless | Run browser in headless mode | false |
| -w, --watch | Watch for changes and auto-reload | false |
Examples
Interactive Testing
Test your local bundle against a production site:
it-works-on-my-machine \
-u https://example.com \
-l ./dist/bundle.js \
-r https://example.com/assets/app.jsThis opens a browser window where you can manually test. The browser pauses for inspection using Playwright's debug mode.
Headless Mode (CI/Screenshots)
Run in headless mode for automated testing or screenshots:
it-works-on-my-machine \
-u https://example.com \
-l ./dist/bundle.js \
-r https://example.com/assets/app.js \
--headlessIn headless mode, a screenshot.png is saved to the current directory.
Watch Mode
Auto-reload when your local file changes:
it-works-on-my-machine \
-u https://example.com \
-l ./dist/bundle.js \
-r https://example.com/assets/app.js \
--watchHow It Works
- Launches a Chromium browser via Playwright
- Sets up a route interceptor for the specified remote JS URL
- Navigates to the target URL
- When the page requests the remote JS file, it's replaced with your local build
- In interactive mode, the browser pauses for manual testing
- In headless mode, a screenshot is captured
Dependencies
- Playwright - Browser automation
- Commander - CLI argument parsing
- Chalk - Terminal styling
License
ISC
