phantomasWrapper.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Yellow Lab Tools main file
  3. */
  4. var q = require ('q');
  5. var phantomas = require('phantomas');
  6. var PhantomasWrapper = function() {
  7. 'use strict';
  8. /**
  9. * This is the phantomas launcher. It merges user chosen options into the default options
  10. * Available options :
  11. *
  12. * - timeout : in seconds (default 60)
  13. * - jsDeepAnalysis : should we inspect subrequests in the javascript execution tree (reported durations of main tasks will be slower than usual)
  14. *
  15. */
  16. this.execute = function(task, callback) {
  17. var options = {
  18. // Cusomizable options
  19. timeout: task.options.timeout || 60,
  20. 'js-deep-analysis': task.options.jsDeepAnalysis || false,
  21. // Mandatory
  22. reporter: 'json:pretty',
  23. 'skip-modules': [
  24. 'ajaxRequests',
  25. 'alerts',
  26. 'cacheHits',
  27. 'caching',
  28. 'console',
  29. 'cookies',
  30. 'documentHeight',
  31. 'domains',
  32. 'domComplexity',
  33. 'domMutations',
  34. 'domQueries',
  35. 'filmStrip',
  36. 'jQuery',
  37. 'jserrors',
  38. 'har',
  39. 'headers',
  40. 'localStorage',
  41. 'mainRequest',
  42. 'pageSource',
  43. 'redirects',
  44. 'requestsStats',
  45. 'screenshot',
  46. 'staticAssets',
  47. 'timeToFirst',
  48. 'waitForSelector'
  49. ].join(','),
  50. 'include-dirs': [
  51. 'phantomas_custom/core',
  52. 'phantomas_custom/modules'
  53. ].join(',')
  54. };
  55. // It's time to launch the test!!!
  56. phantomas(task.url, options, callback);
  57. };
  58. };
  59. module.exports = new PhantomasWrapper();