Fix integration test setup

This commit is contained in:
hicom150
2019-08-18 16:35:54 +02:00
parent 48340010b1
commit 619e5249ac
2 changed files with 17 additions and 6 deletions

View File

@@ -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
})
@@ -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