Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asynchronous 如何在Cumber测试中测试承诺的返回值?_Asynchronous_Cucumber_Couchdb_Axios_Cucumberjs - Fatal编程技术网

Asynchronous 如何在Cumber测试中测试承诺的返回值?

Asynchronous 如何在Cumber测试中测试承诺的返回值?,asynchronous,cucumber,couchdb,axios,cucumberjs,Asynchronous,Cucumber,Couchdb,Axios,Cucumberjs,我试图测试get请求对couchdb节点的返回值 我有一个使用以下给定条款定义的功能: Given A get request is made to the DB 通过以下步骤功能实现: var Profile = require('../UserProfile.js') Given('A get request is made to the DB', function () { var text = Profile.getDB('localhost:5984').then(data

我试图测试get请求对couchdb节点的返回值

我有一个使用以下给定条款定义的功能:

Given A get request is made to the DB
通过以下步骤功能实现:

var Profile = require('../UserProfile.js')
Given('A get request is made to the DB', function () {

    var text = Profile.getDB('localhost:5984').then(data => {
        console.log(data)
    })

}); 
上述步骤引用了此模型:

var axios = require('axios')

module.exports = {

    getDB: function(url){               
        return axios.get(url).then(response => {
            return response.data
        })

    }
};
当我在模型中执行GET请求并在步骤定义中引用它时,我似乎无法记录GET请求的结果。当我在步骤定义中执行GET请求时,它是有效的——但这对我没有用处,我想测试模型。如何获取结果值?

,请尝试:

const Profile = require('../UserProfile')
const { defineSupportCode } = require('cucumber')

defineSupportCode(({ defineStep }) => {
   defineStep('A get request is made to the DB', function () {
      return Profile.getDB('http://localhost:5984').then(data => {
        console.log(data)
      })
   })
})