在实现基于cucumber-protractor-typescript逻辑的一些测试脚本时,我遇到了一个问题:我的Gherkin代码(Cucumber功能)无法找到步骤声明:
步骤定义使用TypeScript编码。但是,我的所有测试都编译并成功运行。看起来我的Cucumber代码不理解TypeScript代码。 There is the same problem as mine, but it didn't solve my problem.
当我尝试手动创建步骤定义文件时,没有选项可以创建TypeScript文件,只有JavaScript:
这是我的步骤定义打字稿代码的示例:
defineSupportCode(({Given, When, Then, Before}) => {
let search: Search;
Before(() => {
search = new Search();
});
Given(/^User on the angular site$/, async () => {
let title = await browser.getTitle();
return expect(title).to.equal('Angular');
});
When(/^User type "(.*?)" into the search input field$/, async (text: string) => {
await search.enterSearchInput(text);
});
Then(/^User should see some results in the search overlay$/, async () => {
await search.getSearchResultItems();
let count = await search.getCountOfResults();
return expect(count).to.be.above(0);
});
});
我的黄瓜档案:
Feature: Search
As a developer using Angular
User need to look-up classes and guidelines
So that User can concentrate on building awesome apps
@SearchScenario
Scenario: Type in a search-term
Given User on the angular site
When User type "foo" into the search input field
Then User should see some results in the search overlay
我的存储库结构:
/features
/steps
searchSteps.ts
search.feature
/pages
search.ts
有人知道如何解决这个问题吗?