Application State: Database vs API


#1

original from @davert in Slack:

REST API or GraphQL provides you with external API to create/read/update/delete data. Unlike, Database those APIs are public so you can use it in end 2 end tests. I recommend to expose public APIs for testing and not to connect to database directly as database structure is in internal application state, so developers can easily delete/update it without notifying you and breaking the tests.


#2

However, if you still need database access use Db helper https://www.npmjs.com/package/codeceptjs-dbhelper