"View Engine Should Be Pug" - Everything works but fails test

Tell us what’s happening:

The view engine works and the page is properly rendered, all other tests pass but “View engine should be Pug” still fails. Googled and found several other people with the same problem but no solutions.

Your code so far

'use strict';

const express     = require('express');
const bodyParser  = require('body-parser');
const fccTesting  = require('./freeCodeCamp/fcctesting.js');

const app = express();

const cors = require('cors');
app.use(cors());

fccTesting(app); //For FCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine',  'pug');

app.route('/')
  .get((req, res) => {
    res.render('pug/index.pug');
  });

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: undefined

Link to the challenge:
https://www.freecodecamp.org/learn/information-security-and-quality-assurance/advanced-node-and-express/set-up-a-template-engine

Hi Owen,

The tests for these exercises use regular expressions to find the correct syntax in your files. Here is the assertion for this test (which you can find in the markdown files here):

assert.match(data, /('|")view engine('|"),( |)('|")pug('|")/gi, 'Your project should set Pug as a view engine'); 

The assertion is expecting either 0 or 1 space between "view engine" and "pug". Looks like you have two or more. Please try removing the extra spaces and see if that works.

Thanks monksy! I really appreciate the help.

1 Like

No problem, glad to help. Happy coding :grinning: