esm.js 611 B

1234567891011121314151617181920212223
  1. var test = require('tap').test;
  2. var fs = require('fs');
  3. var check = require('../');
  4. var file = __dirname + '/sources/esm.js';
  5. var src = fs.readFileSync(file);
  6. test('esm with sourceType script', function (t) {
  7. var err = check(src, file);
  8. t.ok(err);
  9. t.equal(err.line, 1);
  10. t.equal(err.column, 1);
  11. t.equal(err.message, "'import' and 'export' may appear only with 'sourceType: module'");
  12. t.ok(String(err).indexOf(file + ':1'));
  13. t.end();
  14. });
  15. test('esm with sourceType module', function (t) {
  16. var err = check(src, file, { sourceType: 'module' });
  17. t.notOk(err);
  18. t.end();
  19. });