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

feat: enable async start/stop server #81

Merged
merged 1 commit into from
Oct 28, 2024

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
1 check passed
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