Close all handles during Jest teardown #2330
Conversation
Are you sure the changelog does not need updating? |
2 similar comments
Are you sure the changelog does not need updating? |
Are you sure the changelog does not need updating? |
|
Silly me, forgot to do the same for e2e tests (not just dry)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are a genius Lucas :)
Go job figuring that one out!
api_tests/src/utils.ts
Outdated
reject(new Error(`timed out after ${ms}ms`)); | ||
}, ms); | ||
}); | ||
|
||
// Returns a race between our timeout and the passed in promise | ||
return Promise.race([promise, timeout]); | ||
return Promise.race([promise, timeout]).then((result) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe use .finally here, just to be sure?
@@ -0,0 +1,5 @@ | |||
jasmine.getEnv().addReporter({ | |||
specStarted: (result) => | |||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get typings for this instead of using ts-ignore
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can help me figure this one out.
I now realise that I'm using the jasmine
namespace to set and read a value which wasn't there in the first place i.e. there is no type because I'm creating that "field".
Would it make more sense to save this to the global context of the e2e test suite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense to save this to the global context of the e2e test suite?
I guess not because this global context can be accessed by two tests running concurrently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just gonna leave this one as an optional follow-up PR. Had a look at merging namespaces to extend the one provided by jest
with the type we need here, but there's probably a much easier approach that I'm missing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not because this global context can be accessed by two tests running concurrently.
The test environment provides a unique instance of global to every test so you can safely set things there!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But yes, we can do this as a follow-up. I don't have time at the moment so you could write a short issue please? :)
So many good fixes in this one :) |
176: Add close method for bcoin wallet r=mergify[bot] a=luckysori These are a couple of patches that need to be released before comit-network/comit-rs#2330 can be merged in. Co-authored-by: Lucas Soriano del Pino <l.soriano.del.pino@gmail.com>
127a4a2
to
b90d60f
Compare
`yalc` seems more reliable than `yarn link`.
This allows us to remove the weird `smack-my-jasmine-up` dependency.
We ensure that all nodes are stopped and all wallets are closed during Jest teardown.
To prevent reaching the limit of listeners.
b90d60f
to
3fb3ffb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job.
bors r+ |
1 similar comment
bors r+ |
Already running a review |
Build succeeded |
Motivated by the combination of wanting to test `tryExecuteSirenAction` and realising that we would just be testing `timeoutPromise`. We have already decided to replace exactly the same function in `comit-rs` (comit-network/comit-rs#2330 (comment)), so replacing it here has the nice consequence of not needing to write a new test, since it's not our own code. Side-effects: - Move `TryParams` to `swap.ts` since it's directly related and only used for executing a swap. - Rename `util/timeout_promise.ts` to `util/sleep.ts`, since it now only holds a `sleep` function.
179: Replace timeout function with external dependency r=mergify[bot] a=luckysori Fixes #120 (imo). ## Straight from the commit Motivated by the combination of wanting to test `tryExecuteSirenAction` and realising that we would just be testing `timeoutPromise`. We have already decided to replace exactly the same function in `comit-rs` (comit-network/comit-rs#2330 (comment)), so replacing it here has the nice consequence of not needing to write a new test, since it's not our own code. Side-effects: - Move `TryParams` to `swap.ts` since it's directly related and only used for executing a swap. - Rename `util/timeout_promise.ts` to `util/sleep.ts`, since it now only holds a `sleep` function. ## Notes I don't believe this requires a changelog update. Am I wrong? Co-authored-by: Lucas Soriano del Pino <l.soriano.del.pino@gmail.com>
Waiting for comit-network/comit-js-sdk#176 to be merged and for those changes to be included in a release of
comit-js-sdk
before we can update the last commit in this PR to use that release instead of a local dependency created viayalc
(which seems to work much better thanyarn link
).Fixes #2211.
when tests hang after passing, but it just doesn't seem to do anything. I tried using
leaked-handles
without success, but finally foundwtfnode
, which identifiedbcoin
as the culprit.My OCD was definitely triggered with this one, as a different error got me to investigate how to get rid of
smack-my-jasmine-up
. Turns out removing it did not fix that other error, but I still see it as a win, since depending on such an obscure library is bad.And another bug squashed! No more
errors, by combining cde8e0c and 127a4a2:
I believe log files can be reopened if something else needs to be logged.