Skip to content

Commit 46db62a

Browse files
committed
test(stack): assert clerkJwtProvider throws when its token env var is unset
Closes the review gap: the identity suites' "fail rather than skip" contract rests on clerkJwtProvider throwing when CLERK_MACHINE_TOKEN is unset, but nothing asserted it — a weakening to a skip/undefined would take the identity suite dark while CI stayed green. The throw fires before createClerkClient, so this is a credential-free unit test. Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
1 parent 7f89201 commit 46db62a

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { afterEach, describe, expect, it } from 'vitest'
2+
import { clerkJwtProvider } from '../integration/helpers/clerk'
3+
4+
/**
5+
* `clerkJwtProvider`'s "FAIL rather than skip" guard is the load-bearing half of
6+
* the identity suites' no-silent-skip contract: if it were ever weakened to a
7+
* skip or a silent `undefined`, the entire identity suite would go dark while CI
8+
* stayed green. The throw is pure logic — it fires before `createClerkClient`,
9+
* so it needs no live Clerk and belongs here in the credential-free unit suite
10+
* rather than the integration config (which only globs `*.integration.test.ts`).
11+
*/
12+
describe('clerkJwtProvider', () => {
13+
const saved = process.env.CLERK_MACHINE_TOKEN
14+
const savedB = process.env.CLERK_MACHINE_TOKEN_B
15+
afterEach(() => {
16+
if (saved === undefined) delete process.env.CLERK_MACHINE_TOKEN
17+
else process.env.CLERK_MACHINE_TOKEN = saved
18+
if (savedB === undefined) delete process.env.CLERK_MACHINE_TOKEN_B
19+
else process.env.CLERK_MACHINE_TOKEN_B = savedB
20+
})
21+
22+
it('throws (does not skip) when the default machine token env var is unset', () => {
23+
delete process.env.CLERK_MACHINE_TOKEN
24+
expect(() => clerkJwtProvider()).toThrow(/missing CLERK_MACHINE_TOKEN/)
25+
})
26+
27+
it('names the custom env var it was handed', () => {
28+
delete process.env.CLERK_MACHINE_TOKEN_B
29+
expect(() => clerkJwtProvider('CLERK_MACHINE_TOKEN_B')).toThrow(
30+
/CLERK_MACHINE_TOKEN_B/,
31+
)
32+
})
33+
})

0 commit comments

Comments
 (0)