@@ -3,7 +3,13 @@ import * as expect from 'expect';
33import { join , resolve , sep as pathSep } from 'path' ;
44import { tmpdir } from 'os' ;
55import semver = require( 'semver' ) ;
6- import { BIN_PATH_JS , nodeSupportsEsmHooks , ts } from './helpers' ;
6+ import {
7+ BIN_PATH_JS ,
8+ nodeSupportsEsmHooks ,
9+ ts ,
10+ tsSupportsShowConfig ,
11+ tsSupportsTsconfigInheritanceViaNodePackages ,
12+ } from './helpers' ;
713import { lstatSync , mkdtempSync } from 'fs' ;
814import { npath } from '@yarnpkg/fslib' ;
915import type _createRequire from 'create-require' ;
@@ -167,31 +173,29 @@ test.suite('ts-node', (test) => {
167173 expect ( stdout ) . toBe ( 'object\n' ) ;
168174 } ) ;
169175
170- if ( semver . gte ( ts . version , '1.8.0' ) ) {
171- test ( 'should allow js' , async ( ) => {
172- const { err, stdout } = await exec (
173- [
174- CMD_TS_NODE_WITH_PROJECT_FLAG ,
175- '-O "{\\"allowJs\\":true}"' ,
176- '-pe "import { main } from \'./allow-js/run\';main()"' ,
177- ] . join ( ' ' )
178- ) ;
179- expect ( err ) . toBe ( null ) ;
180- expect ( stdout ) . toBe ( 'hello world\n' ) ;
181- } ) ;
176+ test ( 'should allow js' , async ( ) => {
177+ const { err, stdout } = await exec (
178+ [
179+ CMD_TS_NODE_WITH_PROJECT_FLAG ,
180+ '-O "{\\"allowJs\\":true}"' ,
181+ '-pe "import { main } from \'./allow-js/run\';main()"' ,
182+ ] . join ( ' ' )
183+ ) ;
184+ expect ( err ) . toBe ( null ) ;
185+ expect ( stdout ) . toBe ( 'hello world\n' ) ;
186+ } ) ;
182187
183- test ( 'should include jsx when `allow-js` true' , async ( ) => {
184- const { err, stdout } = await exec (
185- [
186- CMD_TS_NODE_WITH_PROJECT_FLAG ,
187- '-O "{\\"allowJs\\":true}"' ,
188- '-pe "import { Foo2 } from \'./allow-js/with-jsx\'; Foo2.sayHi()"' ,
189- ] . join ( ' ' )
190- ) ;
191- expect ( err ) . toBe ( null ) ;
192- expect ( stdout ) . toBe ( 'hello world\n' ) ;
193- } ) ;
194- }
188+ test ( 'should include jsx when `allow-js` true' , async ( ) => {
189+ const { err, stdout } = await exec (
190+ [
191+ CMD_TS_NODE_WITH_PROJECT_FLAG ,
192+ '-O "{\\"allowJs\\":true}"' ,
193+ '-pe "import { Foo2 } from \'./allow-js/with-jsx\'; Foo2.sayHi()"' ,
194+ ] . join ( ' ' )
195+ ) ;
196+ expect ( err ) . toBe ( null ) ;
197+ expect ( stdout ) . toBe ( 'hello world\n' ) ;
198+ } ) ;
195199
196200 test ( 'should eval code' , async ( ) => {
197201 const { err, stdout } = await exec (
@@ -501,21 +505,16 @@ test.suite('ts-node', (test) => {
501505 } ) ;
502506
503507 test . suite ( 'issue #884' , ( test ) => {
508+ // TODO disabled because it consistently fails on Windows on TS 2.7
509+ test . skipIf (
510+ process . platform === 'win32' && semver . satisfies ( ts . version , '2.7' )
511+ ) ;
504512 test ( 'should compile' , async ( t ) => {
505- // TODO disabled because it consistently fails on Windows on TS 2.7
506- if (
507- process . platform === 'win32' &&
508- semver . satisfies ( ts . version , '2.7' )
509- ) {
510- t . log ( 'Skipping' ) ;
511- return ;
512- } else {
513- const { err, stdout } = await exec (
514- `"${ BIN_PATH } " --project issue-884/tsconfig.json issue-884`
515- ) ;
516- expect ( err ) . toBe ( null ) ;
517- expect ( stdout ) . toBe ( '' ) ;
518- }
513+ const { err, stdout } = await exec (
514+ `"${ BIN_PATH } " --project issue-884/tsconfig.json issue-884`
515+ ) ;
516+ expect ( err ) . toBe ( null ) ;
517+ expect ( stdout ) . toBe ( '' ) ;
519518 } ) ;
520519 } ) ;
521520
@@ -706,7 +705,7 @@ test.suite('ts-node', (test) => {
706705 ] ) ;
707706 } ) ;
708707
709- if ( semver . gte ( ts . version , '3.2.0' ) ) {
708+ if ( tsSupportsTsconfigInheritanceViaNodePackages ) {
710709 test ( 'should pull ts-node options from extended `tsconfig.json`' , async ( ) => {
711710 const { err, stdout } = await exec (
712711 `${ BIN_PATH } --show-config --project ./tsconfig-extends/tsconfig.json`
@@ -810,33 +809,33 @@ test.suite('ts-node', (test) => {
810809 }
811810 ) ;
812811
813- if ( semver . gte ( ts . version , '3.2.0' ) ) {
814- test . suite (
815- 'should bundle @tsconfig/bases to be used in your own tsconfigs' ,
816- ( test ) => {
817- const macro = test . macro ( ( nodeVersion : string ) => async ( t ) => {
818- const config = require ( `@tsconfig/ ${ nodeVersion } /tsconfig.json` ) ;
819- const { err , stdout , stderr } = await exec (
820- ` ${ BIN_PATH } --showConfig -e 10n` ,
821- {
822- cwd : join ( TEST_DIR , 'tsconfig-bases' , nodeVersion ) ,
823- }
824- ) ;
825- expect ( err ) . toBe ( null ) ;
826- t . like ( JSON . parse ( stdout ) , {
827- compilerOptions : {
828- target : config . compilerOptions . target ,
829- lib : config . compilerOptions . lib ,
830- } ,
831- } ) ;
812+ test . suite (
813+ 'should bundle @tsconfig/bases to be used in your own tsconfigs' ,
814+ ( test ) => {
815+ test . runIf ( tsSupportsTsconfigInheritanceViaNodePackages ) ;
816+
817+ const macro = test . macro ( ( nodeVersion : string ) => async ( t ) => {
818+ const config = require ( `@tsconfig/ ${ nodeVersion } /tsconfig.json` ) ;
819+ const { err , stdout , stderr } = await exec (
820+ ` ${ BIN_PATH } --showConfig -e 10n` ,
821+ {
822+ cwd : join ( TEST_DIR , 'tsconfig-bases' , nodeVersion ) ,
823+ }
824+ ) ;
825+ expect ( err ) . toBe ( null ) ;
826+ t . like ( JSON . parse ( stdout ) , {
827+ compilerOptions : {
828+ target : config . compilerOptions . target ,
829+ lib : config . compilerOptions . lib ,
830+ } ,
832831 } ) ;
833- test ( `ts-node/node10/tsconfig.json` , macro , 'node10' ) ;
834- test ( `ts-node/node12 /tsconfig.json` , macro , 'node12 ' ) ;
835- test ( `ts-node/node14 /tsconfig.json` , macro , 'node14 ' ) ;
836- test ( `ts-node/node16 /tsconfig.json` , macro , 'node16 ' ) ;
837- }
838- ) ;
839- }
832+ } ) ;
833+ test ( `ts-node/node10 /tsconfig.json` , macro , 'node10 ' ) ;
834+ test ( `ts-node/node12 /tsconfig.json` , macro , 'node12 ' ) ;
835+ test ( `ts-node/node14 /tsconfig.json` , macro , 'node14 ' ) ;
836+ test ( `ts-node/node16/tsconfig.json` , macro , 'node16' ) ;
837+ }
838+ ) ;
840839
841840 test . suite ( 'compiler host' , ( test ) => {
842841 test ( 'should execute cli' , async ( ) => {
@@ -896,7 +895,7 @@ test.suite('ts-node', (test) => {
896895 } ) ;
897896 } ) ;
898897
899- if ( semver . gte ( ts . version , '3.2.0' ) ) {
898+ if ( tsSupportsShowConfig ) {
900899 test ( '--showConfig should log resolved configuration' , async ( t ) => {
901900 function native ( path : string ) {
902901 return path . replace ( / \/ | \\ / g, pathSep ) ;
0 commit comments