Unit tests for Access Policies?
# support
z
Hi, is there a recommended way to write tests for my specific Access Policies? I've looked into the following: - Importing
@medplum/server
and using it similarly to its own tests (messy) - Using
MockClient
(
MemoryRepository
doesn't process "logged-in" logic) The only other option I see is spinning up a test server and database (in say, Docker) and making requests to it. Is there a recommended way to ensure my Access Policies are configured properly?
r
I do think your approach is sensible. YOu can also try "on-behalf-of" in tests

https://www.youtube.com/watch?v=IDhsWiIxK3o▾

z
Thanks for your quick reply! I'll take a look
@reshma I notice that "medplum_test" is a special database that exists. Do you happen to know if it auto-resets after tests are run on it, or generally what a good way might be to reset the test database before tests?
41 Views