6 changed files with 121 additions and 122 deletions
@ -1,54 +1,53 @@ |
|||||
/* eslint-disable */ |
/* eslint-disable */ |
||||
|
import { Application } from 'spectron' |
||||
|
import electronPath from 'electron' |
||||
|
import path from 'path' |
||||
|
|
||||
import { Application } from 'spectron'; |
jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000 |
||||
import electronPath from 'electron'; |
|
||||
import path from 'path'; |
|
||||
|
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000; |
const delay = time => new Promise(resolve => setTimeout(resolve, time)) |
||||
|
|
||||
const delay = time => new Promise(resolve => setTimeout(resolve, time)); |
|
||||
|
|
||||
describe('main window', function spec() { |
describe('main window', function spec() { |
||||
beforeAll(async () => { |
beforeAll(async () => { |
||||
this.app = new Application({ |
this.app = new Application({ |
||||
path: electronPath, |
path: electronPath, |
||||
args: [path.join(__dirname, '..', '..', 'app')] |
args: [path.join(__dirname, '..', '..', 'app')] |
||||
}); |
}) |
||||
|
|
||||
return this.app.start(); |
return this.app.start() |
||||
}); |
}) |
||||
|
|
||||
afterAll(() => { |
afterAll(() => { |
||||
if (this.app && this.app.isRunning()) { |
if (this.app && this.app.isRunning()) { |
||||
return this.app.stop(); |
return this.app.stop() |
||||
} |
} |
||||
}); |
}) |
||||
|
|
||||
const findCounter = () => this.app.client.element('[data-tid="counter"]'); |
const findCounter = () => this.app.client.element('[data-tid="counter"]') |
||||
|
|
||||
const findButtons = async () => { |
const findButtons = async () => { |
||||
const { value } = await this.app.client.elements('[data-tclass="btn"]'); |
const { value } = await this.app.client.elements('[data-tclass="btn"]') |
||||
return value.map(btn => btn.ELEMENT); |
return value.map(btn => btn.ELEMENT) |
||||
}; |
} |
||||
|
|
||||
it('should open window', async () => { |
it('should open window', async () => { |
||||
const { client, browserWindow } = this.app; |
const { client, browserWindow } = this.app |
||||
|
|
||||
await client.waitUntilWindowLoaded(); |
await client.waitUntilWindowLoaded() |
||||
await delay(500); |
await delay(500) |
||||
const title = await browserWindow.getTitle(); |
const title = await browserWindow.getTitle() |
||||
expect(title).toBe('Zap'); |
expect(title).toBe('Zap') |
||||
}); |
}) |
||||
|
|
||||
it('should haven\'t any logs in console of main window', async () => { |
it('should haven\'t any logs in console of main window', async () => { |
||||
const { client } = this.app; |
const { client } = this.app |
||||
const logs = await client.getRenderProcessLogs(); |
const logs = await client.getRenderProcessLogs() |
||||
// Print renderer process logs
|
// Print renderer process logs
|
||||
logs.forEach((log) => { |
logs.forEach((log) => { |
||||
console.log(log.message); |
console.log(log.message) |
||||
console.log(log.source); |
console.log(log.source) |
||||
console.log(log.level); |
console.log(log.level) |
||||
}); |
}) |
||||
expect(logs).toHaveLength(0); |
expect(logs).toHaveLength(0) |
||||
}); |
}) |
||||
}); |
}) |
||||
|
Loading…
Reference in new issue