11import { describe , expect , it , vi } from "vitest" ;
2+ import globalSetup from "../globalSetup" ;
23
34console . log = vi . fn ( ) ;
45
5- async function importFreshGlobalSetup ( ) {
6- return (
7- ( await import (
8- `../globalSetup?${ Date . now ( ) } `
9- ) ) as typeof import ( "../globalSetup" )
10- ) . default ;
11- }
12-
13- describe ( "globalSetup" , async ( ) => {
14- it ( "with version, should log the correct message on setup and teardown, and fail when teardown is called twice" , async ( ) => {
15- vi . stubGlobal ( "__VERSION__" , "1.0.0" ) ;
16- const globalSetup = await importFreshGlobalSetup ( ) ;
6+ describe ( "globalSetup" , ( ) => {
7+ it ( "should log the correct message on setup and teardown, and fail when teardown is called twice" , async ( ) => {
178 const teardown = globalSetup ( ) ;
189
1910 expect ( console . log ) . toHaveBeenCalledWith (
@@ -28,22 +19,4 @@ describe("globalSetup", async () => {
2819
2920 expect ( ( ) => teardown ( ) ) . toThrowError ( "teardown called twice" ) ;
3021 } ) ;
31-
32- it ( "without version, should log the correct message on setup and teardown, and fail when teardown is called twice" , async ( ) => {
33- vi . unstubAllGlobals ( ) ;
34- const globalSetup = await importFreshGlobalSetup ( ) ;
35- const teardown = globalSetup ( ) ;
36-
37- expect ( console . log ) . toHaveBeenCalledWith (
38- "[CodSpeed] @codspeed/vitest-plugin - setup"
39- ) ;
40-
41- teardown ( ) ;
42-
43- expect ( console . log ) . toHaveBeenCalledWith (
44- "[CodSpeed] @codspeed/vitest-plugin - teardown"
45- ) ;
46-
47- expect ( ( ) => teardown ( ) ) . toThrowError ( "teardown called twice" ) ;
48- } ) ;
4922} ) ;
0 commit comments