Replies: 1 comment 3 replies
-
Looks good. I have never used them, but pinging @RomainLanz as he shared test containers with me some time back. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I searched across Adonis documentation and discussions on Github about using of @testcontainers, but was surprised not find anything.
@testcontainers is a good tool, which allows to have database and not only for tests. For local and same way for CI.
So I figured out how to use it with Adonis and want to share. Guide is focused on PostgreSQL, but sure it can be simply adopted for another testcontainer. And sure it isn't the best way how to use it, so feedback is welcome.
First of all let's create initial point for any testcontainers:
start/testcontainers.ts
;await import('#start/testcontainers')
inbin/test.ts
beforeawait import('#start/env')
;So now we have point where is possible to initialise any testcontainer —
start/testcontainers.ts
.For example we need PostgreSQL for our tests:
npm i @testcontainers/postgresql --save-dev
;start/testcontainers.ts
with next content:tests/bootstrap.ts
inconfigureSuite
add next content:Here you can find more testcontainers for Node.js — https://testcontainers.com/modules/?language=nodejs
And if you use Colima, Podman or Rancher take a look to next article: https://node.testcontainers.org/supported-container-runtimes/
Beta Was this translation helpful? Give feedback.
All reactions