spectron testing on github actions

added screenshot capture after tests
This commit is contained in:
Labhansh Agrawal 2021-01-13 18:01:18 +05:30 committed by Benjamin Staneck
parent 0d210abdd1
commit e6eed0d4bb
4 changed files with 29 additions and 0 deletions

View file

@ -34,6 +34,13 @@ jobs:
# echo "::set-env name=CSC_KEY_PASSWORD::${{ secrets.MAC_CERT_P12_PASSWORD }}"
- name: Build
run: yarn run dist --publish=never
- name: Test Spectron
run: yarn run test:spectron
- name: Archive Spectron test screenshot
uses: actions/upload-artifact@v2
with:
name: spectron
path: dist/tmp/darwin_test.png
- name: Get macOS Artifact Names
id: getmacosfilename
run: |
@ -135,6 +142,13 @@ jobs:
# env:
#CSC_LINK: ${{ secrets.WIN_CERT_P12_BASE64 }}
#CSC_KEY_PASSWORD: ${{ secrets.WIN_CERT_P12_PASSWORD }}
- name: Test Spectron
run: yarn run test:spectron
- name: Archive Spectron test screenshot
uses: actions/upload-artifact@v2
with:
name: spectron
path: dist/tmp/win32_test.png
- name: Get Windows Artifact Names
id: getwindowsfilename
run: |

9
ava-spectron.config.js Normal file
View file

@ -0,0 +1,9 @@
export default {
files: ['test/*'],
babel: {
compileEnhancements: false,
compileAsTests: ['**/testUtils/**/*']
},
extensions: ['ts'],
require: ['ts-node/register/transpile-only']
};

View file

@ -11,6 +11,7 @@
"test": "yarn run lint && yarn run test:unit",
"test:unit": "ava",
"test:unit:watch": "yarn run test:unit -- --watch",
"test:spectron": "ava --config ava-spectron.config.js",
"postinstall": "webpack --config-name hyper-app && electron-builder install-app-deps && yarn run rebuild-node-pty && cpy --cwd=target --parents \"node_modules/**/*\" \"../app/\"",
"rebuild-node-pty": "electron-rebuild -f -w target/node_modules/node-pty -m target",
"dist": "yarn run build && cross-env BABEL_ENV=production babel target/renderer/bundle.js --out-file target/renderer/bundle.js --no-comments --minified && electron-builder",

View file

@ -1,5 +1,6 @@
// Native
import path from 'path';
import fs from 'fs-extra';
// Packages
import test from 'ava';
@ -35,6 +36,10 @@ test.before(async () => {
});
test.after(async () => {
await new Promise((resolve) => setTimeout(resolve, 5000));
await app.browserWindow.capturePage().then(async (imageBuffer) => {
await fs.writeFile(`dist/tmp/${process.platform}_test.png`, imageBuffer);
});
await app.stop();
});