本文整理匯總了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);
});
}