The advanced Node and Express challenges are failing even with correct code. (Pug is a dependency as well in my project.)
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const app = express();
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.sendFile(process.cwd() + '/views/index.html');
res.render(process.cwd() + '/views/pug/index.pug', {title: 'Hello', message: 'Please login'});
});
app.listen(process.env.PORT || 3000, () => {
console.log("Listening on port " + process.env.PORT);
});

I can confirm that the tests are failing even after completing the challenge successfully.
I tried to find out why is it failing by running it locally and putting some console.log in the file frame-runner.js but nothing showed up on the terminal. I tried it both on freecodecamp and learn repo but I got the same result.
Same here. Can't pass the " redirect to the home page /". I have res.redirect('/'); in my middlewares and redirect actually happens.
Having the same problem as SoulShaker. The redirect happens but still failing the test.
@a-nuen I've solved this issue. You should put somewhere on the page string 'Home page', for example on the h1, also for profile page you should add the string 'Profile'. You can check tests source code on the link https://github.com/freeCodeCamp/curriculum/blob/dev/challenges/06-information-security-and-quality-assurance/advanced-express-tools.json
@SoulShaker I got it to pass. Thank you.
For those who are continuing to fail the tests despite what has been printed here, I found a solution that worked for me!
You need to add the following code at the top of your server.js file:
const cors = require('cors');
app.use(cors());
This should work for at least some of the tests :)
My problem with this challange was the url. I had res.render('pug/profile', {username: req.user.username}); and it was failing. After checking the tests source code @SoulShaker provided, it turned out it's expecting 'views/pug/profile'. It passed once I changed the url in the render function to:
res.render(process.cwd() + '/views/pug/profile', {username: req.user.username});
Update: This tests no longer looks for a Profile string in the page.
what is the problem with my code why my test not passin


Got the test failing on the part of the challenge when a call to /profile should redirect to index. Followed @SoulShaker workaround. Worked well. Test is not correct.
I believe that the issue with the create new middleware challenge is the test that asserts that the redirect pattern will match /Home Page/. I think that the title of the root route must be changed to "Home Page" in order for this to pass. Or, at least that's what worked for me.
Most helpful comment
@a-nuen I've solved this issue. You should put somewhere on the page string 'Home page', for example on the h1, also for profile page you should add the string 'Profile'. You can check tests source code on the link https://github.com/freeCodeCamp/curriculum/blob/dev/challenges/06-information-security-and-quality-assurance/advanced-express-tools.json