Skip to content

Commit

Permalink
Merge pull request #1657 from hicom150/update_spectron
Browse files Browse the repository at this point in the history
Fix integration test setup

Co-authored-by: null <23040076+greenkeeper[bot]@users.noreply.github.com>
Co-authored-by: Feross Aboukhadijeh <[email protected]>
  • Loading branch information
feross and greenkeeper[bot] authored Sep 6, 2019
2 parents 6e2ff68 + 280fbc1 commit ac9b79c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"plist": "^3.0.1",
"pngjs": "^3.4.0",
"run-series": "^1.1.8",
"spectron": "^3.3.0",
"spectron": "^8.0.0",
"standard": "*",
"tape": "^4.11.0",
"walk-sync": "^2.0.2"
Expand Down
11 changes: 11 additions & 0 deletions test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ module.exports = {
// Returns a promise that resolves to a Spectron Application once the app has loaded.
// Takes a Tape test. Makes some basic assertions to verify that the app loaded correctly.
function createApp (t) {
const userDataDir = process.platform === 'win32'
? path.join('C:\\Windows\\Temp', 'WebTorrentTest')
: path.join('/tmp', 'WebTorrentTest')

return new Application({
path: path.join(__dirname, '..', 'node_modules', '.bin',
'electron' + (process.platform === 'win32' ? '.cmd' : '')),
args: ['-r', path.join(__dirname, 'mocks.js'), path.join(__dirname, '..')],
chromeDriverArgs: [`--user-data-dir=${userDataDir}`],
env: { NODE_ENV: 'test' },
waitTimeout: 10e3
})
Expand Down Expand Up @@ -78,6 +83,12 @@ function endTest (app, t, err) {
// Otherwise, create the reference screenshot: test/screenshots/<platform>/<name>.png
function screenshotCreateOrCompare (app, t, name) {
const ssDir = path.join(__dirname, 'screenshots', process.platform)

// check that path exists otherwise create it
if (!fs.existsSync(ssDir)) {
fs.mkdirSync(ssDir)
}

const ssPath = path.join(ssDir, name + '.png')
let ssBuf

Expand Down

0 comments on commit ac9b79c

Please sign in to comment.