Socket
Socket
Sign inDemoInstall

jasmine-node

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-node - npm Package Compare versions

Comparing version 1.0.22 to 1.0.23

25

lib/jasmine-node/async-callback.js

@@ -8,8 +8,11 @@ (function() {

var args = Array.prototype.slice.call(arguments, 0);
var specFunction = args.pop();
if (specFunction.length === 0) {
args.push(specFunction);
} else {
var timeout = null;
if (isLastArgumentATimeout(args)) {
timeout = args.pop();
}
if (isLastArgumentAnAsyncSpecFunction(args))
{
var specFunction = args.pop();
args.push(function() {
return asyncSpec(specFunction, this);
return asyncSpec(specFunction, this, timeout);
});

@@ -21,4 +24,14 @@ }

function isLastArgumentATimeout(args)
{
return args.length > 0 && (typeof args[args.length-1]) === "number";
}
function isLastArgumentAnAsyncSpecFunction(args)
{
return args.length > 0 && (typeof args[args.length-1]) === "function" && args[args.length-1].length > 0;
}
function asyncSpec(specFunction, spec, timeout) {
if (timeout == null) timeout = 1000;
if (timeout == null) timeout = jasmine.DEFAULT_TIMEOUT_INTERVAL || 1000;
var done = false;

@@ -25,0 +38,0 @@ spec.runs(function() {

@@ -1,2 +0,2 @@

var findit = require('findit');
var walkdir = require('walkdir');
var path = require('path');

@@ -18,3 +18,3 @@ var fs = require('fs');

var wannaBeSpecs = findit.sync(loadpath)
var wannaBeSpecs = walkdir.sync(loadpath)

@@ -21,0 +21,0 @@ for (var i = 0; i < wannaBeSpecs.length; i++) {

{
"name" : "jasmine-node"
, "version" : "1.0.22"
, "version" : "1.0.23"
, "description" : "DOM-less simple JavaScript BDD testing framework for Node"

@@ -23,3 +23,3 @@ , "homepage" : [ "http://pivotal.github.com/jasmine"

, "requirejs" : ">=0.27.1"
, "findit" : ">= 0.1.2"
, "walkdir" : ">= 0.0.1"
, "underscore" : ">= 1.3.1"

@@ -26,0 +26,0 @@ }

@@ -43,3 +43,28 @@ jasmine-node

async tests
-----------
jasmine-node includes an alternate syntax for writing asynchronous tests. Accepting
a done callback in the specification will trigger jasmine-node to run the test
asynchronously waiting until the done() callback is called.
```javascript
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
expect(body).toEqual("hello world");
done();
});
});
```
An asynchronous test will fail after 5000 ms if done() is not called. This timeout
can be changed by setting jasmine.DEFAULT_TIMEOUT_INTERVAL or by passing a timeout
interval in the specification.
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
done();
}, 250); // timeout after 250 ms
});
development

@@ -46,0 +71,0 @@ -----------

@@ -20,4 +20,23 @@ describe('async-callback', function() {

return env.currentRunner().results().totalCount > 0;
}, 6000);
runs(function() {
expect(env.currentRunner().results().failedCount).toEqual(1);
expect(firstResult(env.currentRunner()).message).toMatch(/timeout/);;
});
});
it("should accept timeout for individual spec", function() {
env.describe("it", function() {
env.it("doesn't wait", function(done) {
this.expect(1+2).toEqual(3);
}, 250);
});
env.currentRunner().execute();
waitsFor(function() {
return env.currentRunner().results().totalCount > 0;
}, 500);
runs(function() {

@@ -98,3 +117,3 @@ expect(env.currentRunner().results().failedCount).toEqual(1);

});
});
});
});

@@ -101,0 +120,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc