1- import { bench , describe } from "vitest" ;
1+ import { describe , test } from "vitest" ;
22import parsePr from "./parsePr" ;
33
44const LONG_BODY =
@@ -8,44 +8,52 @@ const LONG_BODY =
88 )
99 . join ( "\n" ) + "fixes #123" ;
1010
11+ function benchShortBody ( ) {
12+ parsePr ( { body : "fixes #123" , title : "test" , number : 124 } ) ;
13+ }
14+
15+ function benchLongBody ( ) {
16+ parsePr ( { body : LONG_BODY , title : "test" , number : 124 } ) ;
17+ }
18+
1119describe ( "parsePr" , ( ) => {
12- bench ( "short body" , ( ) => {
13- parsePr ( { body : "fixes #123" , title : "test" , number : 124 } ) ;
20+ test ( "short body" , async ( { bench } ) => {
21+ await bench ( "short body" , benchShortBody ) . run ( ) ;
1422 } ) ;
1523
16- bench ( "long body" , ( ) => {
17- parsePr ( { body : LONG_BODY , title : "test" , number : 124 } ) ;
24+ test ( "long body" , async ( { bench } ) => {
25+ await bench ( "long body" , benchLongBody ) . run ( ) ;
1826 } ) ;
1927
2028 describe ( "nested suite" , ( ) => {
21- bench ( "short body" , ( ) => {
22- parsePr ( { body : "fixes #123" , title : "test" , number : 124 } ) ;
29+ test ( "short body" , async ( { bench } ) => {
30+ await bench ( "short body" , benchShortBody ) . run ( ) ;
2331 } ) ;
2432
25- bench ( "long body" , ( ) => {
26- parsePr ( { body : LONG_BODY , title : "test" , number : 124 } ) ;
33+ test ( "long body" , async ( { bench } ) => {
34+ await bench ( "long body" , benchLongBody ) . run ( ) ;
2735 } ) ;
2836
2937 describe ( "deeply nested suite" , ( ) => {
30- bench ( "short body" , ( ) => {
31- parsePr ( { body : "fixes #123" , title : "test" , number : 124 } ) ;
38+ test ( "short body" , async ( { bench } ) => {
39+ await bench ( "short body" , benchShortBody ) . run ( ) ;
3240 } ) ;
3341 } ) ;
3442 } ) ;
3543} ) ;
3644
3745describe ( "another parsePr" , ( ) => {
38- bench ( "short body" , ( ) => {
39- parsePr ( { body : "fixes #123" , title : "test" , number : 124 } ) ;
46+ test ( "short body" , async ( { bench } ) => {
47+ await bench ( "short body" , benchShortBody ) . run ( ) ;
4048 } ) ;
4149
42- bench ( "long body" , ( ) => {
43- parsePr ( { body : LONG_BODY , title : "test" , number : 124 } ) ;
50+ test ( "long body" , async ( { bench } ) => {
51+ await bench ( "long body" , benchLongBody ) . run ( ) ;
4452 } ) ;
4553
4654 describe ( "nested suite" , ( ) => {
47- bench ( "short body" , ( ) => {
48- parsePr ( { body : "fixes #123" , title : "test" , number : 124 } ) ;
55+ test ( "short body" , async ( { bench } ) => {
56+ await bench ( "short body" , benchShortBody ) . run ( ) ;
4957 } ) ;
5058 } ) ;
5159} ) ;
0 commit comments