简体   繁体   English

黄瓜休息

[英]Restler with Cucumber

I am totally new with protractor/cucumber and restler.我对量角器/黄瓜和restler完全陌生。 I am using Typescript.我正在使用打字稿。 Below is the code that I am using to hit the endpoint url and to get the response下面是我用来点击端点 url 并获得响应的代码

Given('Hit the {string}', async (string) => {
  browser.quit()
  var data: any = get(string.replace(/\s+/g, ''));
  console.log("In method:" + string.replace(/\s+/g, ''));
  console.log(data.response);
});

This prints the below:这将打印以下内容:

In method:endpoint URL在方法中:端点 URL

undefined不明确的

I want the response and the responsecode to be printed.我想要打印响应和响应代码。

Thanks for the response.感谢您的回复。 Below code worked下面的代码有效

Given('Hit the {string}', async (endpointUrl) => {
    await get(endpointUrl).on('complete', async (result, response) => {
        console.log(response.statusCode);
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM