Closed Julien-R44 closed 10 months ago
tests will fail cause of the last two commits since we dont have TestUtils exported from @adonisjs/core/test_utils
.
We should export TestUtils class from @adonisjs/core in order to be able to extend it with macros. Which export path should we use ? @adonisjs/core/test_utils' ? Let me know and I will make a PR on core
Yeah, we can export it from /test_utils
submodule.
not sure about this one. Naively, i would say no, but : could it cause some problems to register testUtils bindings only in test environnement ?
We can use the container resolving
hook. https://docs.adonisjs.com/guides/ioc-container#container-hooks
not sure here too. should we resolve the Ace binding immediately ?
Yeah, can be lazily resolved as someone uses one of the methods from the DatabaseTestUtils
class.
Should be all good. Let me just know if we keep withGlobalTransaction
or not. Also if naming look correct to you
Looks good.
We will have to create a new doc under the testing group, inside the AdonisJS documentation covering the usage of these hooks
Changes
Add a DatabaseTestUtils class. Works as before.
testUtils.db().migrate()
testUtils.db().truncate()
testUtils.db().seed()
, We can also pass a custom connectionName liketestUtils.db('secondary').seed()
Also, let me know if we should not keep it, but though it would be cool to include a
testUtils.db().withGlobalTransaction()
method that can be used like this :So every test in this group will be wrapped a transaction that will be reverted at the end of the test