jdalrymple / gitbeaker

🦊🧪 A comprehensive and typed Gitlab SDK for Node.js, Browsers, Deno and CLI
Other
1.55k stars 295 forks source link

Is there a method for forcing termination of all gitbeaker connections on termination? #3477

Closed trevor-vaughan closed 10 months ago

trevor-vaughan commented 10 months ago

Description

I'm currently wrapping my CLI tool using gitbeaker in Jest tests and, while this works, there are dangling file descriptors related to attempting to contact gitlab servers that do not exist remaining after execution.

This seems to be causing Jest to kill unrelated tests at random intervals.

While I could possibly mock out all remote connections, that's a heck of a lot of effort.

So is there:

Checklist

jdalrymple commented 10 months ago

The only time it reaches out to a gitlab server is when there is a request, so would a request timeout work here?

trevor-vaughan commented 10 months ago

Well, I took a good solid try at it using jest-fetch-mock without any luck (it mocked but didn't actually work for some reason).

I think I'm going to have to use MSW and give some actual responses to fully test the workflow.

jdalrymple commented 10 months ago

Any chance you could share the code youre working on? Might help seeing the exact context youre working with.

trevor-vaughan commented 10 months ago

Unfortunately no. The gist of it is that I'm using jest to fire up the full entry point of a CLI tool in order to do full acceptance testing.

jdalrymple commented 10 months ago

Similar to what i do In the CLI tests of the library?

Is there anyway for you to abstract out a sample project that has the same issue?

trevor-vaughan commented 10 months ago

Ah yes, very similar to that test!

I'm not quite following how you're mocking out the server connection though.

jdalrymple commented 10 months ago

In that particular test, im not. Its a full e2e test. Here, i mock the whole rest package though.