actionHero now running with Grunt (goodbye Jake)

194 views
Skip to first unread message

Evan Tahler

unread,
Dec 18, 2013, 12:48:26 AM12/18/13
to action...@googlegroups.com
Hi Everyone!

As of tonight, the master branch of actionHero uses grunt as its script-runner rather than Jake.  We made the switch due to Grunt's overwhelming popularity in the node/js community so that it would be easier for new developers to feel comfortable with the actionHero ecosystem.  Grunt and Jake serve a similar purpose (with similar functionality) within actionHero to run tests and provide a CLI for various commands (saving and loading the cache, enqeuing periodic tasks, etc).

A huge shoutout to Github user @nullivex for doing most of the work in this pull request.  He's added Grunt's linting tools and other helpers to the project which will make actionHero even better.

- More information on Grunt can be found here http://gruntjs.com/

This will be deployed in the next actionHero release. 

Brian Corrigan

unread,
Dec 18, 2013, 7:46:17 AM12/18/13
to Evan Tahler, action...@googlegroups.com
Really great change guys!!
--
You received this message because you are subscribed to the Google Groups "actionHero.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


--
Brian Corrigan
MadGlory Interactive
http://www.madglory.com
Tw: @madgloryint
Ph: 518.867.1439

David S Taylor

unread,
Dec 28, 2013, 10:36:13 PM12/28/13
to action...@googlegroups.com
I'd like to upgrade my 7.2.0 project to 7.3.0. Is there anything special required to convert my project to grunt, or is it as simple as 'npm update actionHero'

Thanks

Evan Tahler

unread,
Dec 28, 2013, 11:44:18 PM12/28/13
to David S Taylor, action...@googlegroups.com
You'll need to bump actionHero's version in package.json and then 'npm install'

Take a look at what new project generation does https://github.com/evantahler/actionHero/blob/master/bin/methods/generate.js. Grunt was also added to package.json. The template gruntfile included with new projects is here https://github.com/evantahler/actionHero/blob/master/grunt/actionHero_gruntfile.js

Be sure to delete Jakefile and jakelib :)
--
You received this message because you are subscribed to the Google Groups "actionHero.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


--
--
 Evan Tahler
 412.897.6361
 evant...@gmail.com


David S Taylor

unread,
Dec 30, 2013, 2:01:58 PM12/30/13
to action...@googlegroups.com, David S Taylor
Thanks, think I got it basically working. For instance I can type 'grunt list' and it prints a list of all of my actions

The Action Hero gruntfile.js doesn't seem like a typical Gruntfile.js. For example, I don't see any initialization like the wrapper function "module.exports = function(grunt)" or the typical "grunt.initConfig". I'd like to start integrating some additional tasks like a testing framework. Is that recommended, or is this gruntfile.js only for core ActionHero functionality?

To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-js+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Evan Tahler

unread,
Jan 3, 2014, 3:13:51 AM1/3/14
to David S Taylor, action...@googlegroups.com
The gruntfile actionHero generates for a new project is meant to be a simple starting point for you to build from.  There are no configs to initialize, as actionHero's options come from its own `config.js` files.  

actionHero uses the mocha test suite, and there are integrations between grunt and mocha.  Check out how actionHero's internal grunt file handles it.  However, you don't need to integrate mocha with your test suit if you don't want to.  Setting up `npm test` in your package.json to call "mocha /path/to/tests" works just fine.  



To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.

David S Taylor

unread,
Jan 3, 2014, 5:13:17 AM1/3/14
to action...@googlegroups.com, David S Taylor
Cool thanks. I am also using Mocha in my ActionHero project here, but only for the data services layer - simply typing the command 'mocha' to run the tests. I will try to see if I can get 'grunt test' to work in my project next. 

I was wondering how one goes about testing ActionHero actions, and if it is even recommended to write test suites for actions ...

Evan Tahler

unread,
Jan 3, 2014, 1:38:23 PM1/3/14
to David S Taylor, action...@googlegroups.com
Testing is usually a good thing to do!  

Some other folks are working on exposing a way to test your actions via a middleware and not require a 'full' server boot, for now, it's fine to boot a server in the TEST environment and hit it.  I personally like to use the request library for HTTP testing.

Check out how the tutorial project configures its tests:
- configure `npm test` to run your test suite within the TEST env https://github.com/evantahler/actionHero-tutorial/blob/master/package.json#L30



Evan Tahler

unread,
Jan 5, 2014, 1:21:21 AM1/5/14
to David S Taylor, action...@googlegroups.com
As lots of folks are asking for advice with testing, I built in some spec helpers to actionHero.  Check out release v7.4.0.




David S Taylor

unread,
Jan 6, 2014, 5:31:53 PM1/6/14
to action...@googlegroups.com, David S Taylor
Looks like you've been busy. I've upgrading to your new 7.4.0 and could successfully (and easily) write a mocha test to test out my actions like described here:

https://github.com/evantahler/actionHero/releases/tag/v7.4.0

Works great!  I think your examples from the previous response to this question, using the Request library, is an alternative and valid way to test as well. I am thinking I could even combine the two...

