Set up a template engine - validation error

Tell us what’s happening:
I’m not able to validate the third point of the challenge Use the correct ExpressJS method to render the index page from the response..
I correctly rendered the page with:
res.render(process.cwd() + '/views/pug/index.pug');
But the assert regex doesn’t validate this sentence.

Your code so far

app.set('view engine', 'pug');
app.route("/").get((req, res) => {
  res.render(process.cwd() + '/views/pug/index.pug');

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.

Challenge: set-up-a-template-engine

Link to the challenge:

I have the same issue

Welcome, nank.

I know this is not ideal, but the challenge tests are being re-worked. The way I got through most of them is by looking at the test code for each challenge to make sure I was doing what was being tested for:

Here is the test expression for this test:

assert.match(data, /res(\s*)?\.(r\w{5})/gi)

You need to match the regex.

Looking over it, yours does match that. So, try moving the route around your script. It might randomly work.

Sorry, i could not be of more help. These tests are finicky.

1 Like

I passed this test
my code is here

"use strict";

const express = require("express");
const fccTesting = require("./freeCodeCamp/fcctesting.js");

const app = express();
const pug = require("pug");
const cors = require("cors");

fccTesting(app); //For FCC testing purposes
app.use("/public", express.static(process.cwd() + "/public"));
app.use(express.urlencoded({ extended: true }));

app.set('view engine', 'pug')

app.route("/").get((req, res) => {
  //Change the response to render the Pug template
  res.render(process.cwd() + "/views/pug/index", {
    title: "Hello",
    message: "Please login"

app.listen(process.env.PORT || 3000, () => {
  console.log("Listening on port " + process.env.PORT);


"dependencies": {
    "express": "^4.17.1",
    "cors": "^2.8.5",
    "pug": "^2.0.4"

I put the same in my previous script and failed to pass test, then started a new one from the link in the challenge and literally replaced res.send to res.render
May be this would be helpful


Thank you, I fixed requiring and using the cors dependency.

this worked for me:


note: do not forget to add pug dependency (“pug”: “^2.0.4”) to the package.json file.

Thanks stvo1980 for sharing this has helped me a lot!