@@ -2,12 +2,12 @@ import { Bench } from "tinybench";
22import { beforeEach , describe , expect , it , vi } from "vitest" ;
33import { withCodSpeed } from "." ;
44
5- const mockInstrumented = vi . hoisted ( ( ) => ( {
6- setupCodspeedInstrumentedBench : vi . fn ( ) ,
5+ const mockSimulation = vi . hoisted ( ( ) => ( {
6+ setupCodspeedSimulationBench : vi . fn ( ) ,
77} ) ) ;
88
9- vi . mock ( "./instrumented " , ( ) => ( {
10- ...mockInstrumented ,
9+ vi . mock ( "./simulation " , ( ) => ( {
10+ ...mockSimulation ,
1111} ) ) ;
1212
1313const mockWalltime = vi . hoisted ( ( ) => ( {
@@ -38,13 +38,23 @@ describe("withCodSpeed behavior without different codspeed modes", () => {
3838 expect ( shouldBeCalled . mock . calls . length ) . toBeGreaterThan ( 1000 ) ;
3939 } ) ;
4040
41- it ( "should run in instrumented mode when CODSPEED_RUNNER_MODE=instrumentation" , async ( ) => {
41+ it ( "should run in simulation mode when CODSPEED_RUNNER_MODE=instrumentation" , async ( ) => {
4242 process . env . CODSPEED_ENV = "true" ;
4343 process . env . CODSPEED_RUNNER_MODE = "instrumentation" ;
4444
4545 withCodSpeed ( new Bench ( ) ) ;
4646
47- expect ( mockInstrumented . setupCodspeedInstrumentedBench ) . toHaveBeenCalled ( ) ;
47+ expect ( mockSimulation . setupCodspeedSimulationBench ) . toHaveBeenCalled ( ) ;
48+ expect ( mockWalltime . setupCodspeedWalltimeBench ) . not . toHaveBeenCalled ( ) ;
49+ } ) ;
50+
51+ it ( "should run in simulation mode when CODSPEED_RUNNER_MODE=simulation" , async ( ) => {
52+ process . env . CODSPEED_ENV = "true" ;
53+ process . env . CODSPEED_RUNNER_MODE = "simulation" ;
54+
55+ withCodSpeed ( new Bench ( ) ) ;
56+
57+ expect ( mockSimulation . setupCodspeedSimulationBench ) . toHaveBeenCalled ( ) ;
4858 expect ( mockWalltime . setupCodspeedWalltimeBench ) . not . toHaveBeenCalled ( ) ;
4959 } ) ;
5060
@@ -55,7 +65,7 @@ describe("withCodSpeed behavior without different codspeed modes", () => {
5565 withCodSpeed ( new Bench ( ) ) ;
5666
5767 expect (
58- mockInstrumented . setupCodspeedInstrumentedBench
68+ mockSimulation . setupCodspeedSimulationBench
5969 ) . not . toHaveBeenCalled ( ) ;
6070 expect ( mockWalltime . setupCodspeedWalltimeBench ) . toHaveBeenCalled ( ) ;
6171 } ) ;
0 commit comments