@@ -2,7 +2,8 @@ import { readdirSync } from "node:fs";
2
2
import { readFile } from "node:fs/promises" ;
3
3
import { join } from "node:path" ;
4
4
import jscodeshift from "jscodeshift" ;
5
- import { describe , expect , it } from "vitest" ;
5
+ import { strictEqual } from "node:assert" ;
6
+ import { describe , it } from "node:test" ;
6
7
7
8
import transform from "./transformer" ;
8
9
@@ -21,38 +22,58 @@ describe("v2-to-v3", () => {
21
22
[
22
23
( fileName . match ( inputFileRegex ) as RegExpMatchArray ) [ 1 ] ,
23
24
fileName . split ( "." ) . pop ( ) as string ,
24
- ] as const
25
+ ] as const ,
25
26
) ;
26
27
27
- const getTestMetadata = async ( dirPath : string , filePrefix : string , fileExtension : string ) => {
28
- const inputPath = join ( dirPath , [ filePrefix , "input" , fileExtension ] . join ( "." ) ) ;
29
- const outputPath = join ( dirPath , [ filePrefix , "output" , fileExtension ] . join ( "." ) ) ;
28
+ const getTestMetadata = async (
29
+ dirPath : string ,
30
+ filePrefix : string ,
31
+ fileExtension : string ,
32
+ ) => {
33
+ const inputPath = join (
34
+ dirPath ,
35
+ [ filePrefix , "input" , fileExtension ] . join ( "." ) ,
36
+ ) ;
37
+ const outputPath = join (
38
+ dirPath ,
39
+ [ filePrefix , "output" , fileExtension ] . join ( "." ) ,
40
+ ) ;
30
41
const inputCode = await readFile ( inputPath , "utf8" ) ;
31
42
const outputCode = await readFile ( outputPath , "utf8" ) ;
32
43
33
44
const input = { path : inputPath , source : inputCode } ;
34
45
return { input, outputCode } ;
35
46
} ;
36
47
37
- describe . each ( fixtureSubDirs ) ( "%s" , ( subDir ) => {
38
- const subDirPath = join ( fixtureDir , subDir ) ;
39
- it . concurrent . each ( getTestFileMetadata ( subDirPath ) ) (
40
- "transforms: %s.%s" ,
41
- async ( filePrefix , fileExtension ) => {
42
- const { input, outputCode } = await getTestMetadata ( subDirPath , filePrefix , fileExtension ) ;
43
-
44
- const output = await transform ( input , {
45
- j : jscodeshift ,
46
- jscodeshift,
47
- // biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
48
- stats : ( ) => { } ,
49
- // biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
50
- report : ( ) => { } ,
51
- } ) ;
52
-
53
- expect ( output . trim ( ) ) . toEqual ( outputCode . trim ( ) ) ;
54
- } ,
55
- 100000
56
- ) ;
57
- } ) ;
48
+ for ( const subDir of fixtureSubDirs ) {
49
+ describe ( subDir , ( ) => {
50
+ const subDirPath = join ( fixtureDir , subDir ) ;
51
+ for ( const [ filePrefix , fileExtension ] of getTestFileMetadata (
52
+ subDirPath ,
53
+ ) ) {
54
+ it (
55
+ `transforms: ${ filePrefix } .${ fileExtension } ` ,
56
+ { concurrency : true } ,
57
+ async ( ) => {
58
+ const { input, outputCode } = await getTestMetadata (
59
+ subDirPath ,
60
+ filePrefix ,
61
+ fileExtension ,
62
+ ) ;
63
+
64
+ const output = await transform ( input , {
65
+ j : jscodeshift ,
66
+ jscodeshift,
67
+ // biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
68
+ stats : ( ) => { } ,
69
+ // biome-ignore lint/suspicious/noEmptyBlockStatements: test helper
70
+ report : ( ) => { } ,
71
+ } ) ;
72
+
73
+ strictEqual ( output . trim ( ) , outputCode . trim ( ) ) ;
74
+ } ,
75
+ ) ;
76
+ }
77
+ } ) ;
78
+ }
58
79
} ) ;
0 commit comments