You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the improvement or update you wish to see?
Documentation on how to use playwright + next-auth
Is there any context that might help us understand?
I am currently using Playwright with the Next App Router and Mock Service Worker (MSW) to mock all API calls to a rest backend and i would like to mock the authenticated user as well.
I’ve noticed that the Microsoft authentication provider performs additional API calls to verify the validity of the token. I attempted to mock one of these calls using MSW:
// This mock intercepts API calls in the next backend onlyimport{createServer}from'@mswjs/http-middleware';consthttpServer=createServer(...[http.get('https://login.microsoftonline.com/*',()=>HttpResponse.json({claim_types_supported: ['normal'],claims_parameter_supported: false,grant_types_supported: ['authorization_code','implicit'],request_parameter_supported: false,request_uri_parameter_supported: false,require_request_uri_registration: false,//...})),]);
But i guess there is more to it?
Does the docs page already exist? Please link to it.
triageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
1 participant
Converted from issue
This discussion was converted from issue #12179 on November 05, 2024 10:51.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
What is the improvement or update you wish to see?
Documentation on how to use playwright + next-auth
Is there any context that might help us understand?
I am currently using Playwright with the Next App Router and Mock Service Worker (MSW) to mock all API calls to a rest backend and i would like to mock the authenticated user as well.
I made an snapshot of the auth state with
await page.context().storageState({ path: authFile });
: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests, However, the generated authFile appears to be insufficient:I’ve noticed that the Microsoft authentication provider performs additional API calls to verify the validity of the token. I attempted to mock one of these calls using MSW:
But i guess there is more to it?
Does the docs page already exist? Please link to it.
https://next-auth.js.org/guides/testing
Beta Was this translation helpful? Give feedback.
All reactions