If the API requires a sessionId (cookie) to be passed in, I assume that leaves only the Request library solution. Then again, looking at specHelper's runAction(actionName, input, next), it seems like there might be a possibility of scaffolding a connection with specHelper.connection, and using the randomly generated id there as a 'cookie'

Evan Tahler

unread,
Jan 6, 2014, 5:37:03 PM1/6/14
to David S Taylor, action...@googlegroups.com
Yeah, anything regarding 'cookies' or 'headers' really only makes sense for clients of the 'web' type.  If you want to test those, I would suggest sticking with request.  Request can have a 'sticky' cookie jar, so you can treat it like a browser with a consistent session if you wish. 



David S Taylor

unread,
Jan 6, 2014, 5:49:05 PM1/6/14
to action...@googlegroups.com, David S Taylor
This approach did work for me, although it requires wrapping each test with a login action. Once logged in, I can rely on the connection.id to be set for me (my login action sets the connection id - go that from one of your examples)

    it('lookup', function(done){
        api.specHelper.runAction('login', {username: 'dtaylor', password: '******'}, function(response, connection){
            (connection.id === null).should.be.false
            response.auth.should.be.true
            api.specHelper.runAction('usersLookup', {username: 'dtaylor'}, function(response, connection){
                response.user.firstName.should.equal('David')
                done();
            });
        });
    });

Tried to optimize by moving the login function to the before() method, but there is no connection at that point

Paul Tiseo

unread,
Jan 6, 2014, 7:45:15 PM1/6/14
to action...@googlegroups.com

Of course, the new hotness is apparently gulpjs.
http://www.100percentjs.com/just-like-grunt-gulp-browserify-now/

Bryan Tong

unread,
Jan 6, 2014, 8:00:50 PM1/6/14
to Paul Tiseo, action...@googlegroups.com
Browserify is definitely cool but it takes a while to get it to actually output usable browser code. Havent ran into gulp yet.


--
You received this message because you are subscribed to the Google Groups "actionHero.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
eSited LLC

David S Taylor

unread,
Jan 6, 2014, 9:52:43 PM1/6/14
to action...@googlegroups.com, David S Taylor
It seems chaining the actions did not allow for passing connections. The connection.id was getting reset for each runAction call, since runAction does not allow passing both parameters and a specHelper.connection(). Would need a runAction API that took four parameters

Evan Tahler

unread,
Jan 6, 2014, 11:25:35 PM1/6/14
to David S Taylor, action...@googlegroups.com
If you are using request to make "real" HTTP calls, you need to define a 'cookie jar' to use in each request.  Check their docs (bottom of the read me).  If you want to keep the same connection using the specHelper between tests, you need to pass it to each test:

  describe('persistent test connections', function(){

    var conn;
    var connId;

    it('can make a requset with a spec\'d connection', function(done){
      conn = new api.specHelper.connection();
      conn.params = {
        key: 'someKey',
        value: 'someValue',
      }
      connId = conn.id;
      api.specHelper.runAction('cacheTest', conn, function(response, connection){
        response.messageCount.should.equal(1);
        connection.messages.length.should.equal(2);
        connId.should.equal(connection.id);
        done();
      });
    });

    it('can make second request', function(done){
      api.specHelper.runAction('randomNumber', conn, function(response, connection){
        response.messageCount.should.equal(2);
        connection.messages.length.should.equal(3);
        connId.should.equal(connection.id);
        done();
      });
    });
  });


There was a bug around this, and I've got a fix ready and I'll release a new version with this later tonight. 



David S Taylor

unread,
Jan 7, 2014, 12:42:15 AM1/7/14
to action...@googlegroups.com, David S Taylor
> If you are using request to make "real" HTTP calls, you need to define a 'cookie jar' to use in each request.  Check their docs (bottom of the read me).  

Yes, I was switching my integration tests over to using 'request', but when I saw the release of 7.4.1, I went back to trying specHelper.runAction

With 7.4.1 my integration tests are now holding the connection id properly and passing. Included below is an example integration test based on specHelper.runAction. Notice Im just resetting the parameters prior to each runAction call, and leaving the connection id the same, which my session initializer can then validate the session against. 

Works great, thanks for the super-fast fix and release !!!

   it('add, modify and delete User', function(done){
        api.specHelper.runAction('login', {username: userName, password: password}, function(response, connection){
            (connection.id === null).should.be.false
            response.auth.should.be.true
            connection.params = createUser()
            api.specHelper.runAction('usersInsert', connection, function(response, connection){
                response.user.firstName.should.equal('Tammy')
                connection.params = modifyUser()
                api.specHelper.runAction('usersModify', connection, function(response, connection){
                    response.user.firstName.should.equal('Terry')
                    connection.params = {username: 'testUser'}
                    api.specHelper.runAction('usersDelete', connection, function(response, connection){
                        should.strictEqual(undefined, connection.err)
                        api.specHelper.runAction('usersLookup', {username: 'testuser'}, function(response, connection){
                            should.strictEqual(undefined, response.user)
                            done();
                        });
                    });
                });
            });
        });
    })
});
Reply all
Reply to author
Forward
0 new messages