dalekjs / dalek

[unmaintained] DalekJS Base framework
MIT License
695 stars 63 forks source link

Pass custom parameters to dalek command #164

Open naoyteruh opened 8 years ago

naoyteruh commented 8 years ago

Hi,

Is there a way to pass parameters to "dalek" command ? I would like to switch my test suite between environments.

dalek mytest.js myparameter

where my parameter would refer to my development environment, testing environment etc...

Regards,

rafis commented 8 years ago

I don't exactly understand question, but maybe this will help (you can use *nix environment to pass params):

NODE_ENV=testing PARAM1=VALUE1 dalek mytest.js

In mytest.js add following:

module.exports = {
    'Page title is correct': function (test) {
        test.open('http://myfront.megaproject.consul');
        if ('VALUE1' == process.ENV.PARAM1) {
            test.title().is('My Title - Staging');
        } else {
            test.title().is('My Title');
        }
        test.done();
    }
};

Notice how process.ENV.PARAM1 used to access to PARAM1 which has VALUE1.