Did you import the service hook scripts into your application via e.g. import('wdio-electron-service/main')
and import('wdio-electron-service/preload')
?
#11986
Unanswered
aaronculp-droneup
asked this question in
Q&A
Replies: 1 comment 7 replies
-
Make sure you compile your Electron application with the right |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having this error when running "npm run wdio" --
javascript error: javascript error: Electron context bridge not available! Did you import the service hook scripts into your application via e.g.
import('wdio-electron-service/main')
andimport('wdio-electron-service/preload')
?package.json
{ "name": "dbx-ui", "productName": "DBX UI Platform", "version": "1.0.0", "description": "DBX UI Built with Electron / React / Vite", "main": "./dist/main/index.js", "author": "example.com", "homepage": "https://www.electronjs.org", "scripts": { "format": "prettier --write .", "lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix", "start": "electron-forge start", "dev": "electron-vite dev --outDir=dist", "package": "electron-vite build --outDir=dist && NODE_ENV=test electron-forge package", "make": "electron-vite build --outDir=dist && electron-forge make", "build": "electron-vite build --outDir=dist", "wdio": "NODE_ENV=test wdio run wdio.conf.js --watch" }, "dependencies": { "@electron-toolkit/preload": "^2.0.0", "@electron-toolkit/utils": "^2.0.0", "axios": "^1.6.2", "electron-squirrel-startup": "^1.0.0", "express": "^4.18.2", "framer-motion": "^10.16.16", "react-router-dom": "^6.21.1", "styled-components": "^6.1.3", "wdio-electron-service": "^6.0.2" }, "devDependencies": { "@electron-forge/cli": "^7.2.0", "@electron-forge/maker-deb": "^7.2.0", "@electron-forge/maker-rpm": "^7.2.0", "@electron-forge/maker-squirrel": "^7.2.0", "@electron-forge/maker-zip": "^7.2.0", "@electron-forge/plugin-auto-unpack-natives": "^7.2.0", "@electron-toolkit/eslint-config": "^1.0.1", "@electron-toolkit/eslint-config-prettier": "^1.0.1", "@vitejs/plugin-react": "^4.0.4", "@wdio/cli": "^8.27.1", "@wdio/cucumber-framework": "^8.27.1", "@wdio/local-runner": "^8.27.0", "@wdio/mocha-framework": "^8.27.0", "@wdio/spec-reporter": "^8.27.0", "electron": "^28.1.1", "electron-chromedriver": "^28.1.2", "electron-vite": "^1.0.27", "eslint": "^8.47.0", "eslint-plugin-react": "^7.33.2", "prettier": "^3.0.2", "react": "^18.2.0", "react-dom": "^18.2.0", "vite": "^4.4.9" } }
test/specs/test.e2e.js
`
describe('Electron Testing', () => {
it('should print application title', async () => {
const logs = await browser.electron.execute(
(electron) => electron.app.getPath({ sessionData }),
);
})
`
I've also added inside main / preload as well...
`const isTest = process.env.NODE_ENV === 'test';
if (isTest) require('wdio-electron-service/preload')`
Looking to understand this issue and what needs to change for this to be solved! When I comment out
`
const logs = await browser.electron.execute(
(electron) => electron.app.getPath({ sessionData }),
);
`
from my test file it works... I'm new to testing but I'm trying to achieve getting the sessionData from electron.app.getPath.. I'm actually trying to set a variable to localStorage so my app will run ...
window.localStorage.setItem('internetConnection', true)
App is hidden by this variable inside app.js.. making a variable to ensure we are connected to the internet, if not I show a
trying to reconnect..
So trying to replicate a localStorage variable in my test so I can get into the app... Plz help! <3
Beta Was this translation helpful? Give feedback.
All reactions