Approach to unit testing subscription criteria
# support
n
What would be the recommended approach for unit testing subscription criteria including the
criteria
field and the Medplum-specific filter extensions? Having access to
matchesCriteria
could be valuable to enable unit testing https://github.com/medplum/medplum/blob/7b3bc8c51f49975c372d63a18bc77cad824aa76d/packages/server/src/workers/subscription.ts#L264-L269, although,
withTestContext
would also need to be made available https://github.com/medplum/medplum/blob/7b3bc8c51f49975c372d63a18bc77cad824aa76d/packages/server/src/test.setup.ts#L275 I see some of the internal unit tests are mocking the repo and subscription queue but this seems fairly cumbersome and also requires the withTestContext https://github.com/medplum/medplum/blob/7b3bc8c51f49975c372d63a18bc77cad824aa76d/packages/server/src/workers/subscription.test.ts#L1303-L1344
r
Sorry for the delay here - still researching this one!
n
All good and thanks for the followup. FWIW, I took a stab at shuffling around the existing functionality to enable unit testing without dependency on the server request context and repository. Opened a PR here https://github.com/medplum/medplum/pull/4581
152 Views