Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions e2e/smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,29 @@ test.describe("deployed environment", () => {
headers,
})
expect(signIn.status()).toBe(200)
const sessionCookie = signIn
.headersArray()
.filter((header) => header.name.toLowerCase() === "set-cookie")
.map((header) => header.value)
.find((cookie) => cookie.includes("session_token="))
// only the attributes, so a failure never prints the token
const attributes = sessionCookie
?.split(";")
.slice(1)
.map((attribute) => attribute.trim().toLowerCase())
expect(attributes).toEqual(
expect.arrayContaining(["secure", "httponly", "samesite=lax"]),
)

// better-auth refuses a POST without a JSON body (415)
const signOut = await request.post("/api/v1/auth/sign-out", {
data: {},
headers,
})
expect(signOut.status()).toBe(200)
// sign out even when an assertion fails, so no session row is left behind
try {
const sessionCookie = signIn
.headersArray()
.filter((header) => header.name.toLowerCase() === "set-cookie")
.map((header) => header.value)
.find((cookie) => cookie.includes("session_token="))
// only the attributes, so a failure never prints the token
const attributes = sessionCookie
?.split(";")
.slice(1)
.map((attribute) => attribute.trim().toLowerCase())
expect(attributes).toEqual(
expect.arrayContaining(["secure", "httponly", "samesite=lax"]),
)
} finally {
// better-auth refuses a POST without a JSON body (415)
const signOut = await request.post("/api/v1/auth/sign-out", {
data: {},
headers,
})
// soft, so a failed sign-out never hides the assertion error above
expect.soft(signOut.status()).toBe(200)
}
})
})
Loading