@@ -10,19 +10,24 @@ import { assertFileContents } from "./expectFileContains";
1010const exec = promisify ( cp . exec ) ;
1111const readFile = promisify ( fs . readFile ) ;
1212
13- export const createTests = ( testName : string , accept : boolean ) => {
14- const cwd = path . join ( __dirname , "tests" , testName ) ;
13+ export const createTests = ( cwd : string ) => {
14+ const testName = path . basename ( cwd ) ;
15+ const accept = "acceptTestChanges" in globalThis ;
1516 const cwdPath = ( fileName : string ) => path . join ( cwd , fileName ) ;
1617 const readTestFile = async ( fileName : string ) => ( await readFile ( cwdPath ( fileName ) ) ) . toString ( ) ;
1718
18- return ( ) => {
19+ describe ( testName , ( ) => {
1920 let result : PromiseValue < ReturnType < typeof exec > > ;
2021 beforeAll ( async ( ) => {
2122 // Arrange
2223 const args = await createTestArgs ( cwd ) ;
2324
2425 // Act
25- result = await exec ( `ts-node bin/tslint-to-eslint-config ${ args } ` ) ;
26+ try {
27+ result = await exec ( `ts-node bin/tslint-to-eslint-config ${ args } ` ) ;
28+ } catch ( error ) {
29+ result = error ;
30+ }
2631 } ) ;
2732
2833 test ( "configuration output" , async ( ) => {
@@ -33,14 +38,12 @@ export const createTests = (testName: string, accept: boolean) => {
3338 ) ;
3439 } ) ;
3540
36- // test("info log output", () => {});
37-
3841 test ( "stderr" , async ( ) => {
3942 await assertFileContents ( cwdPath ( "stderr.txt" ) , result . stderr , accept ) ;
4043 } ) ;
4144
4245 test ( "stdout" , async ( ) => {
4346 await assertFileContents ( cwdPath ( "stdout.txt" ) , result . stdout , accept ) ;
4447 } ) ;
45- } ;
48+ } ) ;
4649} ;
0 commit comments