Build a Submission Form - Lesson 17, Test 1 failed

Tell us what’s happening:

I’m stuck on Build a Submission Form - Lesson 17. Help me please,

Your code so far

// middleware/error.middleware.js
function notFoundHandler(req, res, next) {
  const error = new Error(`Cannot find ${req.originalUrl}`);
  error.status = 404;
  next(error);
}
// routes/api.routes.js
import { Router } from "express";

const router = Router();

router.get("/", (req, res) => {
  res.send("API is available!");
});

router.get("/crash", (req, res, next) => {
  const err = new Error("Database connection failed.");
  next(err);
});

router.get("/bad-request", (req, res, next) => {
  const err = new Error("Client-side data is missing.");
  err.status = 400;
  next(err);
});

export default router;

// server.js
import express from "express";
import apiRouter from "./routes/api.routes.js";

const app = express();

app.use((req, res, next) => {
  console.log(req.method);
  console.log(req.url);
  next();
});

app.use(express.json());

app.use(express.urlencoded({ extended: true }));

app.use("/api", apiRouter);

app.listen(3000, () => {
  console.log(`Server started, on localhost:3000`);
});

Tests 2 and 3 clearly see the function code, so the file is being read. But Test 1 asserts the function is `undefined`, which suggests it’s trying to import the export and failing — even though the export works when I test it manually. Any ideas what I’m missing? Or is this a known issue with the test runner? Thanks!

P.S.: Running on Codespace

“Update: Same failure now occurs for finalErrorHandler in the next lesson. Both handlers are exported correctly (verified via runtime import), and Tests 2/3 can read the function bodies, but Test 1 for each handler asserts the function isn’t declared. Looks like a systematic issue with how these particular tests import from middleware/error.middleware.js.”

I will open a bug issue on this, meanwhile try declaring notFoundHandler with const and an arrow function