Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove more DatabaseSupport.clean() #1285

Merged
merged 12 commits into from
Aug 23, 2024
Merged

Conversation

jonathangoulding
Copy link
Collaborator

DEFRA/water-abstraction-team#124

We had a pattern of calling await DatabaseSupport.clean() in a beforeEach() in any unit test file that depended on adding data to support its tests.

The problem is that the project is becoming so large that it is no longer sustainable. It is also a blocker to moving to a test framework that supports ECMAScript Modules, the official standard format to package JavaScript code. Unit test frameworks other than Hapi Lab run tests in parallel by default. This means you can't have one test running DB clean while another is trying to load data.

New tests avoid the pattern, and where we can, we've been updating old ones when we have had cause to update the unit tests.

But there are always those where it'll be some time before we have cause to look at them again. So, rather than waiting, this change handles updating all tests in test/services/bill-licences to drop their dependence on DatabaseSupport.clean().

DEFRA/water-abstraction-team#124

We had a pattern of calling await DatabaseSupport.clean() in a beforeEach() in any unit test file that depended on adding data to support its tests.

The problem is that the project is becoming so large that it is no longer sustainable. It is also a blocker to moving to a test framework that supports ECMAScript Modules, the official standard format to package JavaScript code. Unit test frameworks other than Hapi Lab run tests in parallel by default. This means you can't have one test running DB clean while another is trying to load data.

New tests avoid the pattern, and where we can, we've been updating old ones when we have had cause to update the unit tests.

But there are always those where it'll be some time before we have cause to look at them again. So, rather than waiting, this change handles updating all tests in test/services/bill-licences to drop their dependence on DatabaseSupport.clean().
@jonathangoulding jonathangoulding added housekeeping Refactoring, tidying up or other work which supports the project testing A change to the tests or CI labels Aug 23, 2024
@jonathangoulding jonathangoulding self-assigned this Aug 23, 2024
@jonathangoulding jonathangoulding marked this pull request as ready for review August 23, 2024 15:08
@Cruikshanks
Copy link
Member

First run 3 mins 32 secs. Last run 2 mins 51 seconds. (unit tests)

Every little helps!

@jonathangoulding jonathangoulding merged commit 23271ac into main Aug 23, 2024
6 checks passed
@jonathangoulding jonathangoulding deleted the remove-database-clean-simple branch August 23, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project testing A change to the tests or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants