forked from LN-Zap/zap-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): run e2e tests with custom electron userDir
- Loading branch information
Showing
5 changed files
with
63 additions
and
24 deletions.
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
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,38 @@ | ||
import os from 'os' | ||
import fs from 'fs' | ||
import { Application } from 'spectron' | ||
import electronPath from 'electron' | ||
import path from 'path' | ||
|
||
jest.setTimeout(50000) | ||
jest.unmock('electron') | ||
|
||
// Before running tests, create a new temporary directory that we will use for the electron userDir. | ||
const userDir = fs.mkdtempSync(path.join(os.tmpdir(), 'zap-')) | ||
|
||
export const startApp = async () => { | ||
const app = new Application({ | ||
path: electronPath, | ||
args: [path.join(__dirname, '..', '..', 'app')], | ||
waitTimeout: 10000, | ||
startTimeout: 10000, | ||
quitTimeout: 2000, | ||
// Use requre that we reference in preload.js | ||
requireName: 'electronRequire', | ||
// Tell the app to use a custom Electron userDir. | ||
env: { | ||
USER_DIR: userDir | ||
} | ||
}) | ||
|
||
await app.start() | ||
|
||
await app.client.waitUntilWindowLoaded() | ||
return app | ||
} | ||
|
||
export const stopApp = async app => { | ||
if (app && app.isRunning()) { | ||
await app.stop() | ||
} | ||
} |
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