本文整理汇总了TypeScript中spectron.Application.start方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Application.start方法的具体用法?TypeScript Application.start怎么用?TypeScript Application.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spectron.Application
的用法示例。
在下文中一共展示了Application.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: startApplication
export function startApplication(app: Application) {
if (!app || app.isRunning()) {
return;
}
console.log("Starting application");
return app.start();
}
示例2: beforeAll
beforeAll(async () => {
app = new Application({
path: electronPath,
args: [path.join(__dirname, '..', '..', 'app')],
});
return app.start();
});
示例3: 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();
});
示例4: 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()
})
示例5: 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
assert.equal(title, 'EVETron');
}).catch((error: any) => {
// Log any failures
console.error('Test failed', error.message);
}).then(() => {
示例6: 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);
});
}