File tree Expand file tree Collapse file tree 4 files changed +23
-1
lines changed
test-that-uses-dir-cjs-require.fixture.js Expand file tree Collapse file tree 4 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ exports.requireOrImport = hasStableEsmImplementation
4949 } catch ( err ) {
5050 if (
5151 err . code === 'ERR_MODULE_NOT_FOUND' ||
52- err . code === 'ERR_UNKNOWN_FILE_EXTENSION'
52+ err . code === 'ERR_UNKNOWN_FILE_EXTENSION' ||
53+ err . code === 'ERR_UNSUPPORTED_DIR_IMPORT'
5354 ) {
5455 return require ( file ) ;
5556 } else {
Original file line number Diff line number Diff line change 11'use strict' ;
2+ var path = require ( 'path' ) ;
23var helpers = require ( './helpers' ) ;
34var run = helpers . runMochaJSON ;
45var runMochaAsync = helpers . runMochaAsync ;
@@ -65,4 +66,19 @@ describe('esm', function() {
6566 done ( ) ;
6667 } ) ;
6768 } ) ;
69+
70+ it ( 'should enable requiring/loading a cjs module with "dir" as filename' , async function ( ) {
71+ var fixture = 'esm/test-that-uses-dir-cjs-require.fixture.js' ;
72+ const result = await runMochaAsync (
73+ fixture ,
74+ [
75+ ...args ,
76+ '--require' ,
77+ path . resolve ( __dirname , './fixtures/esm/dir-cjs-require' )
78+ ] ,
79+ { stdio : 'pipe' }
80+ ) ;
81+
82+ expect ( result , 'to have passed test count' , 1 ) ;
83+ } ) ;
6884} ) ;
Original file line number Diff line number Diff line change 1+ global . testPassesIfThisVariableIsDefined = true
Original file line number Diff line number Diff line change 1+ // See https://github.com/mochajs/mocha/issues/4665 for an explanation of this test
2+ it ( 'should require a dir import' , ( ) => {
3+ expect ( global . testPassesIfThisVariableIsDefined , 'to be' , true )
4+ } )
You can’t perform that action at this time.
0 commit comments