虽然 运行 Cucumber 测试抛出错误和未定义的实现,但使用以下代码片段

While running the Cucumber test throws error and undefined implement with the following snippet

虽然 运行 Cucumber/javascript/selenium 网络驱动程序测试,但我得到了 Undefined. Implement with the following snippet: this.Then(/^I should display "([^"]*)" under the search area$/, function (arg1, callback){ callback(null, 'pending');....。在搜索区域中键入文本时,系统将在搜索输入框下方显示结果列表。在显示的结果中,我正在寻找带有文本 'Building Designers' 的元素。知道为什么这是未定义的吗?

Feature: Test search 
   Scenario: List all the items based on input text provide in search
        When I typed the following "Building" text in input
        Then I should display "Building Designers" under the search area

// 搜索-steps.js

this.When(/^I typed the following "([^"]*)" text in input$/, (text) =>{
      return helpers.loadPage('https://www.sometestsite.com')    
      .then(()=>{
          driver.findElement(By.id('search')).sendKeys(text);
      })
    })



this.Then(/^I should display "([^"]*)"under the search area&/, function (mytxt){
        return driver.wait(until.elementsLocated(By.cssSelector("div.SearchResults--result.button")), 50000).getText().then(el => {
        console.log("print text here:"+el);
        const displayTxt = el;  
        expect(displayTxt).to.be.eql(mytxt);        
        });     
    })

this.Then(/^I should display "([^"]*)"under the search area&/, function (mytxt){

你在末尾有一个 & 而不是 $