Bun fix the unit tests 4 - #9379
danieljbruce wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for running tests with Bun in the core/paginator package, including adding a Bun configuration, a test shim, and updating Jest configurations and test files to use bun:test imports. It also modifies CI scripts to handle Bun test execution and conditional test triggers. Feedback on the changes highlights two key issues: first, returning a promise when a callback is provided in src/index.ts can lead to unhandled promise rejections if the callback throws an error; second, reordering the conditional checks in run_conditional_tests.sh bypasses the skip logic for core packages during non-core triggers, unnecessarily wasting CI resources.
| return promise.then( | ||
| results => callback(null, results, query, ...otherArgs), | ||
| (err: Error) => callback(err), | ||
| ); |
There was a problem hiding this comment.
Returning the promise when a callback is provided can lead to unhandled promise rejections if the callback throws an error. Since callers using callbacks do not typically catch returned promises, any synchronous error thrown inside the callback will reject the returned promise and go unhandled. Use the void operator to discard the promise instead of returning it. Additionally, avoid wrapping the callback in an arrow function for the error case to prevent unnecessary closure allocations.
| return promise.then( | |
| results => callback(null, results, query, ...otherArgs), | |
| (err: Error) => callback(err), | |
| ); | |
| void promise.then( | |
| results => callback(null, results, query, ...otherArgs), | |
| callback, | |
| ); |
References
- Avoid wrapping methods in arrow functions for default cases to prevent unnecessary closure allocations and extra call stack frames.
| elif [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then | ||
| echo "change detected in ${d} for ${TEST_TYPE} test" | ||
| should_test=true | ||
| elif [[ "${d}" == core/packages/* ]] || [[ "${d}" == core/dev-packages/* ]]; then | ||
| echo "skipping core package ${d} in non-core trigger" | ||
| elif [[ "${TEST_TYPE}" == "system" ]] || [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then | ||
| elif [[ "${TEST_TYPE}" == "system" ]]; then | ||
| echo "change detected in ${d} for ${TEST_TYPE} test" | ||
| should_test=true |
There was a problem hiding this comment.
Placing the lint and units test checks above the core package skip check bypasses the skip logic for those test types in non-core triggers. This will cause core packages to run unit and lint tests unnecessarily during non-core trigger builds, wasting CI resources. Keep the core package skip check at the top of the conditional block.
| elif [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then | |
| echo "change detected in ${d} for ${TEST_TYPE} test" | |
| should_test=true | |
| elif [[ "${d}" == core/packages/* ]] || [[ "${d}" == core/dev-packages/* ]]; then | |
| echo "skipping core package ${d} in non-core trigger" | |
| elif [[ "${TEST_TYPE}" == "system" ]] || [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then | |
| elif [[ "${TEST_TYPE}" == "system" ]]; then | |
| echo "change detected in ${d} for ${TEST_TYPE} test" | |
| should_test=true | |
| elif [[ "${d}" == core/packages/* ]] || [[ "${d}" == core/dev-packages/* ]]; then | |
| echo "skipping core package ${d} in non-core trigger" | |
| elif [[ "${TEST_TYPE}" == "system" ]] || [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then | |
| echo "change detected in ${d} for ${TEST_TYPE} test" | |
| should_test=true |
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