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 DatabaseSupport.clean() from bill-licences #1221

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

Cruikshanks
Copy link
Member

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](https://nodejs.org/api/esm.html), [the official standard format](https://tc39.github.io/ecma262/#sec-modules) to package JavaScript code. Unit test frameworks other than [Hapi Lab](https://hapi.dev/module/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()`.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Jul 31, 2024
@Cruikshanks Cruikshanks self-assigned this Jul 31, 2024
@Cruikshanks Cruikshanks marked this pull request as ready for review July 31, 2024 22:30
Copy link
Contributor

@Beckyrose200 Beckyrose200 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cruikshanks Cruikshanks merged commit 22951ef into main Aug 1, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the remove-database-clean-from-bill-licences branch August 1, 2024 08:45
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants