本文整理匯總了TypeScript中cucumber.After函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript After函數的具體用法?TypeScript After怎麽用?TypeScript After使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了After函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: catch
await fs.stat(this.rootDir)
rootDirExists = true
} catch (e) {
// nothing to do here
}
if (rootDirExists) {
rimraf.sync(this.rootDir)
}
await fs.mkdir(this.rootDir)
})
After(async function(scenario) {
await endChildProcesses()
if (scenario.result.status === 'failed') {
console.log('\ntest artifacts are located in', this.rootDir)
} else {
const rimrafp = util.promisify(rimraf)
await rimrafp(this.rootDir, { maxBusyTries: 20 })
}
})
Before({ tags: '@verbose' }, function() {
this.verbose = true
})
After({ tags: '@verbose' }, function() {
this.verbose = false
})
Before({ tags: '@debug' }, function() {
this.debug = true
示例2: use
import chaiFs from 'chai-fs';
import chaiString from 'chai-string';
import { Question } from './world';
use(chaiString);
use(chaiFs);
use(chaiJestSnapshot);
BeforeAll(function() {
chaiJestSnapshot.resetSnapshotRegistry();
});
After(function() {
if (this.spawned && !this.output.closed) {
this.spawned.kill();
}
});
Before(function(testCase) {
const { name } = testCase.pickle;
this.snapshot.testname = name;
this.snapshot.filename = `features/__snaps__/${name
.toLowerCase()
.replace(/\s/g, '-')}.snap`;
});
/**
* Given I Have
*/
示例3: StepSampleWithoutDefineSupportCode
function StepSampleWithoutDefineSupportCode() {
setWorldConstructor(function({attach, parameters}) {
this.attach = attach;
this.parameters = parameters;
this.visit = (url: string, callback: Callback) => {
callback(null, 'pending');
};
this.toInt = parseInt;
});
Before((scenarioResult: HookScenarioResult, callback: Callback) => {
console.log(scenarioResult.result.status === Status.FAILED);
callback();
});
Before({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback: Callback) => {
console.log(scenarioResult.result.status === Status.FAILED);
callback();
});
Before('@tag', (scenarioResult: HookScenarioResult, callback: Callback) => {
console.log(scenarioResult.result.status === Status.FAILED);
callback();
});
BeforeAll((callback: Callback) => {
console.log("Before all");
callback();
});
BeforeAll({ timeout: 1000 }, (callback: Callback) => {
console.log("Before all");
callback();
});
BeforeAll('@tag', (callback: Callback) => {
console.log("Before all");
callback();
});
After((scenarioResult: HookScenarioResult, callback: Callback) => {
console.log("After");
callback();
});
After({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback: Callback) => {
console.log("After");
callback();
});
After('@tag', (scenarioResult: HookScenarioResult, callback: Callback) => {
console.log("After");
callback();
});
AfterAll((callback: Callback) => {
console.log("After all");
callback();
});
AfterAll({ timeout: 1000 }, (callback: Callback) => {
console.log("After all");
callback();
});
AfterAll('@tag', (callback: Callback) => {
console.log("After all");
callback();
});
Given(/^a variable set to (\d+)$/, (x: string) => {
console.log("the number is: " + x);
});
Given(/^a variable set to (\d+)$/, (x: number) => {
console.log(typeof x);
});
Given(/^I am on the Cucumber.js GitHub repository$/, function(callback: Callback) {
this.visit('https://github.com/cucumber/cucumber-js', callback);
});
When(/^I go to the README file$/, (title: string, callback: Callback) => {
callback(null, 'pending');
});
Then(/^I should see "(.*)" as the page title$/, {timeout: 60 * 1000}, function(title: string, callback: Callback) {
const pageTitle = this.browser.text('title');
if (title === pageTitle) {
callback();
} else {
callback(new Error("Expected to be on page with title " + title));
}
});
// Type for data_table.js on
// https://github.com/cucumber/cucumber-js/blob/a5fd8251918c278ab2e389226d165cedb44df14a/lib/cucumber/ast/data_table.js
Given(/^a table step with Table raw$/, (table: Table) => {
//.........這裏部分代碼省略.........
示例4: require
const { BeforeAll, After, Status } = require("cucumber");
import * as fs from "fs";
import { browser } from "protractor";
import { config } from "../config/config";
BeforeAll({timeout: 10 * 1000}, async () => {
await browser.get(config.baseUrl);
});
After(async function(scenario) {
if (scenario.result.status === Status.FAILED) {
// screenShot is a base-64 encoded PNG
const screenShot = await browser.takeScreenshot();
this.attach(screenShot, "image/png");
}
});