當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript cucumber.defineSupportCode函數代碼示例

本文整理匯總了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);
    });
});
開發者ID:vfcosta,項目名稱:angular-theme,代碼行數:46,代碼來源:community.steps.ts

示例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);
  });
});
開發者ID:eontool,項目名稱:angularjs-typescript-starter,代碼行數:24,代碼來源:test.steps.ts

示例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)));

});
開發者ID:alexrun,項目名稱:angular-protractor-cucumber,代碼行數:22,代碼來源:search.steps.ts

示例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) => {
//.........這裏部分代碼省略.........
開發者ID:vfcosta,項目名稱:angular-theme,代碼行數:101,代碼來源:steps.ts

示例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);
  });
})

開發者ID:angular,項目名稱:protractor-cookbook,代碼行數:27,代碼來源:calcSteps.ts

示例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();

        }
      );

    }

  });

});
開發者ID:eontool,項目名稱:angularjs-typescript-starter,代碼行數:37,代碼來源:hooks.ts

示例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);
  });
});
開發者ID:garlictech,項目名稱:generator-garlic-webapp,代碼行數:23,代碼來源:homepage.ts

示例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();
    }
  });
})
開發者ID:angular,項目名稱:protractor-cookbook,代碼行數:27,代碼來源:hooks.ts


注:本文中的cucumber.defineSupportCode函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。