test.js 878 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Module dependencies.
  3. */
  4. var Runnable = require('./runnable');
  5. var inherits = require('./utils').inherits;
  6. /**
  7. * Expose `Test`.
  8. */
  9. module.exports = Test;
  10. /**
  11. * Initialize a new `Test` with the given `title` and callback `fn`.
  12. *
  13. * @api private
  14. * @param {String} title
  15. * @param {Function} fn
  16. */
  17. function Test(title, fn) {
  18. Runnable.call(this, title, fn);
  19. this.pending = !fn;
  20. this.type = 'test';
  21. }
  22. /**
  23. * Inherit from `Runnable.prototype`.
  24. */
  25. inherits(Test, Runnable);
  26. Test.prototype.clone = function() {
  27. var test = new Test(this.title, this.fn);
  28. test.timeout(this.timeout());
  29. test.slow(this.slow());
  30. test.enableTimeouts(this.enableTimeouts());
  31. test.retries(this.retries());
  32. test.currentRetry(this.currentRetry());
  33. test.globals(this.globals());
  34. test.parent = this.parent;
  35. test.file = this.file;
  36. test.ctx = this.ctx;
  37. return test;
  38. };