These are chat archives for dareid/chakram

19th
Aug 2016
racerbajs
@racerbajs
Aug 19 2016 07:52
I'm back with one more question :) Don't think it's Chakram specific, but maybe someone know how to solve it.
I'm starting a windows backend process as part of Setup ( in before()), but the script gets stuck after the program is launched
so the tests are not run
Anyone knows why this is?
Daniel Reid
@dareid
Aug 19 2016 08:06
Hi, welcome back!
I would probably need more information before I could start to help
Have u got an example of ur before maybe?
racerbajs
@racerbajs
Aug 19 2016 08:09
Hi Daniel! I'm using the runas-win npm. It looks like this:

before('start service', function(){

return setup.startService();

});

startService = function (){
    runasPromise.default(executablePath, ['-v'], {hide:true, admin:true})
        .then(()=>console.log('finish'));

};
Daniel Reid
@dareid
Aug 19 2016 08:11
I am not familiar with runaspromise, but should u not be returning the result of that call from startService?
racerbajs
@racerbajs
Aug 19 2016 08:19
right, I tried to return it but no change in the script behavior
the .default method returns a promise: exports.default = (command, args, options) => new Promise((resolve, reject) => {
racerbajs
@racerbajs
Aug 19 2016 10:45
I'm launching the runasPromise with child_process instead and it seems to be working better =)
Daniel Reid
@dareid
Aug 19 2016 10:46
Oh really, that is good news
racerbajs
@racerbajs
Aug 19 2016 10:48
Yeah it's now dropping db, starting backend and then killing backend within the setup/teardown, really neat =)
Daniel Reid
@dareid
Aug 19 2016 10:49
Glad it is going well!
racerbajs
@racerbajs
Aug 19 2016 11:07
Is there anything similar compared to Protractors onPrepare function in Chakram/mocha that can be run before all specs ?
The have onPrepare and onComplete
Daniel Reid
@dareid
Aug 19 2016 11:08
Well u can put before and after outside of any describes which I think will do what u are after
racerbajs
@racerbajs
Aug 19 2016 11:09
Yes, it's just that I have several spec files
Daniel Reid
@dareid
Aug 19 2016 11:10
Are u running them all in a single mocha call?
racerbajs
@racerbajs
Aug 19 2016 11:10
That's the intention
But not doing that right now
Daniel Reid
@dareid
Aug 19 2016 11:11
Ok and each have a describe block at the root
racerbajs
@racerbajs
Aug 19 2016 11:11
Yes
Daniel Reid
@dareid
Aug 19 2016 11:11
Ok so if u have another file without a describe block, and instead just a before and after. They will run before and after all the other describe block a
Blocks*
I believe
racerbajs
@racerbajs
Aug 19 2016 11:13
Really, ok I'll try that. Thanks for the suggestion =)
racerbajs
@racerbajs
Aug 19 2016 11:33
Looks like it's working :)
Daniel Reid
@dareid
Aug 19 2016 11:34
Good stuff