Updating my findings.
In my project I have several permissions.
Just with the Factory from the repository was not enough as it only returns the user Authenticated.
So I had to move the factory from User to reuse elsewhere, and I made minor modifications.
First I had to populate the Permissions so I created a Factory for that:
Then create a Factory for Role:
And finally I made small adjustments to the Factory of the original User:
Now to test my Endpoint with the user and its correct permissions, I simply in beforeAll create the permissions to role the user and get the jwt:
It worked great, I was able to raise the strapi instance, register permissions, roles, user to be able to test my account.
Again I don’t know this is the best way to use the tests, but it worked fine.
1 Like