Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explore: Add e2e-testing with Spectron
In this patch we're creating the most basic form of end-to-end testing using the Spectron framework. This boots the app and verifies that it opens. The files aren't in the right spot and the structure of the tests need to change but this gives us an idea of how to run these tests.
- Loading branch information
Showing
5 changed files
with
525 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'regenerator-runtime/runtime'; | ||
import { Application } from 'spectron'; | ||
import electronPath from 'electron'; | ||
import path from 'path'; | ||
|
||
const app = new Application({ | ||
path: electronPath, | ||
args: [path.join(__dirname, '..', '..')], | ||
}); | ||
|
||
describe('E2E', () => { | ||
beforeEach(async () => await app.start(), 10000); | ||
|
||
afterEach(async () => app && app.isRunning() && (await app.stop())); | ||
|
||
test('starts', async () => { | ||
await app.client.waitUntilWindowLoaded(); | ||
expect(app.isRunning()).toEqual(true); | ||
}); | ||
|
||
test('logs in', async () => { | ||
await app.client.waitUntilWindowLoaded(); | ||
|
||
const username = app.client.$('#login__field-username'); | ||
const password = app.client.$('#login__field-password'); | ||
|
||
if (!username.isExisting()) { | ||
await username.waitForExist(); | ||
} | ||
|
||
if (!password.isExisting()) { | ||
await password.waitForExist(); | ||
} | ||
|
||
username.setValue(process.env.TEST_USERNAME); | ||
password.setValue(process.env.TEST_PASSWORD); | ||
|
||
await new Promise(resolve => setTimeout(resolve, 500)); | ||
|
||
await app.client.$('#login__login-button').click(); | ||
|
||
await app.client.waitUntilWindowLoaded(); | ||
await new Promise(resolve => setTimeout(resolve, 5000)); | ||
expect(await app.client.$('.simplenote-app').isExisting()).toEqual(true); | ||
}); | ||
}); |
Oops, something went wrong.