@@ -31,6 +31,10 @@ const assert = require('assert');
3131const path = require ( 'path' ) ;
3232const fixtures = require ( '../common/fixtures' ) ;
3333const { builtinModules } = require ( 'module' ) ;
34+ const publicModules = builtinModules . filter (
35+ ( lib ) => ! lib . startsWith ( '_' ) && ! lib . includes ( '/' ) ,
36+ ) ;
37+
3438const hasInspector = process . features . inspector ;
3539
3640if ( ! common . isMainThread )
@@ -239,9 +243,9 @@ putIn.run(['.clear']);
239243
240244testMe . complete ( 'require(\'' , common . mustCall ( function ( error , data ) {
241245 assert . strictEqual ( error , null ) ;
242- builtinModules . forEach ( ( lib ) => {
246+ publicModules . forEach ( ( lib ) => {
243247 assert (
244- data [ 0 ] . includes ( lib ) || lib . startsWith ( '_' ) || lib . includes ( '/' ) ,
248+ data [ 0 ] . includes ( lib ) && data [ 0 ] . includes ( `node: ${ lib } ` ) ,
245249 `${ lib } not found`
246250 ) ;
247251 } ) ;
@@ -258,6 +262,10 @@ testMe.complete("require\t( 'n", common.mustCall(function(error, data) {
258262 assert . strictEqual ( error , null ) ;
259263 assert . strictEqual ( data . length , 2 ) ;
260264 assert . strictEqual ( data [ 1 ] , 'n' ) ;
265+ // require(...) completions include `node:`-prefixed modules:
266+ publicModules . forEach ( ( lib , index ) =>
267+ assert . strictEqual ( data [ 0 ] [ index ] , `node:${ lib } ` ) ) ;
268+ assert . strictEqual ( data [ 0 ] [ publicModules . length ] , '' ) ;
261269 // There is only one Node.js module that starts with n:
262270 assert . strictEqual ( data [ 0 ] [ 0 ] , 'net' ) ;
263271 assert . strictEqual ( data [ 0 ] [ 1 ] , '' ) ;
0 commit comments