headless-electron
v0.7.0
Published
Manage a headless instance of Electron to run logic in tests and on the server
Downloads
12,305
Readme
headless-electron
Run scripts from node in an Electron pool
Usage
const ep = new ElectronProcess();
const result = await ep.runScript({
pathname: path.resolve(__dirname, "typescript.ts"),
functionName: "multiply",
args: [2, 3],
});
await ep.kill();
API
interface ElectronProcess {
constructor(options: {
debugMode: boolean; // true will show the Electron BrowserWindow for debugging purposes
concurrency: number; // maximum number of Electron BrowserWindows to create for parallel runs
});
runScript(options: {
pathname: string; // full path to script to require
functionName?: string; // function name to call, defaults to 'default'
args?: any[]; // arguments passed to function
}): Promise<any>; // returns what the function returns
}
Acknowledgements
Based on jest-electron
License
MIT