Gathering detailed insights and metrics for @goosewobbler/spectron
Gathering detailed insights and metrics for @goosewobbler/spectron
Gathering detailed insights and metrics for @goosewobbler/spectron
Gathering detailed insights and metrics for @goosewobbler/spectron
🔎 Test Electron apps using WebdriverIO and Chromedriver
npm install @goosewobbler/spectron
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (71.86%)
JavaScript (23.98%)
HTML (4.16%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
4 Stars
1,179 Commits
26 Branches
1 Contributors
Updated on Apr 23, 2022
Latest Version
17.0.0-beta2
Package Id
@goosewobbler/spectron@17.0.0-beta2
Unpacked Size
43.09 kB
Size
10.97 kB
File Count
20
NPM Version
8.1.2
Node Version
16.13.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
5
Easily test your Electron apps using WebdriverIO and Chromedriver.
wdio-electron-service
has now been released enabling Electron apps to be tested natively in WebdriverIO. I updated this fork to use the new service but this change effectively makes Spectron mostly, if not entirely redundant. Some of the Electron APIs / browser helper functions here may be ported to the new service if/as required, but this fork of Spectron will no longer be updated.
Please try out the new service if you are interested in using modern WebdriverIO and its extensive ecosystem for E2E testing Electron apps. It should be a more than adequate replacement for Spectron, but if anything critical is missing for your use case please let us know.
WebdriverIO
Playwright (currently experimental Electron support)
Puppeteer-in-electron
This fork of Spectron exists to fulfil a simple requirement - bring Spectron in line with modern versions of Electron & WebdriverIO, by any means necessary. The code has been completely rewritten in Typescript with modern dependencies and a much greater WebdriverIO integration.
Install Spectron using your favourite package manager. You will also need to install WebdriverIO and a framework dependency for whichever framework you want to use, for instance Mocha:
1npm install --save-dev @goosewobbler/spectron webdriverio @wdio/mocha-framework 2 3yarn add -D @goosewobbler/spectron webdriverio @wdio/mocha-framework 4 5pnpm i -D @goosewobbler/spectron webdriverio @wdio/mocha-framework
In your main process root (index) file, add the following import:
1import '@goosewobbler/spectron/main';
In your preload file, add the following import:
1import '@goosewobbler/spectron/preload';
Add a spec file - the following is a basic example in TypeScript using Mocha and Testing Library:
1import { initSpectron, SpectronApp } from '@goosewobbler/spectron'; 2import { setupBrowser, WebdriverIOQueries } from '@testing-library/webdriverio'; 3 4let app: SpectronApp; 5let screen: WebdriverIOQueries; 6 7describe('App', () => { 8 before(async (): Promise<void> => { 9 app = await initSpectron(); 10 await app.client.waitUntilWindowLoaded(); 11 screen = setupBrowser(app.client); 12 }); 13 14 it('should launch the app', async () => { 15 const isVisible = await app.browserWindow.isVisible(); 16 expect(isVisible).toBe(true); 17 }); 18 19 it('should display a button', async () => { 20 const button = await screen.getByText('This is a button'); 21 expect(button).toBeDefined(); 22 }); 23});
Running tests with Spectron depends on your app binary so you will need to ensure it is built before the tests are executed.
Next you will need some configuration. Spectron uses the exact same format as the WebdriverIO configuration file for their TestRunner, the only difference is that you won't need to configure Chromedriver in services
or anything in the capabilities
section as these are handled by Spectron. Here is a sample configuration:
1const { join } = require('path'); 2const fs = require('fs-extra'); 3 4const packageJson = JSON.parse(fs.readFileSync('./package.json')); 5const { 6 build: { productName }, 7} = packageJson; 8 9const config = { 10 spectronOpts: { 11 appPath: join(process.cwd(), 'dist'), 12 appName: productName, 13 }, 14 port: 9515, 15 waitforTimeout: 5000, 16 connectionRetryCount: 10, 17 connectionRetryTimeout: 30000, 18 logLevel: 'debug', 19 runner: 'local', 20 outputDir: 'wdio-logs', 21 specs: ['./test/e2e/*.spec.ts'], 22 autoCompileOpts: { 23 autoCompile: true, 24 tsNodeOpts: { 25 transpileOnly: true, 26 files: true, 27 project: './tsconfig.json', 28 }, 29 tsConfigPathsOpts: { 30 baseUrl: './', 31 }, 32 }, 33 framework: 'mocha', 34}; 35 36module.exports = { config };
Finally, you can execute your tests by pointing Spectron at your configuration file:
1npx spectron ./spectron.conf.js 2 3yarn spectron ./spectron.conf.js 4 5pnpx spectron ./spectron.conf.js
API details can be found here.
The architecture of Spectron is documented here.
Chromedriver is not currently restarted in between tests; this is a consequence of using the wdio-chromedriver-service
. Separate worker processes are spawned by WDIO for each spec file, but within a given spec file, test state is likely to bleed into subsequent tests. See the migration doc for more details.
Not all Electron APIs are currently supported.
Some old functionality provided by the Electron remote
API (now found here) is not yet fully replicated.
Some Electron API functions may not work due to serialisation errors; this is a consequence of the new way of accessing electron methods from renderer processes, this is by design and can be worked around.
Logging all tasks for development here.
Rewrite Discussion here.
Details of how to configure Spectron can be found here.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/8 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
37 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More