Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test a function which returns a promise and uses async.waterfall() model inside the promise? #240

Open
laxmid opened this issue Feb 23, 2018 · 0 comments

Comments

@laxmid
Copy link

laxmid commented Feb 23, 2018

I want to write test cases for the following function:

Function implementation contains:

function test(){
    return new promise(function(resolve, reject){
        async.waterfall([
		function1(cb){
			....
		},
		function2(cb){
			....
		},
		function3(cb){
			.....
		}
	]);
   });
}

I have tried writing test cases in following ways:

  1. Using callback:
describe('test method', function(){
	it('Should return failed', function(done){
		test().should.eventually.be.rejected.and.have.property('code','Failed');
		done();
	});
});

In this case, the test cases passed but got the error "Unhandled rejection AssertionError" for every test case.

  1. Using async-await:
describe('test method', function(){
	it('Should return failed',async function(){
		var result = await test();
		result.should.eventually.be.rejected.and.have.property('code','Failed');
		return;
	});
});`

In this case, I got the error "ReferenceError: regeneratorRuntime is not defined".

Is there any other way for this? Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant