Code Monkey home page Code Monkey logo

jasmine's Introduction

A JavaScript Testing Framework

Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it's suited for websites, Node.js projects, or anywhere that JavaScript can run.

Upgrading from Jasmine 4.x? Check out the upgrade guide.

Contributing

Please read the contributors' guide.

Installation

There are several different ways to install Jasmine, depending on your environment and how you'd like to use it. See the Getting Started page for details.

Usage

See the documentation site, particularly the Your First Suite tutorial for information on writing specs, and the FAQ.

Supported environments

Jasmine tests itself across popular browsers (Safari, Chrome, Firefox, and Microsoft Edge) as well as Node.

Environment Supported versions
Node 18, 20
Safari 15-17
Chrome Evergreen
Firefox Evergreen, 102, 115
Edge Evergreen

For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us at the time of release. Other browsers, as well as older & newer versions of some supported browsers, are likely to work. However, Jasmine isn't tested against them and they aren't actively supported.

To find out what environments work with a particular Jasmine release, see the release notes.

Maintainers

Maintainers Emeritus

Copyright (c) 2008-2019 Pivotal Labs
Copyright (c) 2008-2023 The Jasmine developers
This software is licensed under the MIT License.

jasmine's People

Contributors

amavisca avatar dcthetall avatar elliot-nelson avatar gerg avatar havunen avatar infews avatar jbunton-atlassian avatar johnjbarton avatar ksvitkovsky avatar maxbrunsfeld avatar moonmaster9000 avatar nitobuendia avatar pimterry avatar pivotalangellist avatar pivotalops avatar prantlf avatar prather-mcs avatar ragaskar avatar rgould avatar rohitarondekar avatar sconover avatar seanparmelee avatar sgravrock avatar sheelc avatar tjarratt avatar uzitech avatar vhermannitk avatar voithos avatar xian avatar yopefonic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jasmine's Issues

Rhino?

One of your stated reasons for writing jasmine was that 'some frameworks require a browser'... can jasmine be run just w/ rhino?

thanks

support multiple config file

we should be able to support different config file when initializing

Jasmine::Config.new

perhaps something like

rake jasmine CONFIG=different_config_file_rather_than_jasmine.yml

This will be very useful to test a subset of js files without having to load all the javascript files all the time.

spec counting and reporting is inconsistent.

describe("The Runner", function() {
it("does not count a spec in the totalCount if there are no expectations (even though it does run)", function() {

})
it("does not have a count of skippped specs (it reports it as a pass)")
it("does not treat an it() statement without a body as a skip/pending (but reports a pass result)")
xit("does not report a result at all for skipped specs")
})

. . .
0 examples, 0 failures.

This should read

.---
4 examples, 0 failures, 3 pending.

I think a more consistent approach is to always report a result result for a spec whether it has expectations or not, and whether it was skipped or not. It's up to the view to decide how/if it wants to render it.

Also, I think that it() without a body should call xit() and behave just like

jasmine init "sinatra app"

hugo@hugo-desktop:~/bakedchat$ jasmine init
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- padrino-core/cli/rake (LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /home/hugo/bakedchat/Rakefile:4
from /home/hugo/.rvm/gems/ree-1.8.7-2010.02@chat/gems/jasmine-1.0.1.1/lib/jasmine/command_line_tool.rb:48:in load' from /home/hugo/.rvm/gems/ree-1.8.7-2010.02@chat/gems/jasmine-1.0.1.1/lib/jasmine/command_line_tool.rb:48:inprocess'
from /home/hugo/.rvm/gems/ree-1.8.7-2010.02@chat/gems/jasmine-1.0.1.1/bin/jasmine:6
from /home/hugo/.rvm/gems/ree-1.8.7-2010.02@chat/bin/jasmine:19:in `load'
from /home/hugo/.rvm/gems/ree-1.8.7-2010.02@chat/bin/jasmine:19

json test fails under 1.9.2

Running tests under rvm 1.8.7@jasmine-gem and rvm 1.9.2@jasmine-gem, with a fresh bundle install under each. All tests pass under 1.8.7, but the json_pure test fails under 1.9.2:

Failures:

  1. Jasmine bug fixes require 'json_pure' should not happen until SeleniumDriver is initialized, which is late enough that it won't conflict with Rails
    Failure/Error: json_is_defined.chomp.should == "nil"
    expected: "nil",
    got: "" (using ==)

    ./spec/bug_fixes_spec.rb:19:in `block (3 levels) in <top (required)>'

Backtrace for errors

Hi,

when an exception is thrown (and not caught), jasmine caught it and marks the spec as failed. It's the expected behaviour, but the backtrace is lost and it can be difficult to fix the spec.

Incorrect Rails dependency

Should require 'railties' as dependency instead of 'rails', as the latter pulls in ActiveRecord, ActiveResource, and ActionMailer, none of which I need or want.

Builtin support node.js

The project you mention on the docs site is very outdated. I published a fork with a simple example, but it would be nice to have it out of the box, and supported on the latest version.

declarationError is lost; instead I get the error "jasmine.Suite() required"

If I have my own js error inside my describe, it is lost and instead I get the error "jasmine.Suite() required"

My simple test:

describe('my own js error', function() {
    var foo = nonExistent.obj;
    it('should throw my error', function() {
    });
});

in jasmine, it is in this block:

jasmine.Env.prototype.describe = function(description, specDefinitions) {
    var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);

    var parentSuite = this.currentSuite;
    if (parentSuite) {
        parentSuite.add(suite);
    } else {
        this.currentRunner_.add(suite);
    }

    this.currentSuite = suite;

    var declarationError = null;
    try {
        specDefinitions.call(suite);
    } catch(e) {
        declarationError = e;
    }

    this.currentSuite = parentSuite;

    if (declarationError) {
        this.it("encountered a declaration exception", function() {
            throw declarationError;
        });
    }
    return suite;
};

==> I get into the if (declarationError) block at the end of this implementation, but within there, this.it('encountered...') tries to create a new spec, which has no currentSuite, which causes the error in my subject line.

toHaveBeenCalledWith does not succeed on correct response (or error is incorrect)

Test:

echo.events.trigger("NAME_REPLY", {command: "NAME_REPLY", args: ["wr:1",
  {"1":{"user_id":"1","mode":{"v":1},"attendee_id":"67"},
   "2":{"user_id":"29","mode":{"v":1},"attendee_id":"1"}}
  ]});

expect(aRoom.listUI.add).toHaveBeenCalledWith(["1"], ["29"]);

Output:

Failed: A Room Controller loads users and their states on NAME_REPLY.
Expected spy to have been called with [ [ '1' ], [ '29' ] ] but was called with [ [ '1' ], [ '29' ] ]
in http://127.0.0.1:53446/jasmine/jasmine.js:94

Rails 3 support?

Does jasmine currently support rails 3? When I try and run 'rails generate jasmine' I get the error of:

Could not find generator jasmine.

Any help is greatly appreciated.

Reporter resultsForSpecs reports specs as passed even when skipped

Via the rspec runner in the gem project, it appears that when you run a specific subset set of specs via the ?spec= query string param, even though the page lists "1 spec run, 0 failed", the resultsForSpec/s returns all other specs marked as passed, even though they were not run at all.

toHaveBeenCalledWith fails with multiple arguments

First attempt:

spyOn(Foo, 'bar');
Foo.bar('baz', 'qux');
expect(Foo.bar).toHaveBeenCalledWith('baz', 'qux');

Expected spy to have been called with [ [ 'baz', 'qux' ] ] but was called with [ 'baz', 'qux' ].

Second attempt:

spyOn(Foo, 'bar');
Foo.bar('baz', 'qux');
expect(Foo.bar).toHaveBeenCalledWith(['baz', 'qux']);

Expected spy to have been called with [ [ 'baz', 'qux' ] ] but was called with [ [ 'baz', 'qux' ] ].

I believe the problem is that Jasmine is using a simple == or === comparison, rather than comparing the elements of arguments individually.

"jasmine init" deleted my code

I had an /app with some javascript code I was starting to cover with jasmine specs.

When I wrote "jasmine init" in the project folder, it had deleted /app content. And it had deleted the .git folder also...

Is this supposed to do so?

documentation of 'not' in matchers

Documentation incorrect:

Expectation Matchers

Jasmine has several built-in matchers. Here are a few:

...

wrong

Every matcher's criteria can be inverted by prepending .not:

expect(x).not.toEqual(y); compares objects or primitives x and y and passes if they are not equivalent

right?

Every matcher's criteria can be inverted by inserting Not in the matcher function name after to:

expect(x).toNotEqual(y); compares objects or primitives x and y and passes if they are not equivalent

CoffeeScript and Rails integration (possibly with Barista)

Hi, I was wondering if there's any way to integrate Jasmine with CoffeeScript (and, possibly with Barista, Rails CoffeeScript support gem) and write tests in CoffeeScript rather than javascript without too much of a headache? Would appreciate if you point me to the right direction.

Request: JsApiReporter: Add execution time elapsed

The TrivialReporter displays the total execution time following the test run, but so far as I can discern, this info isn't available from the JsApiReporter. It'd be great to have this for users of the jasmine-maven-plugin, who are now seeing Jasmine test reports gathered by their CI environments; this information would enable them to track execution time of Jasmine specs over time.

toString fails in IE8 sometimes

We have an edge case where on a failing spec there is no "toString" method on a property.

In order to test it feel free to pull http://github.com/mootools/mootools-core - init all submodules and open the Specs folder in IE from a local server.

Replacing the line http://github.com/pivotal/jasmine/blob/master/lib/jasmine.js#L847 with the code below fixes the issue:

  mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString ? b[property].toString() : '' + b[property]) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString ? a[property].toString() : '' + a[property]) : a[property]) + "' in actual.");

Test window jumps when I hit "command"

I'm running Jasmine 1.0.1.1 in Chrome 8.0.552.215 on OSX.

Every time I hit the "command" key when the Jasmine tab has focus (e.g. in order to command-tab out of the window) the view pops out of the browser to the top-left of my screen, then returns.

this pointer is wrong

Reopen for the accident closed #issue17

I have created a test page:
http://lifesinger.github.com/lab/2010/jasmine-issue17-test.html

Jasmine reports error:
TypeError: Object [object DOMWindow] has no method 'methodA'

If I change line25 to:

expect(TestObject.methodB()).toBe('a');

All will be ok.

But in my actual test code, I want to define methodB = TestObject.methodB to save some typing.

I expect jasmine don't change "this" to window, it's annoying:(

Waiting for you answer ^o^

Add instance mocks

I'd like to be able to mock out an object created via new. Perhaps something like

mockClass('Image');
var i = new Image();
i.src = '/some_url';
expect(Image.lastInstance().src).toEqual("/some_url");

or maybe

mockClass(Vehicle, 'Car');
var c = new Vehicle.Car();
c.start();
expect(Vehicle.Car.anyInstance().start).toHaveBeenCalled();

I might also imagine being able to access the original definition of the "class" (function) via StubbedFunction.originalDefinition.

Misleading error message for string expectation

The test below is reporting a misleading failure:
"Expected spy to have been called with [ 'bar' ] but was called with [ [ 'baz' ] ]"

This implies that we called someFunction(['baz']) when actually we called someFunction('baz');

TEST:

it('should properly compare strings', function(){
  var test = { foo: function(){} };
  spyOn(test, 'foo');

  test.foo('baz');
  expect(test.foo).toHaveBeenCalledWith('bar'); 
});

STACK TRACE:

Error("Expected spy to have been called with [ 'bar' ] but was called with [ [ 'baz' ] ]")@:0 ([object Object])@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:94 ("bar")@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1143 ()@http://localhost:8888/__spec__/javascripts/views/creatives/markup/_facebook_like_spec.js:49 ((function () {if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {completedSynchronously = true;return;}if (self.blocks[self.index].abort) {self.abort = true;}self.offset = 0;self.index++;var now = (new Date).getTime();if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {self.env.lastUpdate = now;self.env.setTimeout(function () {self.next_();}, 0);} else {if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {goAgain = true;} else {self.next_();}}}))@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:968 ()@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1739 ((function () {spec.finish(onComplete);}))@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1692 ((function () {if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {completedSynchronously = true;return;}if (self.blocks[self.index].abort) {self.abort = true;}self.offset = 0;self.index++;var now = (new Date).getTime();if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {self.env.lastUpdate = now;self.env.setTimeout(function () {self.next_();}, 0);} else {if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {goAgain = true;} else {self.next_();}}}))@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:2018 ()@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1739 ((function () {self.finish(onComplete);}))@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1692 ((function () {if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {completedSynchronously = true;return;}if (self.blocks[self.index].abort) {self.abort = true;}self.offset = 0;self.index++;var now = (new Date).getTime();if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {self.env.lastUpdate = now;self.env.setTimeout(function () {self.next_();}, 0);} else {if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {goAgain = true;} else {self.next_();}}}))@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:2163 ()@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1739 ()@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1735 ((function () {if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {completedSynchronously = true;return;}if (self.blocks[self.index].abort) {self.abort = true;}self.offset = 0;self.index++;var now = (new Date).getTime();if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {self.env.lastUpdate = now;self.env.setTimeout(function () {self.next_();}, 0);} else {if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {goAgain = true;} else {self.next_();}}}))@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:2120 ()@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:2164 ()@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1749 (49)@http://localhost:8888/__JASMINE_ROOT__/lib/jasmine.js:1729 

Generated rake-Tasks should ignore missing Jasmine

Hi there,

the generated rake task loading the Rake tasks from Jasmine should not throw an exception if it is unable to load jasmine.
In production environments you often have a "test"-group in your Gemfile, with gems not installed. Though you still want to use rake for Cronjobs and stuff.

You should generate the File like this:

begin
require 'jasmine'
load 'jasmine/tasks/jasmine.rake'
rescue LoadError
puts "jasmine not found"
end

Best, Tobias

afterEach is called twice before an async test is run

An example can be found in the JustKidding project. I will try to reduce the issue to a smaller test case, but for now,

  1. clone git://github.com/jamesarosen/JustKidding.git
  2. check out e5f894168eed8c010ddf286d5d712123a1c6f6d9
  3. run just the group "when there are more elements..."

Console output has to "afterEach" statements first, then a "beforeEach" statement, then an "it" statement.

this pointer is reset to window

var TestObject = {

methodA: function() {},

methodB: function() { this.methodA(); }

};

....

describe('....', function() {

var A = TestObject.A,B = TestObject.B;

it('....', function() {
    B();
});

});

will throw error in 'methodB: function() { this.methodA(); }', because "this" is pointed to window!

looking forward to fix it quickly! thx!

jasmine-gem: don't load json/pure

I've added Jasmine gem to my app recently; I'm also using Resque. The problem is, Resque requires plain json, and Jasmine requires json_pure. So I've got two JSONs now in my project, which causes several warning messages and some failing tests...

Second problem is that even if I remove Resque, json_pure is still loaded twice, because ActiveSupport loads it once as require 'json' and then Jasmine loads it again as require 'json/pure'.

The solution to the second problem is to change require 'json/pure' to require 'json' in Jasmine. The json_pure gem will still be loaded because it will be in the Gemfile, but it won't be loaded twice.

A better, long term solution would be to switch to the multi_json gem in code and in gemspec (http://github.com/intridea/multi_json). If both Jasmine and Resque used that, I could choose any json backend I want and it would work with both.

Conditionals for describe or it

I'd like to see conditionals for skipping tests to be attached to the it or describe functions. The reason would be to enable testing on parameters that can't be set by JavaScript (such as navigator.locale), but requires environmental changes (outside the scope of JavaScript). One such example would be to test L10n or i18n issues.

This could be solved with letting it or describe have a builder method (such as when). Here is one example that tests with turkish 'i':

function itIsTurkishLocale() {
    return navigator.language == 'tu';
}

it('should pass the Turkish test', function() {
    var result = myObj.doIt(upperCaseDottedEye);
    expect(result).toEqual(lowerCaseDottedEye);
}).when(itIsTurkishLocale);

The function when should be able to take on either a conditional (true/false) or a function that can return a conditional. If the conditional is true, the test should run. If it is false, it should skip.

Blank page after running tests.

Visiting the test page for a running Jasmine server displays test results briefly (for about half a second), then the entire page goes blank.

combine jasmine-gem into this repository

When I first started checking out Jasmine, I grabbed the repo, and was delayed a bit when I noticed that I didn't have the gem included. How about combining the two, just carefully leaving files that don't belong in the gem out of the gemspec? This repo already includes things that aren't part of the core, like the javascript documentation.

If part of it is that you plan to have support for other server-side languages in the future, I think having ruby at the root would still be the way to go. That way, if a python implementation got added, a rake task for running the python tasks (including tests) could be added. That way, someone who wanted to maintain consistency among the alternate implementations could easily run tests on both, and someone who's just into python could cd to that directory and build the egg. (Using this scheme, a python implementation of the server-side component could be in a separate repo using submodules, or not. Pythonistas would have to check out jasmine with the submodules to get the javascript code and documentation, and the Python build files would include references to code in the outer repo. For example, if the gem were in python/, it would copy ../src/*.js into its build directory. It would also tell users to get the outer gem if it didn't find it in the parent directory.)

Finally, something that could be done right away to make things easier: add a homepage on github to jasmine-gem (currently it's empty), so people browsing to it can go straight to the page about jasmine, without scrolling down:

http://github.com/pivotal/jasmine-gem

"jasmine init" deleted my code

I had an /app with some javascript code I was starting to cover with jasmine specs.

When I wrote "jasmine init" in the project folder, it had deleted /app content.

Is this supposed to do so?

specify a message when a custom matcher fails

I have a immutable Value Object class:´

var Tile = function(x, y) {
    this.x = function() { return x }
    this.y = function() { return y }
}

and a matcher for it:

function toEqualToTile(expected) {
    return (this.actual.x() == expected.x()) && (this.actual.y() == expected.y())
}

If the custom matcher fails, I get this message:
Expected { x : Function, y : Function } to equal to tile { x : Function, y : Function }.

which is not very informative. Could you add a possibility to specify my own message on failure?

Code Coverage

It would be immensely helpful if Jasmine had a way to generate code coverage reports. Is anything like this planned for the future?

jasmine assumes existence of global window object

I understand that one of the design goals of jasmine is to be host agnostic. However, evaluating it in a bare javascript interpreter yields the following error:

ReferenceError: window is not defined: jasmine-0.10.3.js:49

You may want to detect if window exists before remapping its functions.

cheers,
Charles

Ability to spy on functions multiple times.

Right now, Jasmine does not allow me to set up multiple spies on the same function. For instance, given some constructor:

NavNet.Controller.LoginController = function LoginController (navNet) {
   this.loginService = navNet.getService("loginService");    
   this.storageService = navNet.getService("storageService");
};

My spy setup would looks something like this:

...

beforeEach(function() {
        framework = new NavNet();
        loginService = new NavNet.Services.LoginService();
        storageService = new NavNet.Services.StorageService();

        spyOn(framework, "getService").andReturn(loginService);
        spyOn(framework, "getService").andReturn(storageService);

        sut = new NavNet.Controllers.LoginController(framework);
    });

...

Maybe not the best example, as I actually inject the services I need, but it illustrates a point: the second spy on "getService" will fail as Jasmine will complain that "getService" is already being spied on. Fair enough. It would be nice if I was able to set up spies on multiple function calls, differentiated by parameters. Maybe something like:

spyOn(framework, "getService").with("loginService").andReturn(loginService);

Unless, of course, there is a way I am unaware of that will accomplish this >8)

Stackoverflow error

Hi

I am getting Exceeded stack depth error while executing the maven targets (test). I dont have any clue what is happening. Could you please point in the right direction.

com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError
SEVERE: runtimeError: message=[Exceeded maximum stack depth] sourceName=[script
in file:/C:/oasisNew/target/jasmine/SpecRunner.html from (173, 33) to (2594, 11)
] line=[2565] lineSource=[null] lineOffset=[0]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] : java.lang.RuntimeException: com.gargoylesoftware.htmlunit.ScriptExcepti
on: Exceeded maximum stack depth (script in file:/C:/oasisNew/target/jasmine/Spe
cRunner.html from (173, 33) to (2594, 11)#2565)
There was a problem executing Jasmine specs

com.gargoylesoftware.htmlunit.ScriptException: Exceeded maximum stack depth (scr
ipt in file:/C:/oasisNew/target/jasmine/SpecRunner.html from (173, 33) to (2594,

Regards

WaitsForBlock sometimes doesn't

My tests are hanging when I use waitsFor.
Here's a failing test you can add to WaitsForBlockSpec.js, under describe("if latchFunction returns false":

it('spec should fail with the passed message', function () {
  spyOn(spec, 'fail');
  var block = new jasmine.WaitsForBlock(env, 100, function() {return false}, message, spec);
  block.execute(onComplete);
  waits(150)
  expect(spec.fail).toHaveBeenCalled();
  var failMessage = spec.fail.mostRecentCall.args[0].message;
  expect(failMessage).toMatch(message);
  expect(onComplete).wasNotCalled();
});

global spyOn does not accept / honor ignoreMethodDoesntExist

jasmine.Spec.prototype.spyOn accepts three parameters: obj, methodName, ignoreMethodDoesntExist

global spyOn function only accepts two parameters: obj, methodName

So if one wishes to spy on a non-existent method, one may not use the global spyOn method but must instead grab and directly call jasmine.getEnv().currentSpec.spyOn

geminstaller doesn't work

geminstaller still points to github for gems. I'm not sure if all these gems are on gemcutter. I can't find jsdoc-helper. I admittedly stopped there. Can we get this working? I'm going to try to build all these gems by hand, but some people on the team are not going to be keen on doing that.

Jasmine does not clear scheduledFunctions between mock clock invocations

Hi guys,

We noticed yesterday that between invocation of jasmine.Clock.useMock(), Jasmine does not reset the list of scheduledFunctions. This was the cause of some test pollution for us, where things scheduled in previous tests were still running in later tests.

To see the bug, in useMock(), output the list of scheduledFunctions. You'll see that functions scheduled in previous tests are still pending execution.

We worked around this by adding to our SpecHelper.js:

afterEach(function () {
// Jasmine's mock clock does not remove scheduled functions between specs,
// which allows for test pollution.
jasmine.Clock.defaultFakeTimer.reset();
});

...although the real fix is probably to ensure FakeTimer.reset gets called at each useMock.

Thanks!

Rob

jasmine-gem: Flexible path to jasmine.yml

jasmine-gem
It would be great if jasmine.yml could be loaded using a Dir glob string ("**/jasmine.yml") from the project root or from an environment variable (as mentioned by Rajan in the google group) so that any folder structure is supported.

describe(<non-string>, ...) causes cryptic errors

describe(String, function() {
  ...
});

The first argument to describe should be converted to a string in a useful way, a la rspec. In particular it would be useful to pass constructor functions and have them read as a type name.

Strange error output

Test:
it("should report a strange error", function(){
spyOn(TestMe, 'saySomething');
TestMe.saySomething('a string', {goodbye: 'world'});
expect(TestMe.saySomething).toHaveBeenCalledWith('a string', {hello: 'world'});
});

Supporting class (using jQuery):
(function($) {
TestMe = {};
TestMe.saySomething = function(aString, aHash) {
alert(aString);
};
}(jQuery));

When I run the test I get the following output:
Expected spy to have been called with [ 'a string', { hello : 'world' } ] but was called with [ [ 'a string', { goodbye : 'world' } ] ]

I would expect the failure and it is easy to see why this test fails when you have a short string of failure text...what I wouldn't expect was the "[[" "]]" around the stuff that the method was actually called with.

If you have a big error message then you get caught up on the [[ ]] and lose sight that you are calling the method with the wrong arguments.

Is there a reason that when you mess up a toHaveBeenCalledWith() expectation you get the [[ ]] instead of [ ]?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.