nathanboktae / mocha-casperjs

Write CasperJS tests using Mocha
MIT License
120 stars 30 forks source link

Take screenshots when tests are failing #109

Closed newagebegins closed 7 years ago

newagebegins commented 7 years ago

With complicated test scripts it can be difficult to understand what exactly went wrong and having automatic screenshots on failures help with this greatly.

nathanboktae commented 7 years ago

This might be useful as an example but I wouldn't add this to this library. It's simple enough to write yourself. Most of your code is specific to the way you want your path formatting done, which is your preference and would need to be configured. It's easy enough to do:

afterEach(function() {
  if (this.currentTest.state !== 'passed') {
    casper.capture(new Date().toLocaleString() + '-' + this.currentTest.fullTitle() + '.png')
  }
})

3 lines. and users might want to add more logic in when they capture the screenshot, what path they put it under, etc. It doesn't belong in the project.

newagebegins commented 7 years ago

I see your point. Thanks!