dimanche 8 juillet 2018

Test finished without running any assertion (ava-nodejs)

Why does this test return Test finished without running any assertion? Something wrong with promise handling? If i run this code on server everything works properly.

test.serial('test with req' , async (assert) => {
  var promise = new Promise(function(resolve, reject) {
  request('https://www.random.org/integers/?num=1&min=1&max=100&col=5&base=10&format=plain&rnd=new',
    (error, response, body) => {
      console.log(response)
      if(!error){
        resolve(body)
      } else {
        reject(error)
      }
    })
  })

  promise.then((result) => {
    console.log(result);
    assert.true(result !== undefined)
  }, (err) => {
    console.log(err)
    assert.true(err !== undefined)
  })
})

Aucun commentaire:

Enregistrer un commentaire