Skip to content

"Advanced Node and Express - Set up a Template Engine" passes as correct despite wrong solution #38404

Closed

Description

@mehanix

Describe your problem and how to reproduce it:
When setting up Pug for the first time, even though I didn't choose to render the index.pug page, but sent it (using app.sendFile), the FCC checker passed my solution as correct.

Code that wrongly passes tests:

app.route('/')
  .get((req, res) => {
    res.sendFile(process.cwd() + '/views/pug/index.pug');
  });

Actual solution:

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

This is especially confusing for a beginner as the boilerplate comes with res.sendFile as a default, simply changing the path results in the behavior shown in the screenshots below.

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

Tell us about your browser and operating system:

  • Browser Name: Firefox
  • Browser Version: 74
  • Operating System: Linux Mint 19

If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
image

Activity

  1. added
    scope: curriculum
    status: waiting triage
    on Mar 20, 2020
  2. added
    help wanted
    on Mar 20, 2020
  3. jeremyfiel commented on Apr 19, 2020

    @jeremyfiel
    Contributor

    I've submitted PR's for {freeCodeCamp/boilerplate-advancednode/pull/9} & {/pull/38572} as part of this fix.

  4. scissorsneedfoodtoo commented on Apr 20, 2020

    @scissorsneedfoodtoo
    Contributor

    @mehanix, thank you for reporting this. We should try to test for cases where campers don't update the res.sendFile(...) line to res.render(...) as mentioned in the instructions.

    Also thank you @jeremyfiel for submitting PRs for this challenge. I'll leave some comments over in each of them.

  5. jeremyfiel commented on Apr 28, 2020

    @jeremyfiel
    Contributor

    fixed in the latest merge. Ok to close.

  6. ShaunSHamilton commented on Apr 29, 2020

    @ShaunSHamilton
    Member

    There is still an issue of the test not passing with correct solutions:

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

    OR

    app.route('/').get((req, res) => {
        res.render('./pug/index');
      });
    
  7. jeremyfiel commented on Apr 29, 2020

    @jeremyfiel
    Contributor

    There is still an issue of the test not passing with correct solutions:

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

    OR

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

    hi @SKY020 we've submitted another pr to relax the regex a bit more. it's pending review.

    I believe the single period (relative path) the way you've written it doesn't work in even the glitch app. It's pointing at the wrong path. should be .. or just /pug

  8. removed
    status: waiting triage
    on Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedscope: curriculum

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions