Skip to content

feat: enable async start/stop server#81

Merged
knolleary merged 1 commit intonode-red:masterfrom
AllanOricil:vitest-setup
Oct 28, 2024
Merged

feat: enable async start/stop server#81
knolleary merged 1 commit intonode-red:masterfrom
AllanOricil:vitest-setup

Conversation

@AllanOricil
Copy link
Contributor

Callback using "done" in vitest was deprecated.

They recommend using async/await or add a arrow function that returns a promise. Since async/await is less verbose, making start/stop server async makes sense.

It shouldn't break current api implementation. People can still use done in test runners that have it

BEFORE/CURRENT

beforeEach(function(done){
    helper.startServer(done);
})

afterEach(function (done) {
    helper.unload();
    helper.stopServer(done);
});

AFTER

beforeEach(async function () {
    await helper.startServer();
});

afterEach(async function () {
    helper.unload();
    await helper.stopServer();
});

Callback using "done" in vitest was deprecated.
They recommend using async/await or add a arrow function that returns a promise.
Since async/await is less verbose, making start/stop server async makes sense.
@AllanOricil AllanOricil changed the title feat: enable start/stop server in vitest feat: enable async start/stop server Oct 28, 2024
@knolleary
Copy link
Member

Looks good - the core node unit tests all pass with this change in place.

There is a small risk this someone is calling stopServer without passing in a done callback which may now behave slightly differently due to making it async. But on the whole, I think we can consider that low risk (and simple enough to fix).

But we should make this a semver-minor change to 0.4.

@knolleary knolleary merged commit db9a73f into node-red:master Oct 28, 2024
AllanOricil added a commit to AllanOricil/node-red-node-test-helper that referenced this pull request Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants