You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
817 B

4 years ago
  1. /**
  2. * We pull in example files from test/examples/*.js. Write your assertions in
  3. * the file alongside the ES6 class "setup" code. The node `assert` library
  4. * will already be in the context.
  5. */
  6. Error.stackTraceLimit = 20;
  7. var compile = require('../lib').compile;
  8. var fs = require('fs');
  9. var path = require('path');
  10. var RESULTS = 'test/results';
  11. if (!fs.existsSync(RESULTS)) {
  12. fs.mkdirSync(RESULTS);
  13. }
  14. require('example-runner').runCLI(function(source, testName, filename) {
  15. var result = compile(source, {
  16. includeRuntime: true,
  17. sourceFileName: filename,
  18. sourceMapName: filename + '.map'
  19. });
  20. fs.writeFileSync(path.join(RESULTS, testName + '.js'), result.code, 'utf8');
  21. fs.writeFileSync(path.join(RESULTS, testName + '.js.map'), JSON.stringify(result.map), 'utf8');
  22. return result.code;
  23. });