Implementation:Getgauge Taiko Install Chromium
| Knowledge Sources | |
|---|---|
| Domains | Browser_Automation, Testing |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Concrete tool for the post-install Chromium download system provided by the Taiko library.
Description
The Install Chromium module is responsible for automatically downloading the correct Chromium browser binary as a post-install step during npm install taiko. It acts as the entry point that orchestrates the browser acquisition process, delegating the actual download and extraction work to the BrowserFetcher class.
The main() function in lib/install.js performs a series of guard checks before initiating the download. It first inspects the TAIKO_SKIP_CHROMIUM_DOWNLOAD environment variable and the npm config equivalent (NPM_CONFIG_TAIKO_SKIP_CHROMIUM_DOWNLOAD) to determine if the user has explicitly opted out of the download. It then checks whether the target revision is already present locally, avoiding redundant downloads. Only when all checks pass does it invoke BrowserFetcher.download().
The BrowserFetcher class (defined in lib/browser/fetcher.js) handles the low-level mechanics of downloading and extracting the Chromium archive. It constructs a platform-specific download URL via BrowserMetadata, downloads the zip archive over HTTP/HTTPS with optional proxy support, extracts it using extract-zip, sets executable permissions, and cleans up the temporary zip file. After a successful download, the install script removes any previously downloaded Chromium revisions to conserve disk space.
A progress bar is displayed during download using the progress npm package, providing real-time feedback on download progress including file size, percentage, and estimated time remaining.
Usage
This module is invoked automatically during npm install taiko as a post-install script defined in package.json. It is not intended to be called directly by users. However, its behavior can be controlled through environment variables:
- Set
TAIKO_SKIP_CHROMIUM_DOWNLOAD=trueto skip the download entirely (useful in CI environments where Chromium is pre-installed). - Set
TAIKO_BROWSER_PATHto point to a custom browser binary, making the bundled download unnecessary. - Set proxy environment variables (
HTTP_PROXY,HTTPS_PROXY) for downloading behind corporate firewalls.
Code Reference
Source Location
- Repository: Taiko
- File (entry point):
lib/install.js - Lines: L81-111 (main function), L33-43 (onSuccess), L48-54 (onError), L56-74 (onProgress)
- File (fetcher):
lib/browser/fetcher.js - Lines: L45-131 (BrowserFetcher class), L141-181 (downloadFile), L188-192 (extractZip), L194-219 (httpRequest)
Signature
// lib/install.js - Entry point
function main() -> void
// lib/browser/fetcher.js - BrowserFetcher class
class BrowserFetcher {
constructor(options?: { path?: string, platform?: string })
async download(revision: string, progressCallback?: (downloadedBytes: number, totalBytes: number) => void) -> Promise<RevisionInfo>
async remove(revision: string) -> Promise<void>
canDownload() -> Promise<boolean>
localRevisions() -> Promise<string[]>
}
Import
// Called automatically as npm post-install script
// Not intended for direct import
// Internal usage within the codebase:
const BrowserFetcher = require('./browser/fetcher');
const BrowserMetadata = require('./browser/metadata');
const browser = require('../package.json').taiko.browser;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| TAIKO_SKIP_CHROMIUM_DOWNLOAD | env var (string) | No | Set to any truthy value (except "false") to skip the Chromium download entirely |
| NPM_CONFIG_TAIKO_SKIP_CHROMIUM_DOWNLOAD | env var (string) | No | npm config alternative to skip the Chromium download |
| TAIKO_BROWSER_PATH | env var (string) | No | Path to a custom browser binary; when set, the bundled download is unnecessary |
| revision | string (from package.json) | Yes (internal) | Chromium revision number read from package.json taiko.browser field
|
| progressCallback | function(number, number) | No | Callback invoked with (downloadedBytes, totalBytes) during download |
Outputs
| Name | Type | Description |
|---|---|---|
| Chromium binary | File on disk | Extracted Chromium binary placed in node_modules/taiko/.local-chromium/{platform}-{revision}/
|
| Console output | string | Status messages printed to stdout indicating download progress or skip reasons |
| Process exit | number | Exits with code 1 on download failure |
Dependencies
| Dependency | Purpose |
|---|---|
| progress | Renders a progress bar in the terminal during download |
| extract-zip | Extracts the downloaded Chromium zip archive |
| fs-extra | File system operations (mkdir, unlink, chmod, removeSync) |
| https-proxy-agent | Proxy support for HTTP/HTTPS requests |
| proxy-from-env | Resolves proxy URL from environment variables |
| https / http | Node.js built-in modules for making HTTP requests |
Usage Examples
Standard Installation
# Chromium is downloaded automatically during installation
npm install taiko
# Output: Downloading Chromium r123456 - 120.5 Mb [====================] 100% 0.0s
# Output: Chromium downloaded to /path/to/node_modules/taiko/.local-chromium/linux-123456
Skip Download via Environment Variable
# Skip Chromium download when a system browser is available
TAIKO_SKIP_CHROMIUM_DOWNLOAD=true npm install taiko
# Output: Skipping Chromium Download as given in environment variable.
Skip Download via npm Config
# Skip via npm config (useful in .npmrc files)
npm config set taiko_skip_chromium_download true
npm install taiko
# Output: Skipping Chromium Download as given in npm config.
Use Custom Browser Path
# Point Taiko to a pre-installed Chromium/Chrome binary
TAIKO_BROWSER_PATH=/usr/bin/chromium-browser npm install taiko
Behind a Corporate Proxy
# Download through a proxy server
HTTPS_PROXY=http://proxy.example.com:8080 npm install taiko