WebStorm中的“未定义步骤引用”在尝试时引用TypeScript步骤定义代码

问题描述 投票:0回答:1

在实现基于cucumber-protractor-typescript逻辑的一些测试脚本时,我遇到了一个问题:我的Gherkin代码(Cucumber功能)无法找到步骤声明:

can not find declaration of steps

步骤定义使用TypeScript编码。但是,我的所有测试都编译并成功运行。看起来我的Cucumber代码不理解TypeScript代码。 There is the same problem as mine, but it didn't solve my problem.

当我尝试手动创建步骤定义文件时,没有选项可以创建TypeScript文件,只有JavaScript:

When I am trying to create step definition file manually, there is no option to create TypeScript file, only 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

有人知道如何解决这个问题吗?

javascript typescript cucumber webstorm gherkin
1个回答
1
投票

遗憾的是,WebStorm不支持​​在TypeScript中编写Cucumber.js测试。请投票选择WEB-22516WEB-29665,以获得有关TypeScript支持的任何进展的通知

© www.soinside.com 2019 - 2024. All rights reserved.