iamchrismiller / grunt-casper

Run CasperJS Scripts/Functional Tests
Other
69 stars 38 forks source link

Passing arguments in test mode should be supported #24

Closed tysonnero closed 10 years ago

tysonnero commented 10 years ago

Can you enable support for passing arguments for tests as CasperJS supports this?

iamchrismiller commented 10 years ago

Unless I am unclear, I don't believe this is supported.

"The casperjs test command will treat every passed argument as file or directory paths containing tests. It will recursively scan any passed directory to search for .js or .coffee files and add them to the stack." - http://docs.casperjs.org/en/latest/testing.html

tysonnero commented 10 years ago

That is what the docs say... but

I'm running version 1.1.0 and am passing in cli arguments to my tests. Here's an example command: casperjs test tests.js --port=3000

In my test, I can use casper.cli.get('port') to get the value '3000'.

tysonnero commented 10 years ago

Ah ha...

http://docs.casperjs.org/en/latest/testing.html#options "Options are prefixed with a double-dash (--)"

I think that's the key for passing in custom args.

iamchrismiller commented 10 years ago

Options are indeed supported and use a prefix of -- I just added additional support for an "args" array in the grunt task configuration. Arguments can still be injected via the CLI as well..

alebedev commented 10 years ago

Ability to pass options via args has been lost in 0.3.6. Could you please restore it?

iamchrismiller commented 10 years ago

It's still there, https://github.com/iamchrismiller/grunt-casper/blob/master/tasks/lib/casper.js#L118

Along with the test , https://github.com/iamchrismiller/grunt-casper/blob/master/Gruntfile.js#L72

What issues are you running into?

alebedev commented 10 years ago

Forgot to add I was using args with test: true. I know it's not officially supported, but it's very useful for passing phantomjs options (such as --ignore-ssl-errors when testing via HTTPS with self-signed certificates) and generally making tests more configurable