many fixes resulting from latest refactoring
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 5m57s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 5m57s
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
// and then applying it in the `vi.mock` call at the top level of the module. This resolves a variable
|
||||
// initialization error.
|
||||
//
|
||||
// 2024-08-01: Moved `vi.hoisted` declaration for `passportMocks` before the `vi.mock` call that uses it.
|
||||
// This fixes a "Cannot access before initialization" reference error during test setup by ensuring
|
||||
// the hoisted variable is declared before it's referenced.
|
||||
//
|
||||
// --- END FIX REGISTRY ---
|
||||
// src/routes/auth.routes.test.ts
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
@@ -83,14 +87,6 @@ const passportMocks = vi.hoisted(() => {
|
||||
return { authenticateMock };
|
||||
});
|
||||
|
||||
// 2. Call vi.mock at the top level, referencing the hoisted mock implementation.
|
||||
vi.mock('./passport.routes', () => ({
|
||||
default: {
|
||||
authenticate: vi.fn().mockImplementation(passportMocks.authenticateMock),
|
||||
initialize: () => (req: any, res: any, next: any) => next(),
|
||||
},
|
||||
}));
|
||||
|
||||
// Create a minimal Express app to host our router
|
||||
const app = express();
|
||||
app.use(express.json({ strict: false }));
|
||||
|
||||
Reference in New Issue
Block a user