electron-playwright-helpers
Version:
Helper functions for Electron end-to-end testing using Playwright
90 lines • 3.55 kB
TypeScript
/**
* Parses the `out` directory to find the latest build of your Electron project.
* Use `npm run package` (or similar) to build your app prior to testing.
*
* Assumptions: We assume that your build will be in the `out` directory, and that
* the build directory will be named with a hyphen-delimited platform name, e.g.
* `out/my-app-win-x64`. If your build directory is not `out`, you can
* pass the name of the directory as the `buildDirectory` parameter. If your
* build directory is not named with a hyphen-delimited platform name, this
* function will not work. However, you can pass the build path into
* `parseElectronApp()` directly.
*
* @see parseElectronApp
*
* @param buildDirectory {string} - optional - the directory to search for the latest build
* (path/name relative to package root or full path starting with /). Defaults to `out`.
* @returns {string} - path to the most recently modified build directory
*/
export declare function findLatestBuild(buildDirectory?: string): string;
type Architecture = 'x64' | 'x32' | 'arm64' | 'universal' | undefined;
export interface PackageJson {
[key: string]: unknown;
name: string;
productName?: string;
main: string;
version: string;
description?: string;
author?: string | {
name: string;
email: string;
};
license?: string;
repository?: string;
homepage?: string;
bugs?: string | {
url: string;
};
}
/**
* Format of the data returned from `parseElectronApp()`
* @typedef ElectronAppInfo
* @prop {string} executable - path to the Electron executable
* @prop {string} main - path to the main (JS) file
* @prop {string} name - name of the your application
* @prop {string} resourcesDir - path to the resources directory
* @prop {boolean} asar - whether the app is packaged as an asar archive
* @prop {string} platform - 'darwin', 'linux', or 'win32'
* @prop {string} arch - 'x64', 'x32', or 'arm64'
* @prop {PackageJson} packageJson - the `JSON.parse()`'d contents of the package.json file.
*/
export interface ElectronAppInfo {
/** Path to the app's executable file */
executable: string;
/** Path to the app's main (JS) file */
main: string;
/** Name of the app */
name: string;
/** Resources directory */
resourcesDir: string;
/** True if the app is using asar */
asar: boolean;
/** OS platform */
platform: 'darwin' | 'win32' | 'linux';
/** Architecture */
arch: Architecture;
/** The JSON.parse()'d contents of the package.json file. */
packageJson: PackageJson;
}
/**
* Given a directory containing an Electron app build,
* or the path to the app itself (directory on Mac, executable on Windows),
* return a bunch of metadata, including the path to the app's executable
* and the path to the app's main file.
*
* Format of the data returned is an object with the following properties:
* - executable: path to the app's executable file
* - main: path to the app's main (JS) file
* - name: name of the app
* - resourcesDir: path to the app's resources directory
* - asar: true if the app is using asar
* - platform: OS platform
* - arch: architecture
* - packageJson: the JSON.parse()'d contents of the package.json file.
*
* @param buildDir {string} - absolute path to the build directory or the app itself
* @returns {ElectronAppInfo} metadata about the app
*/
export declare function parseElectronApp(buildDir: string): ElectronAppInfo;
export {};
//# sourceMappingURL=find_parse_builds.d.ts.map