本文整理汇总了TypeScript中cucumber.defineSupportCode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defineSupportCode函数的具体用法?TypeScript defineSupportCode怎么用?TypeScript defineSupportCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了defineSupportCode函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: defineSupportCode
defineSupportCode(function ({ Given, Then, When, setDefaultTimeout }) {
Given('I choose to moderate members of the community before', () => {
return utils.pressButton("#acceptBefore");
});
Given('I choose to moderate members of the community after', () => {
return utils.pressButton("#acceptAfter");
});
When('I save the community', () => {
return utils.pressButton(".save-community");
});
Given('I press button leave community', () => {
utils.pressButton("profile-join .actions .profile-actions .leave");
return browser.waitForAngular();
});
Given('I press button join community', () => {
return utils.pressButton("profile-join .actions .profile-actions .join");
});
Given('I prepare community to run tests', () => {
return utils.goTo("adminuser").then(() => {
return utils.destroy("e2e-community");
}).then(() => {
return browser.get('/myprofile/adminuser');
}).then( () => {
browser.waitForAngular();
return utils.pressButton('ul li .communities');
}).then( () => {
return utils.pressButton('.create-community');
}).then( () => {
return element(by.css('#name')).sendKeys('E2e community');
}).then( () => {
return utils.pressButton('#acceptAfter');
}).then( () => {
return utils.pressButton('.save-community');
}).then( () => {
return utils.goTo("e2e-community");
});
});
Then('I should see join community button', () => {
return expect(element(by.css("profile-join .actions .profile-actions .join")).isPresent()).to.eventually.equal(true);
});
});
示例2: require
import { browser } from 'protractor';
import { CalculatorPageObject } from '../pages/test.page';
import { defineSupportCode } from 'cucumber';
let chai = require('chai').use(require('chai-as-promised'));
let expect = chai.expect;
defineSupportCode(({Given, When, Then}) => {
let calc: CalculatorPageObject = new CalculatorPageObject();
Given(/^The calculator component is present$/, () => {
browser.waitForAngular();
return expect(browser.getTitle()).to.eventually.equal('My App');
});
When(/^I type two numbers "(.*?)" "(.*?)"$/, (num1: string, num2: string) => {
calc.valueA.sendKeys(num1);
return calc.valueB.sendKeys(num2);
});
Then(/^the correct result should be displayed "(.*?)"$/, (result: string) => {
return expect(calc.result.getText()).to.eventually.equal(result);
});
});
示例3: defineSupportCode
import { expect } from 'chai';
import { defineSupportCode } from 'cucumber';
import { AppPage } from './app.po';
defineSupportCode(({Given, When, Then, Before}) => {
let app: AppPage;
Before(() => {
app = new AppPage();
});
Given('I am on the angular.io site',
() => app.navigateTo());
When('I type {string} into the search input field',
(text: string) => app.enterSearchInput(text));
Then('I should see some results in the search overlay',
() => app.getSearchResultItems()
.then(elems => expect(elems.length).to.be.greaterThan(0)));
});
示例4: defineSupportCode
defineSupportCode(function ({ Given, Then, When, setDefaultTimeout }) {
setDefaultTimeout(50000);
Given('I go to the homepage', () => {
return browser.get('/');
});
Then('I should be on the homepage', () => {
return expect(browser.getCurrentUrl()).to.eventually.equal('http://localhost:49152/');
});
Then('I should be on {stringInDoubleQuotes}', (stringInDoubleQuotes) => {
browser.waitForAngular();
return expect(browser.getCurrentUrl()).to.eventually.equal(`http://localhost:49152${stringInDoubleQuotes}`);
});
Given('I follow {stringInDoubleQuotes}', (stringInDoubleQuotes) => {
return utils.pressButton(stringInDoubleQuotes);
});
Given('I fill in the following:', (table, callback) => {
for (const line of table.raw()) {
element(by.css(line[0])).sendKeys(line[1]);
};
callback();
});
Given('I pause', (callback) => {
browser.pause();
});
When('I press {stringInDoubleQuotes}', (stringInDoubleQuotes) => {
return utils.pressButton(stringInDoubleQuotes);
});
When('I press first {stringInDoubleQuotes}', (stringInDoubleQuotes) => {
return element.all(by.css(stringInDoubleQuotes)).first().click();
});
Then('I should be logged in as {stringInDoubleQuotes}', (stringInDoubleQuotes) => {
return expect(element(by.css('#navbar .profile-link .truncated-profile-name')).getText()).to.eventually.equal(stringInDoubleQuotes);
});
Given('I login with {stringInDoubleQuotes}, {stringInDoubleQuotes}', (user: string, password: string) => {
return utils.pressButton('#navbar .login').then(() => {
return element(by.css(".modal-dialog #email")).sendKeys(user);
}).then(() => {
return element(by.css(".modal-dialog #passwd")).sendKeys(password);
}).then(() => {
return utils.pressButton(".btn-login");
});
});
Given('I go to {stringInDoubleQuotes} profile', (profile) => {
browser.waitForAngular();
return browser.driver.get(`http://localhost:49152/${profile}`);
});
Given('I go to {stringInDoubleQuotes}', (page) => {
browser.waitForAngular();
return browser.driver.get(`http://localhost:49152${page}`);
});
Given('I enter in edit mode', () => {
return utils.pressButton(".button-edit-mode");
});
Given('I enter in profile setup', () => {
return utils.pressButton(".open-setup");
});
Given('I enter members menu', () => {
return utils.pressButton("ul li .members");
});
Given('I upload {stringInDoubleQuotes} to {stringInDoubleQuotes}', (file, selector) => {
return element(by.css(selector)).sendKeys(path.resolve(__dirname, `../../assets/${file}`));
});
Then('I see {stringInDoubleQuotes} as top image', (image) => {
return expect(element(by.css('noosfero-profile-header .profile-header')).getCssValue('background-image')).to.eventually.contain(image);
});
Given('I am logged out', () => {
return element(by.css("#navbar .profile-menu > .profile-link")).isPresent().then((present) => {
if (present) {
return utils.pressButton("#navbar .profile-menu > .profile-link").then(() => {
return utils.pressButton("#navbar .btn-logout");
});
}
});
});
When('I change layout to {stringInDoubleQuotes}', (stringInDoubleQuotes) => {
return utils.pressButton("#layout-config-btn").then(() => {
return utils.pressButton(`.layout-config .dropdown-menu .layout-${stringInDoubleQuotes} a.dropdown-item`);
});
});
Then('I see {stringInDoubleQuotes} {int} times', (selector, amount) => {
//.........这里部分代码省略.........
示例5: require
import { browser } from 'protractor';
import { CalculatorPageObject } from '../pages/calcPage';
import { defineSupportCode } from 'cucumber';
let chai = require('chai').use(require('chai-as-promised'));
let expect = chai.expect;
/*
StepDefinition files act as the glue code between config and feature files
They drive the feature files from the background
**/
defineSupportCode(({Given, When, Then}) => {
let calc: CalculatorPageObject = new CalculatorPageObject();
Given(/^I am on ng1 calculator page$/, () => {
return expect(browser.getTitle()).to.eventually.equal('Super Calculator');
});
When(/^I calculate "(.*?)" "(.*?)" "(.*?)"$/, (num1: string, optor: string, num2: string) => {
calc.first_operand.sendKeys(num1);
calc.operator(optor).click();
calc.second_operand.sendKeys(num2);
return calc.go_button.click();
});
Then(/^the result "(.*?)" should be displayed$/, (result: string) => {
return expect(calc.result.getText()).to.eventually.equal(result);
});
})
示例6: defineSupportCode
defineSupportCode(function ({registerHandler, After }) {
registerHandler('BeforeFeature', (event) => {
return browser.get(`http://127.0.0.1:9000/`);
});
After((scenario, callback) => {
if (scenario.failureException) {
browser.driver.takeScreenshot().then(
(image) => {
const decodedImage = new Buffer(image, `base64`);
scenario.attach(decodedImage, `image/png`);
callback();
}
);
} else {
browser.driver.takeScreenshot().then(
(image) => {
const decodedImage = new Buffer(image, `base64`);
scenario.attach(decodedImage, `image/png`);
callback();
}
);
}
});
});
示例7: defineSupportCode
import { defineSupportCode } from 'cucumber';
import { browser, by, element } from 'protractor';
import * as chai from 'chai';
import * as cap from 'chai-as-promised';
chai.use(cap);
const expect = chai.expect;
defineSupportCode(async ({ Before, Given, Then }) => {
Before({ timeout: 30000 }, async function() {
browser.ignoreSynchronization = true;
await browser.get(browser.baseUrl);
});
Given(/^he is on "([^"]*)"$/, async function(url: string): Promise<void> {
const currentUrl = await browser.getCurrentUrl();
expect(currentUrl).to.equal(`${browser.baseUrl}${url}`);
});
Then(/^he get title "([^"]*)"$/, async function(title: string): Promise<void> {
const currentTitle = await browser.getTitle();
expect(currentTitle).to.equal(title);
});
});
示例8: defineSupportCode
/*jslint node: true*/
import { browser } from 'protractor';
import { defineSupportCode } from "cucumber";
import * as fs from 'fs';
/*
Hooks help us follow DRY principle, all the utility functions go here
BeforeScenario, Features and screenshot hooks example provided here
**/
defineSupportCode(function ({registerHandler, After}) {
registerHandler('BeforeFeature', (event) => {
return browser.get('/ng1/calculator');
});
After((scenario, done) => {
if (scenario.isFailed()) {
return browser.takeScreenshot().then(function (base64png) {
let decodedImage = new Buffer(base64png, 'base64').toString('binary');
scenario.attach(decodedImage, 'image/png');
}, (err) => {
done(err);
});
} else {
done();
}
});
})