本文整理汇总了TypeScript中spectron.Application类的典型用法代码示例。如果您正苦于以下问题:TypeScript Application类的具体用法?TypeScript Application怎么用?TypeScript Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: stopApplication
export function stopApplication(app: Application) {
if (!app || !app.isRunning()) {
return;
}
console.log("Stopping application");
return app.stop();
}
示例2: startApplication
export function startApplication(app: Application) {
if (!app || app.isRunning()) {
return;
}
console.log("Starting application");
return app.start();
}
示例3: beforeAll
beforeAll(async () => {
app = new Application({
path: electronPath,
args: [path.join(__dirname, '..', '..', 'app')],
});
return app.start();
});
示例4: before
before(function() {
let electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', 'electron');
if (process.platform === 'win32') {
electronPath += '.cmd';
}
let appPath = path.join(__dirname, '..', '..', 'app', 'server', 'main.js');
app = new Application({
path: electronPath,
args: [
appPath,
`--storagepath=${testHelpers.tempLocalStore}`
],
});
chaiAsPromised.transferPromiseness = app.transferPromiseness;
return app.start();
});
示例5: beforeEach
beforeEach(function() {
let appPath = path.join(
__dirname,
'..',
'..',
'..',
'node_modules',
'.bin',
'electron'
)
if (process.platform === 'win32') {
appPath += '.cmd'
}
app = new Application({
path: appPath,
args: [path.join(__dirname, '..', '..', '..', 'out')],
})
return app.start()
})
示例6: require
// A simple test to verify a visible window is opened with a title
import assert = require('assert');
let Application = require('spectron').Application;
let pathToApp = `./src/evetron/bin/${(process.platform === 'darwin'
? 'Electron.app/Contents/MacOS/'
: '')}electron${(process.platform === 'win32'
? '.exe'
: '')}`;
/*********** Node tests ***********/
const app = new Application({
path: pathToApp,
});
console.log('application launch');
app.start().then(() => {
// Check if the window is visible
return app.browserWindow.isVisible();
}).then((isVisible: Boolean) => {
// Verify the window is visible
assert.equal(isVisible, true);
}).then(() => {
// Get the window's title
return app.browserWindow.getTitle();
}).then((title: String) => {
// Verify the window's title
示例7: boot
export function boot(context: ITestCallbackContext, testConfig: Partial<FnTestConfig> = {}): Promise<spectron.Application> {
context.retries(testConfig.retries || 0);
context.timeout(testConfig.testTimeout || 30000);
const skipFetch = testConfig.skipFetch !== false;
const skipUpdateCheck = testConfig.skipUpdateCheck !== false;
const currentTestDir = getTestDir(context);
if (testConfig.prepareTestData) {
testConfig.prepareTestData.forEach((data) => {
fs.outputFileSync([currentTestDir, data.name].join(path.sep), data.content);
});
}
const profilesDirPath = currentTestDir + "/profiles";
const localProfilePath = profilesDirPath + "/local";
testConfig.localRepository = Object.assign(new LocalRepository(), testConfig.localRepository || {});
testConfig.localRepository.openTabs = testConfig.localRepository.openTabs.map((tab) => {
if (tab.id.startsWith("test:")) {
tab.id = tab.id.replace("test:", currentTestDir);
}
return tab;
});
fs.outputFileSync(localProfilePath, JSON.stringify(testConfig.localRepository));
if (testConfig.platformRepositories) {
for (const userID in testConfig.platformRepositories) {
const profilePath = profilesDirPath + `/${userID}`;
const profileData = Object.assign(new UserRepository(), testConfig.platformRepositories[userID] || {});
fs.outputFileSync(profilePath, JSON.stringify(profileData));
}
}
const moduleOverrides = testConfig.overrideModules && JSON.stringify(testConfig.overrideModules, (key, val) => {
if (typeof val === "function") {
return val.toString();
}
return val;
});
const chromiumArgs = [
isDevServer() && "./electron",
"--spectron",
skipFetch && "--no-fetch-on-start",
skipUpdateCheck && "--no-update-check",
"--user-data-dir=" + currentTestDir,
moduleOverrides && `--override-modules=${moduleOverrides}`
].filter(v => v);
const appCreation = new spectron.Application({
path: findAppBinary(),
args: chromiumArgs
});
return appCreation.start().then((app: any) => {
Object.assign(app, {testdir: currentTestDir});
if (testConfig.waitForMainWindow === false) {
return app;
}
return app.client.waitForVisible("ct-layout").then(() => app);
});
}
示例8:
}).then(() => {
console.log('application exit');
// Stop the application
return app.stop();
});