1.0 KiB
1.0 KiB
Testing and Code Quality Rules
- No non-null assertions: Non-null assertions (the
!
operator) are a hack for missing null checks or extraneous null types. Always use proper null checks and handle possible null/undefined values explicitly. - Do not throw errors within tests: Use proper test assertions (e.g.,
expect(value).not.toBeNull()
) instead of throwing errors from within tests. This ensures test failures are reported clearly and consistently. - Do not use
any
: Use proper types instead ofany
. - Do not use
jest.fn()
: Use proper test assertions (e.g.,expect(value).not.toBeNull()
) instead of throwing errors from within tests. This ensures test failures are reported clearly and consistently. - Use the in-memory database for tests: Use the in-memory database for tests. This is a good way to test the code without having to set up a real database.
- Always use repositories for database operations: Use repositories for database operations. This is a good way to test the code without having to set up a real database.