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

Not running all tests #880

Closed
wejrowski opened this issue Jun 20, 2015 · 10 comments
Closed

Not running all tests #880

wejrowski opened this issue Jun 20, 2015 · 10 comments

Comments

@wejrowski
Copy link

I'm on 2.2.0 and typically when I have more than 10 tests, it will only run the first 10 and not the others. Most of my tests are doing api calls which take a little while. If I remove the api calls it works fine with more tests. I can't figure out why though I believe it has something to do with the timeout function. I know if I remove the if statement where it's checking for maximumSpecCallbackDepth in clearStack(), it's fine.

I'm running this in a Nashorn environment with a custom reporter and using jasmine.clock().install();.

Has anyone else experience this or have any idea what it may be?

@slackersoft
Copy link
Member

If your specs are making Ajax requests, you should probably be stubbing them out with something like jasmine ajax or else using the done callback to make your specs asynchronous and wait for the call to return.

@provegard
Copy link

I have this problem as well. My test suite is run in a Scala host using Nashorn.

I lowered maximumSpecCallbackDepth to 5 to make it work. It would be nice to have this value as a configurable option.

(Side note/question: I had to make my Jasmine boot file async-aware by executing a host-provided done-callback in a custom reporter. Is that the officially recommended way?)

@slackersoft
Copy link
Member

@provegard The current preferred way to cause your jasmine suite to not execute at onload time is to provide your own boot.js that waits until your suite is ready before kicking off the run.

@provegard
Copy link

@slackersoft Not sure what you mean - as I wrote I'm running tests from a Scala/Nashorn host, so there is no such thing as onload.

I have a custom boot file that essentially calls env.execute() inside a function that is called from Scala code. But there is no human to observe HTML output in a browser. Instead, the Scala code wants to know about the outcome of the test run. But as soon as Jasmine starts going async, env.execute() returns to the caller. At this point, the suite may not yet be complete.

My current approach to knowing when the suite is complete is to have a Scala-provided reporter that resolves a Promise inside jasmineDone. That works well, so there's no problem here. I was just curious as to if this is a standard approach to dealing with suite-asyncness from a programmatic run. :-)

@provegard
Copy link

One more thing to add: http://jasmine.github.io/2.3/boot.html says "The jsApiReporter also receives spec results, and is used by any environment that needs to extract the results from JavaScript." So using jsApiReporter was my first approach, but since it hadn't collected all test results by the time env.execute() returned, it was of no use.

@slackersoft
Copy link
Member

Spec execution is always potentially asynchronous (if you have more than 20 specs, it will definitely be see #366, #945), so you always have to wait for the jasmineDone event to get reported before all of the specs.

@vitalije
Copy link

I have a problem with Spec with more than 15 tests. Jasmine reports correctly execution of every test printing out dots and F-s, but at the end it gives wrong information that everything went ok without errors. It doesn't print any other information on failed tests. When I comment out some of the tests to reduce number of them, jasmine prints detailed information on every failed test and also at the end it gives correct summary with number of failed tests. Here is the output when suite contains more than 15 tests.

Running "jasmine" task
Started
..F..........FF..
Done, without errors.

Well, I have found a solution. In the Gruntfile.coffee, where the task 'jasmine' is registered, the following lines of code should be added before calling jasmine.execute()

grunt.registerTask 'jasmine', '....', ()->
     jasmine = new require('jasmine')
     conf = 
           spec_dir: 'build/spec'
           spec_files: ['mySpec.js']
           helpers: ['helpers/*.js']
     jasmine.loadConfig conf
     // the following three lines solved the issue 
     done = this.async()
     jasmine.onComplete (passed) ->
           done(passed)

     jasmine.exec()

HTH

@slackersoft
Copy link
Member

@vitalije It looks like you're using the jasmine-npm to run your specs. That package also includes a grunt task that should correctly run your specs, but you would need to put your configuration into a jasmine.json file.

@vitalije
Copy link

Thanks @slackersoft

@slackersoft
Copy link
Member

It sounds like this issue was primarily from not waiting for the suite to finish executing (jasmineDone to get called on a reporter), so I'm going to close it.

Thanks for using Jasmine!

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

4 participants