@@ -165,7 +165,7 @@ describe('runConfigure', () => {
165165 const { capture, deps } = makeCapture ( ) ;
166166 // Pre-existing dev profile — re-running configure interactively must keep it
167167 // (the internal dogfooding flow) without ever prompting for the endpoint.
168- writeProfile (
168+ await writeProfile (
169169 'dev' ,
170170 { apiKey : 'sk-old' , apiUrl : 'https://api.example.com:8443' } ,
171171 { path : credentialsPath } ,
@@ -350,7 +350,7 @@ describe('runConfigure', () => {
350350 it ( 'dogfood-2026-05-25 — --from-env without TESTSPRITE_API_URL inherits existing profile api_url AND validates against it' , async ( ) => {
351351 const { capture, deps } = makeCapture ( ) ;
352352 // Pre-write an existing profile with a custom (non-default) endpoint.
353- writeProfile (
353+ await writeProfile (
354354 'default' ,
355355 { apiKey : 'sk-old' , apiUrl : 'https://api.example.com' } ,
356356 { path : credentialsPath } ,
@@ -398,7 +398,7 @@ describe('runConfigure', () => {
398398
399399 it ( 'dogfood-2026-05-25 — --endpoint-url flag overrides existing profile api_url' , async ( ) => {
400400 const { capture, deps } = makeCapture ( ) ;
401- writeProfile (
401+ await writeProfile (
402402 'default' ,
403403 { apiKey : 'sk-old' , apiUrl : 'https://api.example.com' } ,
404404 { path : credentialsPath } ,
@@ -428,7 +428,7 @@ describe('runConfigure', () => {
428428 it ( 'dogfood-2026-05-25 — no advisory when inherited url equals DEFAULT_API_URL' , async ( ) => {
429429 const { capture, deps } = makeCapture ( ) ;
430430 // Existing profile has the default prod endpoint — no advisory needed.
431- writeProfile (
431+ await writeProfile (
432432 'default' ,
433433 { apiKey : 'sk-old' , apiUrl : 'https://api.testsprite.com' } ,
434434 { path : credentialsPath } ,
@@ -504,7 +504,7 @@ describe('runConfigure', () => {
504504 // An exported-but-empty env var (`export TESTSPRITE_API_URL=`) must not
505505 // short-circuit the `??` chain to an empty endpoint; it should fall through
506506 // to the existing profile's api_url.
507- writeProfile (
507+ await writeProfile (
508508 'default' ,
509509 { apiKey : 'sk-old' , apiUrl : 'https://api.example.com:8443' } ,
510510 { path : credentialsPath } ,
@@ -610,7 +610,7 @@ describe('runWhoami', () => {
610610 }
611611
612612 it ( 'calls GET /me using the configured profile and prints text output' , async ( ) => {
613- writeProfile (
613+ await writeProfile (
614614 'default' ,
615615 { apiKey : 'sk-stored' , apiUrl : 'https://api.example.com' } ,
616616 { path : credentialsPath } ,
@@ -633,7 +633,7 @@ describe('runWhoami', () => {
633633 } ) ;
634634
635635 it ( 'emits JSON when --output json' , async ( ) => {
636- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
636+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
637637 const { capture, deps } = makeCapture ( ) ;
638638 await runWhoami (
639639 { profile : 'default' , output : 'json' , debug : false } ,
@@ -644,7 +644,7 @@ describe('runWhoami', () => {
644644 } ) ;
645645
646646 it ( 'L1788: text output includes the resolved endpoint URL' , async ( ) => {
647- writeProfile (
647+ await writeProfile (
648648 'default' ,
649649 { apiKey : 'sk-stored' , apiUrl : 'https://api.example.com' } ,
650650 { path : credentialsPath } ,
@@ -672,7 +672,7 @@ describe('runWhoami', () => {
672672 } ) ;
673673
674674 it ( 'L1788: JSON output does NOT add endpoint (raw /me envelope is passed through)' , async ( ) => {
675- writeProfile (
675+ await writeProfile (
676676 'default' ,
677677 { apiKey : 'sk-stored' , apiUrl : 'https://api.example.com' } ,
678678 { path : credentialsPath } ,
@@ -701,7 +701,7 @@ describe('runWhoami', () => {
701701 } ) ;
702702
703703 it ( 'L1866: renders email + name in text mode when the backend supplies them' , async ( ) => {
704- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
704+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
705705 const { capture, deps } = makeCapture ( ) ;
706706 const meWithEmail = new Response (
707707 JSON . stringify ( { ...sampleMe , email : 'alice@example.com' , displayName : 'Alice' } ) ,
@@ -718,7 +718,7 @@ describe('runWhoami', () => {
718718 } ) ;
719719
720720 it ( 'L1866: omits email/name lines when the backend does not return them' , async ( ) => {
721- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
721+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
722722 const { capture, deps } = makeCapture ( ) ;
723723 await runWhoami (
724724 { profile : 'default' , output : 'text' , debug : false } ,
@@ -731,7 +731,7 @@ describe('runWhoami', () => {
731731 } ) ;
732732
733733 it ( 'L1866: passes email through verbatim in JSON mode when present' , async ( ) => {
734- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
734+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
735735 const { capture, deps } = makeCapture ( ) ;
736736 const meWithEmail = new Response ( JSON . stringify ( { ...sampleMe , email : 'alice@example.com' } ) , {
737737 status : 200 ,
@@ -769,7 +769,7 @@ describe('runWhoami', () => {
769769 } ) ;
770770
771771 it ( 'emits debug events to stderr when debug is enabled' , async ( ) => {
772- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
772+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
773773 const { capture, deps } = makeCapture ( ) ;
774774 await runWhoami (
775775 { profile : 'default' , output : 'json' , debug : true } ,
@@ -782,7 +782,7 @@ describe('runWhoami', () => {
782782 } ) ;
783783
784784 it ( 'forwards server AUTH_INVALID with exit code 3' , async ( ) => {
785- writeProfile ( 'default' , { apiKey : 'sk-bad' } , { path : credentialsPath } ) ;
785+ await writeProfile ( 'default' , { apiKey : 'sk-bad' } , { path : credentialsPath } ) ;
786786 const { deps } = makeCapture ( ) ;
787787 const errorBody = {
788788 error : {
@@ -812,7 +812,7 @@ describe('runWhoami', () => {
812812 ...sampleMe ,
813813 scopes : [ 'read:projects' , 'read:tests' ] ,
814814 } ;
815- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
815+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
816816 const { capture, deps } = makeCapture ( ) ;
817817 const fetchImpl = makeFetch (
818818 new Response ( JSON . stringify ( readOnlyMe ) , {
@@ -835,7 +835,7 @@ describe('runWhoami', () => {
835835 ...sampleMe ,
836836 scopes : [ 'read:projects' , 'read:tests' , 'write:tests' , 'run:tests' ] ,
837837 } ;
838- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
838+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
839839 const { capture, deps } = makeCapture ( ) ;
840840 const fetchImpl = makeFetch (
841841 new Response ( JSON . stringify ( fullMe ) , {
@@ -856,7 +856,7 @@ describe('runWhoami', () => {
856856 ...sampleMe ,
857857 scopes : [ 'read:projects' , 'read:tests' ] ,
858858 } ;
859- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
859+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
860860 const { capture, deps } = makeCapture ( ) ;
861861 const fetchImpl = makeFetch (
862862 new Response ( JSON . stringify ( readOnlyMe ) , {
@@ -878,8 +878,8 @@ describe('runWhoami', () => {
878878
879879describe ( 'runLogout' , ( ) => {
880880 it ( 'removes the profile and reports success' , async ( ) => {
881- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
882- writeProfile ( 'dev' , { apiKey : 'sk-dev' } , { path : credentialsPath } ) ;
881+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
882+ await writeProfile ( 'dev' , { apiKey : 'sk-dev' } , { path : credentialsPath } ) ;
883883 const { capture, deps } = makeCapture ( ) ;
884884 await runLogout (
885885 { profile : 'default' , output : 'text' , debug : false } ,
@@ -927,7 +927,7 @@ describe('createAuthCommand wiring', () => {
927927 } ) ;
928928
929929 it ( 'remove deletes the active profile and exits 0' , async ( ) => {
930- writeProfile ( 'default' , { apiKey : 'sk-remove' } , { path : credentialsPath } ) ;
930+ await writeProfile ( 'default' , { apiKey : 'sk-remove' } , { path : credentialsPath } ) ;
931931 const { deps } = makeCapture ( ) ;
932932 const auth = createAuthCommand ( { ...deps , credentialsPath } ) ;
933933 auth . exitOverride ( ) ;
@@ -937,7 +937,7 @@ describe('createAuthCommand wiring', () => {
937937 } ) ;
938938
939939 it ( 'deprecated `whoami` alias emits a deprecation notice pointing at `auth status`' , async ( ) => {
940- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
940+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
941941 const { capture, deps } = makeCapture ( ) ;
942942 const auth = createAuthCommand ( {
943943 ...deps ,
@@ -953,7 +953,7 @@ describe('createAuthCommand wiring', () => {
953953 } ) ;
954954
955955 it ( 'whoami uses injected fetch and exits 0' , async ( ) => {
956- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
956+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
957957 const { deps } = makeCapture ( ) ;
958958 const fetchImpl = vi . fn (
959959 async ( ) =>
@@ -970,7 +970,7 @@ describe('createAuthCommand wiring', () => {
970970 } ) ;
971971
972972 it ( 'L1802: `status` alias resolves to the whoami action' , async ( ) => {
973- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
973+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
974974 const { deps } = makeCapture ( ) ;
975975 const fetchImpl = vi . fn (
976976 async ( ) =>
@@ -987,7 +987,7 @@ describe('createAuthCommand wiring', () => {
987987 } ) ;
988988
989989 it ( 'logout removes the profile' , async ( ) => {
990- writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
990+ await writeProfile ( 'default' , { apiKey : 'sk' } , { path : credentialsPath } ) ;
991991 const { deps } = makeCapture ( ) ;
992992 const auth = createAuthCommand ( { ...deps , credentialsPath } ) ;
993993 auth . exitOverride ( ) ;
0 commit comments