@@ -39,6 +39,7 @@ before(async function () {
3939
4040describe ( 'ts-node' , function ( ) {
4141 const cmd = `"${ BIN_PATH } " --project "${ PROJECT } "`
42+ const cmdNoProject = `"${ BIN_PATH } "`
4243
4344 this . timeout ( 10000 )
4445
@@ -88,6 +89,32 @@ describe('ts-node', function () {
8889 } )
8990 } )
9091
92+ it ( 'shows usage via --help' , function ( done ) {
93+ exec ( `${ cmdNoProject } --help` , function ( err , stdout ) {
94+ expect ( err ) . to . equal ( null )
95+ expect ( stdout ) . to . match ( / U s a g e : t s - n o d e / )
96+ return done ( )
97+ } )
98+ } )
99+ it ( 'shows version via -v' , function ( done ) {
100+ exec ( `${ cmdNoProject } -v` , function ( err , stdout ) {
101+ expect ( err ) . to . equal ( null )
102+ expect ( stdout . trim ( ) ) . to . equal ( 'v' + testsDirRequire ( 'ts-node/package' ) . version )
103+ return done ( )
104+ } )
105+ } )
106+ it ( 'shows version of compiler via -vv' , function ( done ) {
107+ exec ( `${ cmdNoProject } -vv` , function ( err , stdout ) {
108+ expect ( err ) . to . equal ( null )
109+ expect ( stdout . trim ( ) ) . to . equal (
110+ `ts-node v${ testsDirRequire ( 'ts-node/package' ) . version } \n` +
111+ `node ${ process . version } \n` +
112+ `compiler v${ testsDirRequire ( 'typescript/package' ) . version } `
113+ )
114+ return done ( )
115+ } )
116+ } )
117+
91118 it ( 'should register via cli' , function ( done ) {
92119 exec ( `node -r ts-node/register hello-world.ts` , {
93120 cwd : TEST_DIR
@@ -727,11 +754,30 @@ describe('ts-node', function () {
727754 } )
728755
729756 describe ( 'create' , ( ) => {
757+ let service : tsNodeTypes . Register
758+ before ( ( ) => {
759+ service = create ( { compilerOptions : { target : 'es5' } , skipProject : true } )
760+ } )
761+
730762 it ( 'should create generic compiler instances' , ( ) => {
731- const service = create ( { compilerOptions : { target : 'es5' } , skipProject : true } )
732763 const output = service . compile ( 'const x = 10' , 'test.ts' )
733764 expect ( output ) . to . contain ( 'var x = 10;' )
734765 } )
766+
767+ describe ( 'should get type information' , ( ) => {
768+ it ( 'given position of identifier' , ( ) => {
769+ expect ( service . getTypeInfo ( '/**jsdoc here*/const x = 10' , 'test.ts' , 21 ) ) . to . deep . equal ( {
770+ comment : 'jsdoc here' ,
771+ name : 'const x: 10'
772+ } )
773+ } )
774+ it ( 'given position that does not point to an identifier' , ( ) => {
775+ expect ( service . getTypeInfo ( '/**jsdoc here*/const x = 10' , 'test.ts' , 0 ) ) . to . deep . equal ( {
776+ comment : '' ,
777+ name : ''
778+ } )
779+ } )
780+ } )
735781 } )
736782
737783 describe ( 'issue #1098' , ( ) => {
@@ -824,6 +870,17 @@ describe('ts-node', function () {
824870 } )
825871 } )
826872
873+ it ( 'defers to fallback loaders when URL should not be handled by ts-node' , function ( done ) {
874+ exec ( `${ cmd } index.mjs` , {
875+ cwd : join ( __dirname , '../tests/esm-import-http-url' )
876+ } , function ( err , stdout , stderr ) {
877+ expect ( err ) . to . not . equal ( null )
878+ // expect error from node's default resolver
879+ expect ( stderr ) . to . match ( / E r r o r \[ E R R _ U N S U P P O R T E D _ E S M _ U R L _ S C H E M E \] : .* \n * a t d e f a u l t R e s o l v e / )
880+ return done ( )
881+ } )
882+ } )
883+
827884 it ( 'should support transpile only mode via dedicated loader entrypoint' , ( done ) => {
828885 exec ( `${ cmd } /transpile-only index.ts` , { cwd : join ( __dirname , '../tests/esm-transpile-only' ) } , function ( err , stdout ) {
829886 expect ( err ) . to . equal ( null )
0 commit comments