
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
screenkitten
Advanced tools
A cross-platform Node.js library for taking screenshots on iOS simulators and Android devices/emulators
A cross-platform Node.js library for taking screenshots on iOS simulators and Android devices/emulators.
xcrun simctladbnpm install screenkitten
import { screenkitten } from 'screenkitten';
const ios = screenkitten({
platform: 'ios',
deviceId: 'booted', // Default: 'booted'
type: 'png', // Default: 'png'
outputPath: '/path/to/screenshot.png' // Optional: auto-generated if not provided
});
const screenshotPath = await ios.takeScreenshot();
console.log(`Screenshot saved to: ${screenshotPath}`);
import { screenkitten } from 'screenkitten';
const android = screenkitten({
platform: 'android',
deviceId: 'emulator-5554', // Optional: uses 'booted' by default
outputPath: '/path/to/screenshot.png' // Optional: auto-generated if not provided
});
const screenshotPath = await android.takeScreenshot();
console.log(`Screenshot saved to: ${screenshotPath}`);
screenkitten(options: ScreenkittenOptions)Creates a platform-specific screenshot instance.
Parameters:
options - Configuration object (see platform-specific options below)Returns: ScreenkittenIOS or ScreenkittenAndroid instance
interface ScreenkittenOptionsIOS {
platform: 'ios';
deviceId?: string; // Default: 'booted'
xcrunPath?: string; // Default: '/usr/bin/xcrun'
type?: 'png' | 'jpeg'; // Default: 'png'
display?: 'internal' | 'external'; // Default: 'internal'
mask?: 'ignored' | 'alpha' | 'black'; // Default: 'ignored'
outputPath?: string; // Auto-generated if not provided
abortSignal?: AbortSignal;
onError?: OnErrorHandler;
}
interface ScreenkittenOptionsAndroid {
platform: 'android';
deviceId?: string; // Default: 'booted'
adbPath?: string; // Default: 'adb'
outputPath?: string; // Auto-generated if not provided
abortSignal?: AbortSignal;
onError?: OnErrorHandler;
}
You can control error behavior using the onError option:
type OnErrorHandler = 'throw' | 'ignore' | ((error: Error) => void);
Options:
'throw' (default) - Throws the error'ignore' - Suppresses the error and returns the output pathfunction - Custom error handler function// Custom error handling
const ios = screenkitten({
platform: 'ios',
onError: (error) => {
console.error('Screenshot failed:', error.message);
// Custom logging, reporting, etc.
}
});
takeScreenshot(options?: Partial<ScreenkittenOptionsBase>): Promise<string>Takes a screenshot and returns the path to the saved file.
Parameters:
options - Optional override options for this specific screenshotReturns: Promise that resolves to the screenshot file path
Example:
// Use instance defaults
const path1 = await ios.takeScreenshot();
// Override specific options for this screenshot
const path2 = await ios.takeScreenshot({
outputPath: '/custom/path.png',
deviceId: 'specific-device'
});
Cancel screenshot operations gracefully:
const controller = new AbortController();
const ios = screenkitten({
platform: 'ios',
abortSignal: controller.signal
});
// Cancel after 5 seconds
setTimeout(() => controller.abort(), 5000);
try {
const path = await ios.takeScreenshot();
console.log('Screenshot saved:', path);
} catch (error) {
if (error.name === 'ScreenkittenOperationAbortedError') {
console.log('Screenshot was cancelled');
}
}
Screenkitten provides specific error types for different failure scenarios:
import {
ScreenkittenError, // Base error class
ScreenkittenDeviceNotFoundError, // Device/simulator not found
ScreenkittenXcrunNotFoundError, // xcrun tool not found (iOS)
ScreenkittenAdbNotFoundError, // adb tool not found (Android)
ScreenkittenIOSSimulatorError, // iOS simulator not available
ScreenkittenAndroidDeviceError, // Android device not available
ScreenkittenFileWriteError, // Failed to write screenshot file
ScreenkittenOperationAbortedError, // Operation was aborted
ScreenkittenScreenshotFailedError, // Generic screenshot failure
ScreenkittenInvalidTypeError // Invalid screenshot type (iOS)
} from 'screenkitten';
All errors extend the base ScreenkittenError class, which extends the standard Error class.
xcrun tool (usually available at /usr/bin/xcrun)adb toolScreenkitten supports both ES modules and CommonJS:
// ES modules
import { screenkitten } from 'screenkitten';
// CommonJS
const { screenkitten } = require('screenkitten');
MIT
Contributions are welcome! Please read our Contributing Guide and Code of Conduct.
FAQs
A cross-platform Node.js library for taking screenshots on iOS simulators and Android devices/emulators
We found that screenkitten demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.