generated from catdad/electron-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmoke.test.js
82 lines (58 loc) · 2.27 KB
/
smoke.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const { expect } = require('chai');
const { start, stop, environment } = require('./lib/app-provider.js');
const config = require('./lib/config-provider.js');
describe('[smoke tests]', () => {
const all = async (...promises) => {
let err;
await Promise.all(promises.map(p => p.catch(e => {
err = e;
})));
if (err) {
throw err;
}
};
async function cleanup() {
const includeLogs = this.currentTest.state === 'failed' || process.env.VERBOSE;
await all(
stop(includeLogs),
config.cleanAll()
);
}
beforeEach(cleanup);
afterEach(cleanup);
it('opens the application', async () => {
const configPath = await config.create({});
const app = await start(configPath);
await app.utils.waitForVisible('#app');
await app.utils.waitForElementCount('p.label', 1);
expect(await app.utils.getText('#app p.label')).to.include('This is your app');
});
it(`shows that the app is runing in "${environment}" mode`, async () => {
const configPath = await config.create({});
const app = await start(configPath);
await app.utils.waitForVisible('#app');
await app.utils.waitForElementCount('p.environment', 1);
const envString = `Environment: ${environment === 'production' ? 'Production' : 'Development'}`;
expect(await app.utils.getText('#app p.environment')).to.equal(envString);
});
it('counts when clicking the button', async () => {
const configPath = await config.create({});
const app = await start(configPath);
await app.utils.waitForVisible('.app button');
// maybe consider using better selectors, but you get the idea
expect(await app.utils.getText('.app > div > span')).to.equal('0');
await app.utils.click('.app button');
expect(await app.utils.getText('.app > div > span')).to.equal('1');
});
it('loads the previously counted value', async () => {
const configPath = await config.create({
// set any config that matter to your app/test
counter: 72
});
const app = await start(configPath);
await app.utils.waitForVisible('#app button');
expect(await app.utils.getText('.app > div > span')).to.equal('72');
await app.utils.click('.app button');
expect(await app.utils.getText('.app > div > span')).to.equal('73');
});
});