Blank DB for every single test
See original GitHub issueI would like to have a clean DB for every single unit test.
I’m using more or less the code from your README. However I’m using beforeEach
and afterEach
instead of *All
. I would have expected the database to be clear after closing the connection in one unit test and creating a new one in the next, but apparently this is not the case.
When rerunning the tests, the first test always starts from a “clean” database. How can I achieve this for every test? At the moment, to achieve what I want, I drop the tables in afterEach
, but I’m sure there must be a better approach? You can view me code here.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Testing for an Empty Database - LearnHowToProgram.com
As always, we begin by testing the simplest possible behavior. In this case, we'll start with a test to make sure the database...
Read more >Loopback 4 empty database before a test - Stack Overflow
I want to empty the database before my acceptance test cases. ... It will generate the datasource similar to the last one I...
Read more >Empty database after test - Laracasts
I thought I've set everything up to use the memory database and don't test against my MySQL database. But after every test my...
Read more >Database (Data) Testing Tutorial with Sample Test Cases
Database Testing is checking the schema, tables, triggers, etc. of the ... we will look into each type and its sub-types one by...
Read more >Create an Empty SQL Server Unit Test - Microsoft Learn
The following procedures explain how to create SQL Server unit tests for any database object. SQL Server Data Tools includes some additional ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I agree and @aymericbouzy I have the same issue. Any ideas on how to fix it?
Same issue, I moved to mongodb-memory-server and everything works fine.