Skip to content

Commit 16471a6

Browse files
authored
chore: automated electron tests (#1883)
* feat: first draft of working electron connection test * feat: add workflow for electron tests * chore: cleanup some default electron packages * fix(workflow): fix xvfb run for test * chore: correction workflow branches * feat: add tests to check isBrowser and protocol used * chore: exclude electron-test from eslint
1 parent dda9ce1 commit 16471a6

14 files changed

+11065
-0
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/doc/
44
/dist/
55
/build/
6+
/electron-test/
67

78
*.js
89
*.mjs

.github/workflows/electron-tests.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Electron Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
browser:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: [20.x]
16+
fail-fast: false
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install Dependencies
27+
run: npm ci
28+
29+
- name: Build MQTT.JS
30+
run: npm run build
31+
32+
- name: Run headless test
33+
run: cd electron-test && npm i && xvfb-run npm run wdio

electron-test/.gitignore

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
.DS_Store
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# TypeScript cache
43+
*.tsbuildinfo
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
.env.test
63+
64+
# parcel-bundler cache (https://parceljs.org/)
65+
.cache
66+
67+
# next.js build output
68+
.next
69+
70+
# nuxt.js build output
71+
.nuxt
72+
73+
# vuepress build output
74+
.vuepress/dist
75+
76+
# Serverless directories
77+
.serverless/
78+
79+
# FuseBox cache
80+
.fusebox/
81+
82+
# DynamoDB Local files
83+
.dynamodb/
84+
85+
# Webpack
86+
.webpack/
87+
88+
# Vite
89+
.vite/
90+
91+
# Electron-Forge
92+
out/

electron-test/README

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```
2+
npm i
3+
npm run wdio
4+
```

electron-test/forge.config.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
2+
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
3+
4+
module.exports = {
5+
packagerConfig: {
6+
asar: true,
7+
},
8+
rebuildConfig: {},
9+
makers: [
10+
{
11+
name: '@electron-forge/maker-zip',
12+
platforms: ['linux'],
13+
},
14+
],
15+
plugins: [
16+
{
17+
name: '@electron-forge/plugin-auto-unpack-natives',
18+
config: {},
19+
},
20+
// Fuses are used to enable/disable various Electron functionality
21+
// at package time, before code signing the application
22+
new FusesPlugin({
23+
version: FuseVersion.V1,
24+
[FuseV1Options.RunAsNode]: false,
25+
[FuseV1Options.EnableCookieEncryption]: true,
26+
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
27+
[FuseV1Options.EnableNodeCliInspectArguments]: false,
28+
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
29+
[FuseV1Options.OnlyLoadAppFromAsar]: true,
30+
}),
31+
],
32+
};

0 commit comments

Comments
 (0)