File tree 4 files changed +23
-1
lines changed
test-that-uses-dir-cjs-require.fixture.js
4 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ exports.requireOrImport = hasStableEsmImplementation
49
49
} catch ( err ) {
50
50
if (
51
51
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'
53
54
) {
54
55
return require ( file ) ;
55
56
} else {
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
+ var path = require ( 'path' ) ;
2
3
var helpers = require ( './helpers' ) ;
3
4
var run = helpers . runMochaJSON ;
4
5
var runMochaAsync = helpers . runMochaAsync ;
@@ -65,4 +66,19 @@ describe('esm', function() {
65
66
done ( ) ;
66
67
} ) ;
67
68
} ) ;
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
+ } ) ;
68
84
} ) ;
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