Replies: 1 comment
-
I don't think it can work that way. What I did was creating functions that returns objects for test data with all the necessary fields. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When trying to use the
subject()
helper to test an ability against an object it seems that the object requires every possible field from the Prisma table's type to exist in the object. My use case is testing a dto's fields against a query, ex. can a user submit a post of that type. It seems a lot of possible work to build an object with every possible field, ex{ id, createdAt, isDeleted, title, type }
, just because I want to test a single field.Am I doing this wrong, is it ok to use Partial when building the PrismaAbility type to attempt to fix this?
Maybe instead like this?
abilities.can('read', subject('Post', { type: 'foo' } as Post))
Beta Was this translation helpful? Give feedback.
All reactions