1+ /**
2+ * Express Route Detection
3+ *
4+ * This approach checks routes without making HTTP requests by
5+ * directly inspecting the Express app's routing table.
6+ */
7+
18import request from "supertest"
29import { jest } from "@jest/globals"
310import api_routes from "../routes/api-routes.js"
411import app from "../app.js"
512import fs from 'fs'
613
7- /**
8- * Express 5 Route Detection
9- *
10- * Key changes from Express 4 to Express 5:
11- * 1. Router is accessed via app.router (not app._router)
12- * 2. Layers use 'matchers' array instead of 'regexp' property
13- * 3. Each matcher is a function that tests if a path matches
14- * 4. Matchers return match info including path and params, or false
15- *
16- * This approach checks routes without making HTTP requests by
17- * directly inspecting the Express app's routing table.
18- */
1914let app_stack = app . router . stack
2015let api_stack = api_routes . stack
2116
2217/**
23- * Helper function to check if a route exists in Express 5
24- * In Express 5, layers use 'matchers' instead of 'regexp'
18+ * Check if a route exists in the Express app
2519 * @param {Array } stack - The router stack to search
2620 * @param {string } testPath - The path to test for
2721 * @returns {boolean } - True if the route exists
@@ -141,5 +135,7 @@ describe('Check to see that critical repo files are present', () => {
141135 expect ( fs . existsSync ( filePath + "CONTRIBUTING.md" ) ) . toBeTruthy ( )
142136 expect ( fs . existsSync ( filePath + "README.md" ) ) . toBeTruthy ( )
143137 expect ( fs . existsSync ( filePath + "LICENSE" ) ) . toBeTruthy ( )
138+ expect ( fs . existsSync ( filePath + ".gitignore" ) ) . toBeTruthy ( )
139+ expect ( fs . existsSync ( filePath + "jest.config.js" ) ) . toBeTruthy ( )
144140 } )
145141} )
0 commit comments