@@ -10,19 +10,24 @@ import { assertFileContents } from "./expectFileContains";
10
10
const exec = promisify ( cp . exec ) ;
11
11
const readFile = promisify ( fs . readFile ) ;
12
12
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 ;
15
16
const cwdPath = ( fileName : string ) => path . join ( cwd , fileName ) ;
16
17
const readTestFile = async ( fileName : string ) => ( await readFile ( cwdPath ( fileName ) ) ) . toString ( ) ;
17
18
18
- return ( ) => {
19
+ describe ( testName , ( ) => {
19
20
let result : PromiseValue < ReturnType < typeof exec > > ;
20
21
beforeAll ( async ( ) => {
21
22
// Arrange
22
23
const args = await createTestArgs ( cwd ) ;
23
24
24
25
// 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
+ }
26
31
} ) ;
27
32
28
33
test ( "configuration output" , async ( ) => {
@@ -33,14 +38,12 @@ export const createTests = (testName: string, accept: boolean) => {
33
38
) ;
34
39
} ) ;
35
40
36
- // test("info log output", () => {});
37
-
38
41
test ( "stderr" , async ( ) => {
39
42
await assertFileContents ( cwdPath ( "stderr.txt" ) , result . stderr , accept ) ;
40
43
} ) ;
41
44
42
45
test ( "stdout" , async ( ) => {
43
46
await assertFileContents ( cwdPath ( "stdout.txt" ) , result . stdout , accept ) ;
44
47
} ) ;
45
- } ;
48
+ } ) ;
46
49
} ;
0 commit comments