Advanced Node and Express - Implementation of Social Authentication Issues with the testing

For anybody trying to complete these tests, there are some issues you may come across. I found them through searching and finding a GitHub issue that is open.

I wish I could just fix the issue but it is currently above my ability level.

Due to the previous test in where you clean up the code into different modules. There is now a ./routes.js file with the routes in there. If you place your new code in this file it will fail the tests.

To pass the tests the new social implementation code must go into the original server.js file


@abellinii Thanks for the tip!

Thanks man, saved me a night of desperation and panic

For anyone else that may run into this, I had to start a new Glitch project from the first Implementation of Social Authentication challenge. The authentication project I was working on up until this point wasn’t compatible with the social authentication challenges. The first in the series of Implementation of Social Authentication has a different Glitch project set up from before.


Also make sure to connect to a mongoDB otherwise you won’t pass the tests.


Thanks for the tips, wonder why it couldn’t work in routes.js


Same :confused: Not even in auth.js

test is checking in server.js file instead of routes.js

"getUserInput => $.get(getUserInput('url')+ '/_api/server.js') .then(data => { assert.match(data, /('|\")\\/auth\\/github\\/callback('|\")[^]*get.*passport.authenticate.*github.*failureRedirect:( |)(\"|')\\/(\"|')/gi, 'Route auth/github/callback should accept a get request and call passport.authenticate for github with a failure redirect to home'); }, xhr => { throw new Error(xhr.statusText); })"

It took me a whole week to figure this out. Till I found your comment.

It took me a whole week to understand that the tests will only pass if i had all the code in server.js. I had to create a new project to confirm this.

And even after you transfer all back to server.js, you still might run into problems. As the code is checked with regex, all sort of little issues can creep in unnoticed. For example, here we see a newline causing the test to fail. When you run into trouble, try copying their code and see if it works. If it does, then you probably ran into some regex issue.

I read this whole thread yesterday, but missed this key point by @jakawa72. I wanted to highlight it in case anyone else missed it like me. There is a new boilerplate to use starting with the Social Authentication challenges. It’s linked correctly in the challenge, but not called out that you’re supposed to switch to a new one. The new boilerplate has all the code in server.js and no routes.js or auth.js.

If you’re still having trouble getting the tests to pass, you can check the details of the tests described in the markdown files here. As @isacvale mentioned, they’re using regex, so it’s somewhat finicky. For me, I had to remove some newlines which the Glitch formatter inserted into my new GitHubStrategy statement in order to get the tests on challenge ‘II’ to pass.

A big Thanks to @abellinii for this post. Seems like an easy fix is to clearly call out in the instructions on this project page to start a new Glitch Project and not use the one we’ve been using for the last several modules. This github issue was helpful to me to get the callback test to pass.

1 Like

I found that if I have a working solution, but it is not passing the test(s), I could take the supplied code, copy/paste it into my working code, and then comment it out. That way the key words the test is looking for are present in the code, but since it is commented out, it doesn’t interfere with the work I put into the project. I have spent a fair bit of time figuring out how to implement the current versions of the packages. That way I am learning something current. However, these tests are often checking for implementation details, instead of just functionality, which makes the up-to-date code fail the tests. So far, it has only been in this series of lessons that I have run into this issue.

Exactly. What I have started doing is, if my code works properly, but is not passing the tests, I just copy/paste their code and comment it out (so it doesn’t interfere with all the coding work I have done). This has allowed me to get past the tests. With them checking for implementation details, instead of testing functionality, the tests are more or less ineffective.

Passed the test with code structure like this :


    app.route('/auth/github/callback').get(passport.authenticate('github', {failureRedirect: '/'}),
      (req, res) => {

    passport.use(new GitHubStrategy(
          clientID: process.env.GITHUB_CLIENT_ID,
          clientSecret: process.env.GITHUB_CLIENT_SECRET,
          callbackURL: ""
        function(accessToken, refreshToken, profile, cb) {
          //Database logic here with callback containing our user object
            { id: },
              $setOnInsert: {
                name: profile.displayName || "John Doe",
                photo:[0].value || "",
                email: profile.emails[0].value || "No public email",
                created_on: new Date(),
                provider: profile.provider || ""
              $set: {
                last_login: new Date()
              $inc: {
                login_count: 1
            { upsert: true, new: true },
            (err, doc) => {
              return cb(null, doc.value);


This line passport.use(new GitHubStrategy( I think was the problem.