casper.js 771 B

1234567891011121314151617181920212223242526
  1. /**
  2. * Run e2e tests with CasperJS.
  3. */
  4. module.exports = function (grunt) {
  5. grunt.registerTask('casper', function (id) {
  6. var path = require('path')
  7. var done = this.async()
  8. var file = id ? id + '.js' : ''
  9. // let casperjs use local phantomjs
  10. process.env.PHANTOMJS_EXECUTABLE =
  11. '../../node_modules/karma-phantomjs-launcher/node_modules/.bin/phantomjs'
  12. grunt.util.spawn({
  13. cmd: '../../node_modules/.bin/casperjs',
  14. args: ['test', '--concise', './' + file],
  15. opts: {
  16. stdio: ['ignore', process.stdout, 'ignore'],
  17. cwd: path.resolve('test/e2e')
  18. }
  19. }, function (err, res) {
  20. if (err) grunt.fail.fatal(res.stdout || 'CasperJS test failed')
  21. grunt.log.writeln(res.stdout)
  22. done()
  23. })
  24. })
  25. }