Questions tagged [chai-as-promised]

Chai as Promised is an extension for the Chai assertion library which adds the capability for assertions about promises.

Chai as Promised is an extension for the Chai assertion library which adds the capability for assertions about promises. It is compatible with any promises which follow the Promises/A+ specification.

116 questions
0
votes
1 answer

Sinon, observing different behaviour using Promise.reject() to stub.rejects()

I was having issues running a test (in Node), I was simulating a promise being rejected, and my code should retry (using promise-retry if that could be relevant). When I simulated the rejected promise using stub.returns(Promise.reject(error) I was…
vidhill
  • 13
  • 1
  • 4
0
votes
1 answer

serenity-js / cucumber / chai Promise AssertionError need some assistance

Im losing it, I feel like im doing this right BUT cant figure out why this simple test fails I got a feature file like so Scenario: List all accounts in the tenant Given that Keith has navigated to the tenant account list When he views the…
kapperkp
  • 199
  • 1
  • 3
  • 14
0
votes
1 answer

How to test for a propety of a class after promise resolution with mocha and chai

I am trying out a bit of unit testing with Mocha + Chai as promised 'use strict'; var chai = require('chai').use(require('chai-as-promised')) var should = chai.should(); describe('Testing how promises work', () => { it("should work right",…
Ranjith Ramachandra
  • 10,399
  • 14
  • 59
  • 96
0
votes
1 answer

returning promises chai as promised

I am new to promises, I have the following function var chai = require('chai'); var expect = chai.expect; var chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); it('should do something with promises', function() { var…
Venkata
  • 656
  • 6
  • 17
0
votes
1 answer

create row but promise not resolve

Using seqalizerjs, resolve a promise: return new Promise(function(resolve, reject){ return models.merchants.create({ name: ctx.name, }); }).then(function(result){ resolve({ …
Alvin
  • 8,219
  • 25
  • 96
  • 177
0
votes
1 answer

Sinon check if other method of object is invoked with promise

I have a confusing not working test which I am unable to solve somehow (I am coming from Java background so I am sorry in advance if there are some mistakes in my terminology). There is an object class Trigger which has some public functions, foo()…
Vegaaaa
  • 474
  • 4
  • 22
0
votes
0 answers

chai as promise call function once

How can I do this with chai-as-promised: Currently I am using chai expect: return User.auth(data).then(function(usr){ expect(usr).to.have.property('user', 'alvin'); expect(usr).to.have.property('email', 'alvin@l.com'); }); for…
Alvin
  • 8,219
  • 25
  • 96
  • 177
0
votes
2 answers

check chai as promised on multiple properties object

hello I have a method which returns me data along with URL , so return object has url and body as two properties. return new Promise(function(resolve,reject) { request(url, function (error, response, body) { if(error) …
0
votes
2 answers

How to handle Boolean value in Chai protractor promise

I have tried to validate the Boolean value in chai promise as below, expect(2==2).to.eventually.equal(true); But I got the below error: E/launcher - true is not a thenable. Can anyone help me how to validate the Boolean value using chai promise.
KAK
  • 905
  • 4
  • 14
  • 33
0
votes
2 answers

Uncaught ReferenceError: require is not defined karma and webpack

So I was just trying to use chai-as-promised with karma and webpack and this is what I get. I have chai-as-promised, karma-chai-as-promised, sinon-chai, karma-sinon-chai, karma-webpack installed so i should be good to go yet it doesn't work here is…
Amgad Serry
  • 1,595
  • 2
  • 12
  • 20
0
votes
2 answers

Testing vuex action that contains an async

[This is a Vue app, using Vuex, created with vue-cli, using mocha, chai, karma, sinon] I'm trying to create tests for my vuex state and I DON'T want to use a mock -- one of my big goals for these tests is to also test the API that data is coming…
Paulie
  • 1,940
  • 3
  • 20
  • 34
0
votes
1 answer

Cucmber.js step is getting passed even though expect should have failed

My Cucumber step is getting passed even though expect statement is failing. It seems steps is running before expect statement is completed. Please let me know how can I instruct the cucumber step to fail if expect is getting failed. [Folder…
0
votes
2 answers

What is the difference between calling chai-as-promised with or without a notify method?

I'm using chai and chai-as-promised to test some asynchronous JS code. I just want to check that a function returning a promise will eventually return an Array and wrote the 2 following tests: A: it('should return an array', () => { …
Mick F
  • 7,312
  • 6
  • 51
  • 98
0
votes
1 answer

Promise rejection failed with chai-as-promised

I use chai-as-promised library with promise generated by the q library. This simple test case should work (the promise must be rejected) or i misunderstand promise feature? bdd.it("Test rejection", function () { var promise = q.promise(function…
Troopers
  • 5,127
  • 1
  • 37
  • 64
0
votes
1 answer

Cucumber-Protractor Multiple Expect And Notify

I have a step in my scenario that fills in multiple text fields and selects options from a dropdown. I want to assert that the text entered and the option selected was correct for each. expect(action1).to.eventually.have.string('some…
Austin
  • 576
  • 2
  • 8
  • 21