-
-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
npm install spectroscope
# Or
yarn add spectroscope
Installing Spectroscope as a dev dependency will cause issues with your final application unless the Spectroscope import is removed during your applications build process.
Add the line require("spectroscope/main");
into your Electron application's main thread. This is the Javascript/Typescript file that is executed by the electron
binary.
Next ensure you have a preload script configured as shown below.
const win = new BrowserWindow({
webPreferences: {
preload: __dirname + "/preload.js", # This line here
},
});
And finally add the line require("spectroscope/preload");
to your preload script.
You have successfully added the Spectroscope runtime to your application. This allows the test suite to correctly communicate with the Electron main thread. If your application was not launched using Spectroscope, the runtime code will disable itself so it does not pose a security risk.
Now you can write tests for your application!
An example of how to do this using Jest can be found here. Jest is shown here but any testing framework, or regular Javascript/Typescript program would work.