Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Add support for Jasmine #167

Closed
jzaefferer opened this issue May 1, 2012 · 6 comments
Closed

Add support for Jasmine #167

jzaefferer opened this issue May 1, 2012 · 6 comments
Assignees
Milestone

Comments

@jzaefferer
Copy link
Member

At this point, the two JS testing frameworks that seem to get the most attention are QUnit and Jasmine. TestSwarm shouldn't really care about which one you use, so adding support for Jasmine seems like a good idea. Might be enough to just add a check and hooks for it in the main integration script.

Even if not a priority for the jQuery project, maybe someone already implemented it - we're certainly interested in adding support.

@maciejblinkbox
Copy link

You could add this code to testFrameworks in inject.js :

"Jasmine": {
            detect: function() {
                return typeof jasmine !== "undefined" && typeof describe !== "undefined" && typeof it !== "undefined";
            },
            install: function() {
                log('installing Jasmine framework support');

                var jasmineTestSwarmResults = null;

                var testSwarmReporter = {
                    reportRunnerStarting: function (runner)
                    {
                        log('Jasmine reportRunnerStarting');
                        // reset counters
                        jasmineTestSwarmResults = {
                            fail: 0,
                            error: 0,
                            total: 0
                        };
                    },
                    reportRunnerResults: function (runner)
                    {
                        // testing finished
                        log('Jasmine reportRunnerResults');
                        submit(jasmineTestSwarmResults);                        
                    },
                    reportSuiteResults: function (suite)
                    {
                        log('Jasmine reportSuiteResults:' + suite.description);
                        // not in use
                    },
                    reportSpecStarting: function (spec)
                    {
                        log('Jasmine reportSpecStarting' + spec.description);
                        jasmineTestSwarmResults.total++;
                        window.TestSwarm.heartbeat();   // we are still alive, trigger heartbeat so test execution won't time out
                    },
                    reportSpecResults: function (spec)
                    {
                        log('Jasmine reportSpecResults: ' + spec.description);

                        if(spec.results().failedCount>0)
                            jasmineTestSwarmResults.fail++;
                    },
                    log: function (str)
                    {
                        log('Jasmine says: ' + str);
                    }
                };

                window.TestSwarm.serialize = function () {
                    // take only the #wrapper and #html as a test result
                    remove('content');                  
                    return trimSerialize();
                };

                var jasmineEnv = jasmine.getEnv();
                jasmineEnv.addReporter(testSwarmReporter);

                log('Jasmine injected!');   
            }       
        },  

@seanzx85
Copy link

Any updates on this? I would really like to try this with our jasmine test suite.

@Krinkle
Copy link
Member

Krinkle commented Mar 12, 2013

I haven't had a chance to try it (other priorities). @seanzx85, perhaps you can give the patch a try in your TestSwarm install and let us know how it works out?

@seanzx85
Copy link

I will see what I can do. Might take a day or two.

@hijarian
Copy link

hijarian commented Apr 8, 2013

I tried it and in Chrome 25 jasmine runs tests in iframe as intended, but no results are being processed afterwards (job run just stays in pending state indefinitely).

EDIT:

Okay, sorry, guys, it was my fault, after re-checking I noticed that inject script was loading before the Jasmine. Now it runs OK. Only (minor, maybe) problem is displaying results for successful/errored job run. TrivialReporter tries to run again in the iframe showing the results and hangs.

@Krinkle Krinkle closed this as completed in d8114f8 Aug 8, 2017
@Krinkle
Copy link
Member

Krinkle commented Aug 8, 2017

This is now working per d8114f8.

Screenshots
screen shot 2017-08-07 at 21 28 30
screen shot 2017-08-07 at 21 28 41

@Krinkle Krinkle self-assigned this Aug 8, 2017
@Krinkle Krinkle added this to the 1.1.0 milestone Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

5 participants