Skip to content

Commit

Permalink
fix(tests): Resolve rate limit errors during testing
Browse files Browse the repository at this point in the history
- Updated rate limiter utility to bypass rate limiting in test environment.
- Ensured that the rateLimiter middleware allows all requests without restrictions when NODE_ENV is set to "test".
- This fix prevents test failures related to rate limiting while running automated tests.
  • Loading branch information
TKanX committed Oct 14, 2024
1 parent b286455 commit 8ffc839
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils/rateLimiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ const rateLimit = require("express-rate-limit");
* @returns {Function} - A rate limiter middleware.
*/
const rateLimiter = (max = 150, window = 5 * 60 * 1000) => {
if (process.env.NODE_ENV === "test") {
return (req, res, next) => {
next();
};
}

return rateLimit({
windowMs: window,
max,
Expand Down

0 comments on commit 8ffc839

Please sign in to comment.