Context
While contributing to and working with the repository, I noticed that all the test files (lib/schema.spec.ts) have to manually track and unregister every single registered schema inside their afterEach hooks:
afterEach(() => {
unregisterSchema(`${testDomain}/schema`);
unregisterSchema(`${testDomain}/relative-schema`);
unregisterSchema(`https://example.com/schema`);
});
The Problem
Currently, there is no public API to clear or flush the entire schema registry at once.
If any one forgets to unregister even a single schema in a spec file, that schema leaks into all subsequent tests. This results in state pollution, making it difficult to guarantee test isolation and potentially causing unpredictable test failures depending on the execution order.
Proposed Solution
Exposing a simple, top-level unregisterAllSchemas() function would solve this perfectly. It would allow developers to completely reset the registry's state.
We can define it by leveraging the existing getAllRegisteredSchemaUris() and unregisterSchema(uri) methods:
export const unregisterAllSchemas = () => {
for (const uri of getAllRegisteredSchemaUris()) {
unregisterSchema(uri);
}
};
This would:
- Provide a standard, robust way to reset the registry.
- Drastically simplify the repository's own unit tests by replacing repetitive
unregisterSchema lists with a single unregisterAllSchemas() call.
Please let me know if this looks like a valid addition! I would be very happy to implement this and open a PR to clean up the test suite.
Context
While contributing to and working with the repository, I noticed that all the test files (
lib/schema.spec.ts) have to manually track and unregister every single registered schema inside theirafterEachhooks:The Problem
Currently, there is no public API to clear or flush the entire schema registry at once.
If any one forgets to unregister even a single schema in a spec file, that schema leaks into all subsequent tests. This results in state pollution, making it difficult to guarantee test isolation and potentially causing unpredictable test failures depending on the execution order.
Proposed Solution
Exposing a simple, top-level
unregisterAllSchemas()function would solve this perfectly. It would allow developers to completely reset the registry's state.We can define it by leveraging the existing
getAllRegisteredSchemaUris()andunregisterSchema(uri)methods:This would:
unregisterSchemalists with a singleunregisterAllSchemas()call.Please let me know if this looks like a valid addition! I would be very happy to implement this and open a PR to clean up the test suite.