fix: we can not use ts-node apaprently
This commit is contained in:
parent
46e5767527
commit
be60f93bd0
2 changed files with 43 additions and 4 deletions
|
@ -98,7 +98,7 @@ async function runElectronTests () {
|
||||||
|
|
||||||
async function runRemoteBasedElectronTests () {
|
async function runRemoteBasedElectronTests () {
|
||||||
let exe = path.resolve(BASE, utils.getElectronExec())
|
let exe = path.resolve(BASE, utils.getElectronExec())
|
||||||
const runnerArgs = ['electron/spec', ...args._]
|
const runnerArgs = ['electron/spec', ...args._.slice(2)]
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
runnerArgs.unshift(path.resolve(__dirname, 'dbus_mock.py'), exe)
|
runnerArgs.unshift(path.resolve(__dirname, 'dbus_mock.py'), exe)
|
||||||
exe = 'python'
|
exe = 'python'
|
||||||
|
@ -116,7 +116,7 @@ async function runRemoteBasedElectronTests () {
|
||||||
async function runMainProcessElectronTests () {
|
async function runMainProcessElectronTests () {
|
||||||
const exe = path.resolve(BASE, utils.getElectronExec())
|
const exe = path.resolve(BASE, utils.getElectronExec())
|
||||||
|
|
||||||
const { status } = childProcess.spawnSync(exe, ['electron/spec-main', ...args._], {
|
const { status } = childProcess.spawnSync(exe, ['electron/spec-main', ...args._.slice(2)], {
|
||||||
cwd: path.resolve(__dirname, '../..'),
|
cwd: path.resolve(__dirname, '../..'),
|
||||||
stdio: 'inherit'
|
stdio: 'inherit'
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,42 @@
|
||||||
require('ts-node/register')
|
/**
|
||||||
|
* @fileoverview A set of helper functions to make it easier to work
|
||||||
|
* with events in async/await manner.
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = require('../spec-main/window-helpers')
|
/**
|
||||||
|
* @param {!EventTarget} target
|
||||||
|
* @param {string} eventName
|
||||||
|
* @return {!Promise<!Event>}
|
||||||
|
*/
|
||||||
|
const waitForEvent = (target, eventName) => {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
target.addEventListener(eventName, resolve, { once: true })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {!EventEmitter} emitter
|
||||||
|
* @param {string} eventName
|
||||||
|
* @return {!Promise<!Array>} With Event as the first item.
|
||||||
|
*/
|
||||||
|
const emittedOnce = (emitter, eventName) => {
|
||||||
|
return emittedNTimes(emitter, eventName, 1).then(([result]) => result)
|
||||||
|
}
|
||||||
|
|
||||||
|
const emittedNTimes = (emitter, eventName, times) => {
|
||||||
|
const events = []
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const handler = (...args) => {
|
||||||
|
events.push(args)
|
||||||
|
if (events.length === times) {
|
||||||
|
emitter.removeListener(eventName, handler)
|
||||||
|
resolve(events)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emitter.on(eventName, handler)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.emittedOnce = emittedOnce
|
||||||
|
exports.emittedNTimes = emittedNTimes
|
||||||
|
exports.waitForEvent = waitForEvent
|
||||||
|
|
Loading…
Reference in a new issue