1- import fs from "fs" ;
1+ import { promises } from "fs" ;
22import { homedir } from "os" ;
33import { join } from "path" ;
4+ import { afterEach , beforeEach , describe , expect , test as it , vi } from "vitest" ;
45
56import { fromSSO } from "./fromSSO" ;
67
@@ -15,22 +16,18 @@ sso_start_url = https://my-sso-portal.awsapps.com/start
1516sso_registration_scopes = sso:account:access
1617` ;
1718
18- jest . mock ( "fs" , ( ) => {
19- return {
20- promises : {
21- readFile : jest . fn ( ) ,
22- } ,
23- } ;
24- } ) ;
19+ vi . mock ( "fs" , ( ) => ( { promises : { readFile : vi . fn ( ) } } ) ) ;
2520
2621describe ( "fromSSO integration test" , ( ) => {
2722 beforeEach ( ( ) => {
28- jest . resetAllMocks ( ) ;
23+ vi . mocked ( promises . readFile ) . mockResolvedValue ( SAMPLE_CONFIG ) ;
2924 } ) ;
3025
31- it ( "should expand relative homedir" , async ( ) => {
32- const mockReadFile = ( fs . promises . readFile as jest . Mock ) . mockResolvedValue ( SAMPLE_CONFIG ) ;
26+ afterEach ( ( ) => {
27+ vi . clearAllMocks ( ) ;
28+ } ) ;
3329
30+ it ( "should expand relative homedir" , async ( ) => {
3431 try {
3532 await fromSSO ( {
3633 profile : "dev" ,
@@ -39,7 +36,7 @@ describe("fromSSO integration test", () => {
3936 } ) ( ) ;
4037 } catch ( ignored ) { }
4138
42- expect ( mockReadFile ) . toHaveBeenCalledWith ( join ( homedir ( ) , "custom/path/to/credentials" ) , "utf8" ) ;
43- expect ( mockReadFile ) . toHaveBeenCalledWith ( join ( homedir ( ) , "custom/path/to/config" ) , "utf8" ) ;
39+ expect ( promises . readFile ) . toHaveBeenCalledWith ( join ( homedir ( ) , "custom/path/to/credentials" ) , "utf8" ) ;
40+ expect ( promises . readFile ) . toHaveBeenCalledWith ( join ( homedir ( ) , "custom/path/to/config" ) , "utf8" ) ;
4441 } ) ;
4542} ) ;
0 commit comments