3

I'm not sure if this is possible or not, but I'm wondering if it's possible to use a grunt task argument to dynamically require another file.

Background:

I'm using mocha-casperjs to webdrive and test client websites. Each test is defined by json object that lists what pages to view and what tests to run on those pages. Each type of test is defined in my testing logic. Right now the list and the testing logic are in the same file. Each client has it's own file. The testing logic is repeated among every file.

What I want to do:

I want to separate my logic and client test list into separate files, where there is only one testing logic file and several client files. Then run a grunt task:

$ grunt test:clientName

Then somehow, grunt passes clientName to my testfile.js, maybe inside a require() function? The end result being, the test is run with that client's list of tests.

Is this possible? Note, the testfile.js is a casperjs test file, which means it runs off phantom, not node, so many node utilities are not available.

AdamPat
  • 101
  • 10

0 Answers0