Skip to content

Commit

Permalink
Migrate clicktests from nightmare to puppeteer (#1336)
Browse files Browse the repository at this point in the history
* puppeteer

* reduce test flakiness

* puppeteer does not require xvfb?!

* reduce test flakiness

* don't query same element twice

* try out 1920 x 1080

* rename nmclicktest -> clicktest

* add clicktest npm script

* move headless to enviroment config

* reduce test flakiness by waiting for the correct element

* use different commit name for commit & push with ff

* log selector when click fails

* retry click a second time

* remove old gitignore entries

* update puppeteer to 3.0.3

* changelog
  • Loading branch information
campersau committed May 6, 2020
1 parent 7b40061 commit f866756
Show file tree
Hide file tree
Showing 40 changed files with 1,480 additions and 1,726 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -11,8 +11,6 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
# Xvfb (nightmare on linux)
DISPLAY: ':99.0'
# electron packager (win32 ia32 on macos) https://github.com/electron/electron-packager/pull/449#issuecomment-240508298
WINEDLLOVERRIDES: 'mscoree,mshtml='

Expand All @@ -25,10 +23,10 @@ jobs:
node-version: ${{ matrix.node-version }}

# linux dependencies
- run: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
if: matrix.os == 'ubuntu-latest'
- run: sudo apt update
if: matrix.os == 'ubuntu-latest'
- run: sudo apt install -y libgbm1
if: matrix.os == 'ubuntu-latest'
- run: sudo apt install -y wine64
if: matrix.os == 'ubuntu-latest'
- run: wine --version
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Expand Up @@ -24,11 +24,7 @@ report/

/node_modules/

/clicktests/screenshots/
/build
/*.dll
/nw.exe
/nw.pak

/components/**/*.css
/components/**/*.bundle.js
Expand Down
1 change: 0 additions & 1 deletion .npmignore
Expand Up @@ -32,7 +32,6 @@ public/devStyling.html
public/js/devStyling.js

clicktests/
nmclicktests/

teststabilitytester.js

Expand Down
7 changes: 2 additions & 5 deletions .travis.yml
Expand Up @@ -26,8 +26,7 @@ jobs:
addons:
apt:
packages:
- xvfb
- libgconf-2-4
- libgbm1
- wine
homebrew:
update: true
Expand All @@ -36,8 +35,6 @@ addons:
- wine-stable
before_install:
# linux
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then export DISPLAY=':99.0'; fi
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & fi
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then wine --version; fi
- if [[ $TRAVIS_OS_NAME = "linux" && $GIT_VERSION = "edge" ]]; then sudo add-apt-repository ppa:git-core/ppa -y && sudo apt-get update -q && sudo apt-get install -y git; fi
# osx
Expand All @@ -55,7 +52,7 @@ before_script:
- git config --global user.email "test@testy.com"
- git config --global user.name "Test testy"
- git --version
- DISPLAY= npm run package
- npm run package
after_success:
- npm run travisnpmpublish
before_deploy:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,9 @@ We are following the [Keep a Changelog](https://keepachangelog.com/) format.

## [Unreleased](https://github.com/FredrikNoren/ungit/compare/v1.5.7...master)

### Changed
- Migrate clicktests from nightmare to puppeteer [#1336](https://github.com/FredrikNoren/ungit/pull/1336)

## [1.5.7](https://github.com/FredrikNoren/ungit/compare/v1.5.6...v1.5.7)

### Fixed
Expand Down
13 changes: 7 additions & 6 deletions Gruntfile.js
Expand Up @@ -69,18 +69,18 @@ module.exports = (grunt) => {
options: {
reporter: 'spec',
require: './source/utils/winston.js',
timeout: 15000,
timeout: 35000,
bail: true
},
src: 'nmclicktests/spec.*.js'
src: 'clicktests/spec.*.js'
}
},

jshint: {
options: {
undef: true, // check for usage of undefined constiables
indent: 2,
esnext: true,
esversion: 6,
'-W033': true, // ignore Missing semicolon
'-W041': true, // ignore Use '===' to compare with '0'
'-W065': true, // ignore Missing radix parameter
Expand Down Expand Up @@ -124,6 +124,7 @@ module.exports = (grunt) => {
},
mocha: {
options: {
esversion: 8,
node: true,
globals: {
'it': true,
Expand All @@ -138,7 +139,7 @@ module.exports = (grunt) => {
},
src: [
'test/**/*.js',
'nmclicktests/**/*.js'
'clicktests/**/*.js'
]
}
},
Expand Down Expand Up @@ -305,7 +306,7 @@ module.exports = (grunt) => {
grunt.registerTask('clickParallel', 'Parallelized click tests.', function() {
const done = this.async();

fs.readdirAsync('./nmclicktests')
fs.readdirAsync('./clicktests')
.then((files) => files.filter((file) => file.startsWith('spec.')))
.then((tests) => {
const genericIndx = tests.indexOf('spec.generic.js');
Expand All @@ -321,7 +322,7 @@ module.exports = (grunt) => {

grunt.log.writeln(cliColor.set(`Clicktest started! \t${file}`, 'blue'));
return new Bluebird((resolve, reject) => {
const child = childProcess.execFile('./node_modules/mocha/bin/mocha', [path.join(__dirname, 'nmclicktests', file), '--timeout=20000', '-b'], { maxBuffer: 10*1024*1024 });
const child = childProcess.execFile('./node_modules/mocha/bin/mocha', [path.join(__dirname, 'clicktests', file), '--timeout=35000', '-b'], { maxBuffer: 10*1024*1024 });
child.stdout.on('data', outStream);
child.stderr.on('data', outStream);
child.on('exit', (code) => {
Expand Down

0 comments on commit f866756

Please sign in to comment.