Skip to content

Commit dafa160

Browse files
committed
test(auth): mock fetch for jsdom
1 parent f8ccef8 commit dafa160

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/core/auth-js/test/GoTrueClient.browser.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ describe('GoTrueClient in browser environment', () => {
8080
})
8181

8282
it('should handle PKCE flow', async () => {
83+
// Mock fetch since jsdom doesn't provide it, and we're testing browser behavior not HTTP
84+
global.fetch = jest.fn().mockResolvedValue({
85+
ok: true,
86+
json: async () => ({
87+
access_token: 'test-token',
88+
refresh_token: 'test-refresh-token',
89+
expires_in: 3600,
90+
token_type: 'bearer',
91+
user: {
92+
id: 'test-user-id',
93+
94+
created_at: new Date().toISOString(),
95+
},
96+
}),
97+
})
98+
8399
const { email, password } = mockUserCredentials()
84100
const pkceClient = getClientWithSpecificStorage({
85101
getItem: jest.fn(),

0 commit comments

Comments
 (0)