Closed evgenijponomarev closed 7 years ago
You always need to wrap Casper logic in a step. waitForSelector
needs to be in a casper.then
. otherwise mocha sees that as synchronous and succeeds.
The step counter is a critical piece to how mocha-casperjs
works. If you had real logic in there you would see race conditions everywhere removing it.
Sorry, but on the main page of mocha-casperjs I see such example:
describe('Google searching', function() {
before(function() {
casper.start('http://www.google.fr/')
})
it('should retrieve 10 or more results', function() {
casper.then(function() {
'Google'.should.matchTitle
'form[action="/search"]'.should.be.inDOM.and.be.visible
this.fill('form[action="/search"]', {
q: 'casperjs'
}, true)
})
casper.waitForUrl(/q=casperjs/, function() {
(/casperjs/).should.matchTitle
})
})
})
I see waitForUrl
outside of casper.then
section. Is it a bug in documentation?
waitForSelector
calls waitFor internally and waitFor creates separate step, so I think it is not necessary to put waitForSelector
into casper.then
Ah ok, yeah that incrementing of the step counter came in with #56. Did casper functionality change since 1.1.0-beta3? what version of casperjs are you on? It could be if casper moves on to the next step after timeouts now automatically.
I wrap waitForSelector
in a step:
casper.then(function() {
casper.waitForSelector('#qwerty')
})
The result is the same. Version of casperjs is 1.1.3
, mocha - 3.2.0
, mocha-casperjs - 0.5.8
.
I agree with you I think it's a bug and removing those lines make sense. Would you mind to submit a PR with this test case too?
Yes. I'll do it this weekend.
If test fails with timeout, first
then
section of next test will be skipped.Result in console:
Is it a bug? Or I'm doing something wrong? I think, it's problem with steps counter, because if I remove line 51 in
node_modules/mocha-casperjs/mocha-casperjs.js
, allthen
sections are running.https://github.com/nathanboktae/mocha-casperjs/blob/master/mocha-casperjs.js#L51