Any documentation how to use the package would be highly appreciated
Hi, I'm using Jasmine which is based on Protractor.
Could you please provide some instructions how to use the async package with described env. currently I'm getting ReferenceError: AsyncSpec is not defined
Thanks
Hi igalep, did you ever resolve this issue? I'm trying to use jasmine.async and encountering the same error.
I put together a video showing this librarie's usage in a requirejs project - maybe that will help :). My strategy was to copy the code into my code base instead of trying to bower or npm install it as an external dependency.
Oh, and here's an example patch in an open source project - Use jasmine.async lib to simplify async tests. by patkujawa-wf · Pull Request #23 · WebFilings/wf-common.
I'd use bower install -D or npm install --save-dev because it is an external dependency!
On 22/09/2014 17:20, Pat Kujawa wrote:
I put together a video showing this libraries usage in a requirejs project https://www.youtube.com/watch?v=3nE2rVk8T8o&list=PLcqHb3lGaZxEAMCCT0OEmku4jaZyTZOH5#t=440
- maybe that will help :). My strategy was to copy the code into my code base instead of trying to bower or npm install it as an external dependency.
— Reply to this email directly or view it on GitHub https://github.com/derickbailey/jasmine.async/issues/12#issuecomment-56398816.
Hi everyone - first off, sorry i didn't see this issue before! i've been buried under github notifications forever and am trying to dig out.
FWIW, there's a nodejs specific package for this at https://github.com/derickbailey/node-jasmine-async - i realize it's a bad idea to have two separate repositories for this... i was in a rush when i put that second one together. i don't have a specific package for bower or anything else, though... cause honestly, i don't really use this package that much anymore. w/ Jasmine v2.x, this this functionality is built in.
If anyone here would like to take over the jasmine.async project, please let me know. I'd be happy to give you access to the repository, or have it transfered to your account, so it can be properly managed.
@leegee I realize that it is an external dep, but when all the necessary code is ~50 lines, it doesn't make sense to pull down the entire repo (as bower and npm will do unless given instructions otherwise). Honestly, just paste this into your app, adjust the module structure to what you need, and go from there :)
// Jasmine.Async, v0.1.0
// Copyright (c)2012 Muted Solutions, LLC. All Rights Reserved.
// Distributed under MIT license
// http://github.com/derickbailey/jasmine.async
this.AsyncSpec = (function(global){
// Private Methods
// ---------------
function runAsync(block){
return function(){
var done = false;
var complete = function(){ done = true; };
runs(function(){
block(complete);
});
waitsFor(function(){
return done;
});
};
}
// Constructor Function
// --------------------
function AsyncSpec(spec){
this.spec = spec;
}
// Public API
// ----------
AsyncSpec.prototype.beforeEach = function(block){
this.spec.beforeEach(runAsync(block));
};
AsyncSpec.prototype.afterEach = function(block){
this.spec.afterEach(runAsync(block));
};
AsyncSpec.prototype.it = function(description, block){
// For some reason, `it` is not attached to the current
// test suite, so it has to be called from the global
// context.
global.it(description, runAsync(block));
};
return AsyncSpec;
})(this);
:) Yeah, I know, but then I do that in 10 projects and then have 10 places to update when the code is improved, so a short-term saving becomes a long- term drag!
On 23/09/2014 21:21, Pat Kujawa wrote:
@leegee https://github.com/leegee I realize that it is an external dep, but when all the necessary code is ~50 lines, it doesn't make sense to pull down the entire repo (as bower and npm will do unless given instructions otherwise). Honestly, just paste this into your app, adjust the module structure to what you need, and go from there :)
// Jasmine.Async, v0.1.0 // Copyright (c)2012 Muted Solutions, LLC. All Rights Reserved. // Distributed under MIT license // http://github.com/derickbailey/jasmine.async this.AsyncSpec = (function(global){
// Private Methods // ---------------
function runAsync(block){ return function(){ var done = false; var complete = function(){ done = true; };
runs(function(){ block(complete); }); waitsFor(function(){ return done; }); };}
// Constructor Function // --------------------
function AsyncSpec(spec){ this.spec = spec; }
// Public API // ----------
AsyncSpec.prototype.beforeEach = function(block){ this.spec.beforeEach(runAsync(block)); };
AsyncSpec.prototype.afterEach = function(block){ this.spec.afterEach(runAsync(block)); };
AsyncSpec.prototype.it = function(description, block){ // For some reason,
itis not attached to the current // test suite, so it has to be called from the global // context. global.it(description, runAsync(block)); };return AsyncSpec; })(this);
— Reply to this email directly or view it on GitHub https://github.com/derickbailey/jasmine.async/issues/12#issuecomment-56583348.