@@ -2,12 +2,12 @@ import { Bench } from "tinybench";
22import { beforeEach , describe , expect , it , vi } from "vitest" ;
33import { withCodSpeed } from "." ;
44
5- const mockSimulation = vi . hoisted ( ( ) => ( {
6- setupCodspeedSimulationBench : vi . fn ( ) ,
5+ const mockAnalysis = vi . hoisted ( ( ) => ( {
6+ setupCodspeedAnalysisBench : vi . fn ( ) ,
77} ) ) ;
88
9- vi . mock ( "./simulation " , ( ) => ( {
10- ...mockSimulation ,
9+ vi . mock ( "./analysis " , ( ) => ( {
10+ ...mockAnalysis ,
1111} ) ) ;
1212
1313const mockWalltime = vi . hoisted ( ( ) => ( {
@@ -38,23 +38,33 @@ describe("withCodSpeed behavior without different codspeed modes", () => {
3838 expect ( shouldBeCalled . mock . calls . length ) . toBeGreaterThan ( 1000 ) ;
3939 } ) ;
4040
41- it ( "should run in simulation mode when CODSPEED_RUNNER_MODE=instrumentation" , async ( ) => {
41+ it ( "should run in analysis 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 ( mockSimulation . setupCodspeedSimulationBench ) . toHaveBeenCalled ( ) ;
47+ expect ( mockAnalysis . setupCodspeedAnalysisBench ) . toHaveBeenCalled ( ) ;
4848 expect ( mockWalltime . setupCodspeedWalltimeBench ) . not . toHaveBeenCalled ( ) ;
4949 } ) ;
5050
51- it ( "should run in simulation mode when CODSPEED_RUNNER_MODE=simulation" , async ( ) => {
51+ it ( "should run in analysis mode when CODSPEED_RUNNER_MODE=simulation" , async ( ) => {
5252 process . env . CODSPEED_ENV = "true" ;
5353 process . env . CODSPEED_RUNNER_MODE = "simulation" ;
5454
5555 withCodSpeed ( new Bench ( ) ) ;
5656
57- expect ( mockSimulation . setupCodspeedSimulationBench ) . toHaveBeenCalled ( ) ;
57+ expect ( mockAnalysis . setupCodspeedAnalysisBench ) . toHaveBeenCalled ( ) ;
58+ expect ( mockWalltime . setupCodspeedWalltimeBench ) . not . toHaveBeenCalled ( ) ;
59+ } ) ;
60+
61+ it ( "should run in analysis mode when CODSPEED_RUNNER_MODE=memory" , async ( ) => {
62+ process . env . CODSPEED_ENV = "true" ;
63+ process . env . CODSPEED_RUNNER_MODE = "memory" ;
64+
65+ withCodSpeed ( new Bench ( ) ) ;
66+
67+ expect ( mockAnalysis . setupCodspeedAnalysisBench ) . toHaveBeenCalled ( ) ;
5868 expect ( mockWalltime . setupCodspeedWalltimeBench ) . not . toHaveBeenCalled ( ) ;
5969 } ) ;
6070
@@ -64,7 +74,7 @@ describe("withCodSpeed behavior without different codspeed modes", () => {
6474
6575 withCodSpeed ( new Bench ( ) ) ;
6676
67- expect ( mockSimulation . setupCodspeedSimulationBench ) . not . toHaveBeenCalled ( ) ;
77+ expect ( mockAnalysis . setupCodspeedAnalysisBench ) . not . toHaveBeenCalled ( ) ;
6878 expect ( mockWalltime . setupCodspeedWalltimeBench ) . toHaveBeenCalled ( ) ;
6979 } ) ;
7080} ) ;
0 commit comments