From 19ca1a48eb6ee895967866ea0edc633e73298da0 Mon Sep 17 00:00:00 2001 From: Gil Tayar Date: Wed, 20 Jan 2021 18:39:08 +0200 Subject: [PATCH] add tests --- test/integration/esm.spec.js | 12 +++++++++++- .../esm/syntax-error/esm-syntax-error.fixture.mjs | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/integration/fixtures/esm/syntax-error/esm-syntax-error.fixture.mjs diff --git a/test/integration/esm.spec.js b/test/integration/esm.spec.js index 20b3a27248..733190d55b 100644 --- a/test/integration/esm.spec.js +++ b/test/integration/esm.spec.js @@ -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']; @@ -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(); diff --git a/test/integration/fixtures/esm/syntax-error/esm-syntax-error.fixture.mjs b/test/integration/fixtures/esm/syntax-error/esm-syntax-error.fixture.mjs new file mode 100644 index 0000000000..c9c23b9634 --- /dev/null +++ b/test/integration/fixtures/esm/syntax-error/esm-syntax-error.fixture.mjs @@ -0,0 +1,3 @@ +// This is intentionally a syntax error +it('should never run because of a syntax error here', => { +});