Closed charandas closed 10 years ago
Maybe, is it that you just don't want to include that 1-liner in all your tests?
That module is really boring :P s -> { type: 'xpath', path: s }
I guess, it goes back to reducing code-duplication. Depending on casperjs definition would be philosophically closer to good development for me.
Yeah true, the CLI is intended to wire up the common use cases, leaving the core more pure for programmatic usage. Being that it already looks for chai
and casper-chai
, I can see it pulling up this module too. Yup send a PR.
Ok. Will send it soon. @nathanboktae
I do have one more related question: why are the casperjs
options different between all.coffee
test spec and bin/mocha-casperjs
(excepting the obvious reason of variable arguments for the deliverable), specifically the missing mocha-casperjs-path
option?
all.coffee
:
'./bin/cli.js',
'--mocha-path=node_modules/mocha',
'--chai-path=node_modules/chai',
'--casper-chai-path=node_modules/casper-chai'
bin/mocha-casperjs
:
$mcPath/cli.js --mocha-casperjs-path=$mcPath/..
I am finding something rather strange about the XPath helper once I expose it as mentioned in the first comment. I can access it while using mocha-casperjs
but cannot in the tests.
My test is dumb and I am not sure if it satisfies any purpose in this case, but just so you know, how I am trying to access the helper in all.coffee
:
it 'should select by XPath using casper XPath helper', (done) ->
thisShouldPass
test: ->
casper.waitForSelector 'h1', ->
selectXPath.should.be.a.function
Once I can understand what's going under-the-hood, I can make the PR with/without this test, as you prefer.
why are the casperjs options different between all.coffee test spec and bin/mocha-casperjs
The dependencies for mocha-casperjs are peer dependencies, so for testing locally I have to point them to the developer dependencies, so that's why they have extra paths. as for the missing mocha-casperjs-path
, it's abusing the fact that the working directory is what mocha-casperjs-path
is supposed to be. I am not happy with all the funky path specifications and require
dances needed... it's complex due to global vs local, require.paths
not being supported for a while and capserj's wrapped require
, but it's another issue.
As for the test, that looks fine. You don't need to do a waitForSelector
so you can remove line 4.
@nathanboktae thanks. Yes, with the waitForSelector removed, the test is still failing though. Any reason the function would be undefined?
It should be there.... Push your feature branch to your repository and I can take a look.
@nathanboktae Thanks much. Commit made. I am running test using npm test
.
I gave you full permissions to my fork in case you decide to make additional changes.
Your test needed to pass in the done
to thisShouldPass
, and also call the right chai assertion:
it 'should select by XPath using casper XPath helper', (done) ->
thisShouldPass
test: ->
selectXPath.should.be.a('function')
, done
Yeah CoffeeScript can be hard to read sometimes, ironically. I have a love-hate relationship to it.
Thanks for the direction and merge. Shorter name looks good. :thumbsup:
casper
module provides an XPath selector helper calledselectXPath
incasperjs
.I think it would be handy to expose
selectXPath
incli.js
like thus:Are you cool with that - or do you have other ideas around structuring the
this
instance? Shall I make a PR?