main.js 705 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const runner = require('./subprocess').getRunner();
  3. const makeCjsExport = () => {
  4. function test() {
  5. return runner.chain.apply(null, arguments);
  6. }
  7. return Object.assign(test, runner.chain);
  8. };
  9. // Support CommonJS modules by exporting a test function that can be fully
  10. // chained. Also support ES module loaders by exporting __esModule and a
  11. // default. Support `import * as ava from 'ava'` use cases by exporting a
  12. // `test` member. Do all this whilst preventing `test.test.test() or
  13. // `test.default.test()` chains, though in CommonJS `test.test()` is
  14. // unavoidable.
  15. module.exports = Object.assign(makeCjsExport(), {
  16. __esModule: true,
  17. default: runner.chain,
  18. test: runner.chain
  19. });