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

Asynchronous support? #185

Closed
juanca opened this issue Aug 8, 2017 · 9 comments
Closed

Asynchronous support? #185

juanca opened this issue Aug 8, 2017 · 9 comments

Comments

@juanca
Copy link

juanca commented Aug 8, 2017

Not really sure how to figure out what is at fault but I figured this might be a decent spot to ask for advice:

This is the test file:

it('fails on purpose', function() {
  console.log('Expected failure');
  expect(true).toEqual(false);
});

it('fails without purpose (asynchronously)', function(done) {
  console.log('Unexpected failure');
  expect(true).toEqual(true);
  done();
});

Expected behaviour

1 failure, 1 success

Actual behaviour

2 failures, 0 success

with the following report:

18:28:11.675 spec.js:2 Expected failure
18:28:11.684 debug.js:15 FAILED  fails on purpose
18:28:11.684 spec.js:7 Unexpected failure
18:28:11.687 debug.js:21 Uncaught Expected true to equal false.
    at Object.<anonymous> (http://localhost:9876/base/spec.js:3:16)
(anonymous) @ debug.js:21
18:28:11.687 debug.js:15 FAILED  fails without purpose (asynchronously)
18:28:11.687 debug.js:6 Skipped 0 tests
18:28:11.688 debug.js:21 Uncaught Uncaught Expected true to equal false.
    at Object.<anonymous> (http://localhost:9876/base/spec.js:3:16) thrown
(anonymous) @ debug.js:21

Environment Details

  • webpack@2.5.0
  • karma@1.7.0
  • jasmine@2.7.0
  • karma-webpack@2.0.4
  • karma-jasmine@1.1.0

===

Jasmine keeps catching the thrown exception on all async specs. :( I'm not really sure if debug.js is set up correctly for asynchronous specs.

If I had multiple asynchronous spec, each would throw the previous uncaught exception.

@daanstolp
Copy link

I just posted the exact same thing as an issue on the karma github. I'm not quite sure if it is specific to karma or to the karma-jasmine plugin. Have you had any luck finding a fix or workaround?

@juanca
Copy link
Author

juanca commented Aug 18, 2017

I have not found a fix for this -- besides getting the specs green 😺

😭

@maksimr
Copy link
Contributor

maksimr commented Aug 22, 2017

@juanca @daanstolp could you provide gist which reproduces this problem

Thanks

P.S.

Is it work in Jasmine as expected? (Without karma)

@juanca
Copy link
Author

juanca commented Aug 22, 2017

Yeah, it does work without karma.

I'll post steps tomorrow since I'm not near a working computer today.

@daanstolp
Copy link

Hi @maksimr, see my previous comment with the link to the karma issue. It describes the exact steps to reproduce. The main culprit is the Debug.js file of the karma debug runner.

@juanca
Copy link
Author

juanca commented Aug 23, 2017

Finally on a working computer, will try to get a public repo setup by EOD.

Something I want to capture before it leaves my head: I'll mess around with the iframe options in Karma in case that is correlated with our issues. EDIT: useIframe and/or runInParent seem to have no effect.

@juanca
Copy link
Author

juanca commented Aug 23, 2017

Repo set up @ https://github.com/juanca/karma-jasmine-async-bug

README contains SHAs which showcase how it works with just jasmine and how it works and does not work with karma/karma-jasmine.

Let me know if y'all need anything else.

@daanstolp
Copy link

As I mentioned before, this issue is not particular to Jasmine, but can be traced to the Debug.js file of the karma debug runner. I have published a pull request with a fix, which has just now been accepted and merged into master. See the issue here and the pull request here.

@juanca
Copy link
Author

juanca commented Aug 25, 2017

Awesome work! Thank you for the fix!

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

No branches or pull requests

3 participants