Skip to content

Commit

Permalink
chore: automated electron tests (#1883)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
axi92 authored Jun 19, 2024
1 parent dda9ce1 commit 16471a6
Show file tree
Hide file tree
Showing 14 changed files with 11,065 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/doc/
/dist/
/build/
/electron-test/

*.js
*.mjs
33 changes: 33 additions & 0 deletions .github/workflows/electron-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Electron Tests

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
browser:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
fail-fast: false

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Build MQTT.JS
run: npm run build

- name: Run headless test
run: cd electron-test && npm i && xvfb-run npm run wdio
92 changes: 92 additions & 0 deletions electron-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock
.DS_Store

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Webpack
.webpack/

# Vite
.vite/

# Electron-Forge
out/
4 changes: 4 additions & 0 deletions electron-test/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```
npm i
npm run wdio
```
32 changes: 32 additions & 0 deletions electron-test/forge.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');

module.exports = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-zip',
platforms: ['linux'],
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
Loading

0 comments on commit 16471a6

Please sign in to comment.