@@ -104,60 +104,84 @@ npx nx docs auth-js # Generate documentation
104104
105105### Testing
106106
107- ** Docker Required!** The auth-js tests require a local Supabase Auth server (GoTrue) running in Docker.
107+ The auth-js package has two test suites:
108+
109+ 1 . ** CLI Tests** - Main test suite using Supabase CLI (331 tests)
110+ 2 . ** Docker Tests** - Edge case tests requiring specific GoTrue configurations (11 tests)
111+
112+ #### Prerequisites
113+
114+ - ** Supabase CLI** - Required for main test suite ([ installation guide] ( https://supabase.com/docs/guides/cli ) )
115+ - ** Docker** - Required for edge case tests
116+
117+ #### Running Tests
108118
109119``` bash
110- # Run complete test suite (from monorepo root )
120+ # Run main test suite with Supabase CLI (recommended )
111121npx nx test:auth auth-js
122+
123+ # Run Docker-only edge case tests
124+ npx nx test:docker auth-js
125+
126+ # Run both test suites
127+ npx nx test:auth auth-js && npx nx test:docker auth-js
112128```
113129
114- This command automatically:
130+ #### Main Test Suite (Supabase CLI)
115131
116- 1 . Stops any existing test containers
117- 2 . Starts a Supabase Auth server (GoTrue) and PostgreSQL database in Docker
118- 3 . Waits for services to be ready (30 seconds)
119- 4 . Runs the test suite
120- 5 . Cleans up Docker containers after tests complete
132+ The ` test:auth ` command automatically:
121133
122- #### Individual Test Commands
134+ 1 . Stops any existing Supabase instance
135+ 2 . Starts a local Supabase instance via CLI
136+ 3 . Runs the test suite (excludes ` docker-tests/ ` folder)
137+ 4 . Cleans up after tests complete
123138
124139``` bash
125- # Run just the test suite (requires infrastructure to be running)
126- npx nx test:suite auth-js
140+ # Individual commands for manual control
141+ npx nx test:infra auth-js # Start Supabase CLI
142+ npx nx test:suite auth-js # Run tests only
143+ npx nx test:clean-post auth-js # Stop Supabase CLI
144+ ```
127145
128- # Manually manage test infrastructure
129- npx nx test:infra auth-js # Start Docker containers
130- npx nx test:clean auth-js # Stop and remove containers
146+ #### Docker Tests (Edge Cases)
147+
148+ The ` test:docker ` target runs tests that require specific GoTrue configurations not possible with a single Supabase CLI instance:
149+
150+ - ** Signup disabled** - Tests for disabled signup functionality
151+ - ** Asymmetric JWT (RS256)** - Tests for RS256 JWT verification
152+ - ** Phone OTP / SMS** - Tests requiring Twilio SMS provider
153+ - ** Anonymous sign-in disabled** - Tests for disabled anonymous auth
154+
155+ These tests are located in ` test/docker-tests/ ` and use the Docker Compose setup in ` infra/docker-compose.yml ` .
156+
157+ ``` bash
158+ # Individual commands for manual control
159+ npx nx test:docker:infra auth-js # Start Docker containers
160+ npx nx test:docker:suite auth-js # Run Docker tests only
161+ npx nx test:docker:clean-post auth-js # Stop Docker containers
131162```
132163
133164#### Development Testing
134165
135166For actively developing and debugging tests:
136167
137168``` bash
138- # Start infrastructure once
169+ # Start Supabase CLI once
139170npx nx test:infra auth-js
140171
141- # Run tests multiple times (faster since containers stay up)
172+ # Run tests multiple times (faster since instance stays up)
142173npx nx test:suite auth-js
143174
144175# Clean up when done
145- npx nx test:clean auth-js
176+ npx nx test:clean-post auth-js
146177```
147178
148179#### Test Infrastructure
149180
150- The Docker setup includes:
151-
152- - ** Supabase Auth (GoTrue)** - The authentication server
153- - ** PostgreSQL** - Database for auth data
154- - Pre-configured with test users and settings
155-
156- #### Prerequisites
157-
158- - ** Docker** must be installed and running
159- - Ports used by test infrastructure (check ` infra/docker-compose.yml ` )
160- - No full Supabase instance needed - just the Auth server
181+ | Suite | Infrastructure | Configuration |
182+ | ------------ | -------------- | --------------------------- |
183+ | CLI Tests | Supabase CLI | ` test/supabase/config.toml ` |
184+ | Docker Tests | Docker Compose | ` infra/docker-compose.yml ` |
161185
162186### Contributing
163187
0 commit comments