11import { EventEmitter } from "events" ;
22import { spawn } from "child_process" ;
3+ import path from "path" ;
34
45import { describe , it , expect , vi , beforeEach , afterEach } from "vitest" ;
56
@@ -38,7 +39,8 @@ describe("getFunctionInfo", () => {
3839 } ,
3940 } ;
4041
41- const promise = getFunctionInfo ( "/path/to/extensions/my-function" ) ;
42+ const functionDir = "/path/to/extensions/my-function" ;
43+ const promise = getFunctionInfo ( functionDir ) ;
4244
4345 // Simulate successful CLI response
4446 setTimeout ( ( ) => {
@@ -48,12 +50,16 @@ describe("getFunctionInfo", () => {
4850
4951 const result = await promise ;
5052
53+ // Calculate expected cwd the same way the implementation does
54+ const resolvedFunctionDir = path . resolve ( functionDir ) ;
55+ const expectedCwd = path . dirname ( resolvedFunctionDir ) ;
56+
5157 expect ( result ) . toEqual ( mockFunctionInfo ) ;
5258 expect ( mockSpawn ) . toHaveBeenCalledWith (
5359 "shopify" ,
5460 [ "app" , "function" , "info" , "--json" , "--path" , "my-function" ] ,
5561 expect . objectContaining ( {
56- cwd : "/path/to/extensions" ,
62+ cwd : expectedCwd ,
5763 env : expect . objectContaining ( {
5864 SHOPIFY_INVOKED_BY : "shopify-function-test-helpers" ,
5965 } ) ,
0 commit comments