Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file location when SyntaxError happens in ESM (fixes #4551) #4557

Merged
merged 3 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
giltayar authored and juergba committed Feb 3, 2021
commit 19ca1a48eb6ee895967866ea0edc633e73298da0
12 changes: 11 additions & 1 deletion test/integration/esm.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';
var run = require('./helpers').runMochaJSON;
var helpers = require('./helpers');
var run = helpers.runMochaJSON;
var runMochaAsync = helpers.runMochaAsync;
var utils = require('../../lib/utils');
var args =
+process.versions.node.split('.')[0] >= 13 ? [] : ['--experimental-modules'];
Expand Down Expand Up @@ -38,6 +40,14 @@ describe('esm', function() {
});
});

it('should show file location when there is a syntax error in the test', async function() {
var fixture = 'esm/syntax-error/esm-syntax-error.fixture.mjs';
const err = await runMochaAsync(fixture, args, {stdio: 'pipe'}).catch(
err => err
);
expect(err.output, 'to contain', 'SyntaxError').and('to contain', fixture);
});

it('should recognize esm files ending with .js due to package.json type flag', function(done) {
if (!utils.supportsEsModules(false)) return this.skip();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This is intentionally a syntax error
it('should never run because of a syntax error here', => {
});