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

Any documentation how to use the package would be highly appreciated #12

Open
igalep opened this issue Feb 4, 2014 · 7 comments
Open

Comments

@igalep
Copy link

igalep commented Feb 4, 2014

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

@supdegrave
Copy link

Hi igalep, did you ever resolve this issue? I'm trying to use jasmine.async and encountering the same error.

@patkujawa-wf
Copy link

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.

@patkujawa-wf
Copy link

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.

@leegee
Copy link

leegee commented Sep 23, 2014

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
#12 (comment).

@mxriverlynn
Copy link
Owner

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.

@patkujawa-wf
Copy link

@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);

@leegee
Copy link

leegee commented Sep 23, 2014

:) 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, 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);


Reply to this email directly or view it on GitHub
#12 (comment).

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

5 participants