question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Advanced Node and Express Challenges failing tests

See original GitHub issue

Describe your problem and - if possible - how to reproduce it

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);
});

Add a Link to the page with the problem

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

Tell us about your browser and operating system

  • Browser Name: Google Chrome
  • Browser Version: Version 67.0.3396.87 (Official Build) (64-bit)
  • Operating System: OSX Yosemite Version 10.10.3

If possible, add a screenshot here

screen shot 2018-06-18 at 12 51 18 pm

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
konstanting-devcommented, Jun 27, 2018

@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

2reactions
lieberscottcommented, Jul 12, 2018

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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Node and Express - ensureAuthenticated always ...
I've been passing all the tests, but the app is clearly not working. ... Advanced Node and Express - ensureAuthenticated always failing.
Read more >
Advanced Node and Express | FreeCodeCamp - YouTube
I go though the Advance Node and Express challenges on FreeCodeCamp. Most of these challenges are just copy and paste, so they weren't...
Read more >
Top Node.js Interview Questions and Answers in 2023 - Edureka
This blog lists the top Node.js interview questions you might be asked in Nodejs job interviews in 2023 on concepts such as Node.js...
Read more >
Performance Best Practices Using Express in Production
Node applications crash if they encounter an uncaught exception. The foremost thing you need to do is to ensure your app is well-tested...
Read more >
VSTest@2 - Visual Studio Test v2 task - Microsoft Learn
Collect process dump and attach to test run report. Default: onAbortOnly. #rerunFailedTests: False # boolean. Rerun failed tests. Default: False ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found