@akshit0201 (akshit chaturvedi) posted a new topic, subject "Test not passing when chaining helpers". It read:

   **Tell us what's happening:**
    
    Repl:https://repl.it/@akshitchaturved/boilerplate-mongomongoose  
    I'm following all the hints yet I'm unable to pass the test. Pls help me out.
    
    **Your code so far**
    [code] 
        var queryChain = function(done) {
          
          
         Person.find({ age: 55 })
          .sort({ name: -1 })
          .limit(5)
          .select({ favoriteFoods: 0 })
          .exec(function(error, people) {
            if(error){
               done(error);
            }
            
            done(null, people);
          })
        
    [/code]
    
    **Your browser information:**
    
    User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Safari/605.1.15`.
    
    **Challenge:** Chain Search Query Helpers to Narrow Search Results
    
    **Link to the challenge:**  
    
    
    freecodecamp.org
    
    ### freeCodeCamp.org
    
    Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.

Then @lasjorg (Lasse) said

    1. You are not using `foodToSearch` for the `.find()`
    
      2. The default sort order is ascending, which I believe is what is expected.
    
      3. You are not limiting the results to two documents.
    
      4. You are not excluding the age.
    
    
    
    
    I would suggest you look at the docs, for find and query.

To which @akshit0201 (akshit chaturvedi) replied

    Thanks for the quick feedback. I've made the suggested changes but I am unable to pass the test.
    [code] 
        var queryChain = function(done) {
          foodToSearch = "Chickpea"
          Person.find({favoriteFoods: foodToSearch}).sort({name:1}).limit(2).select({age:0}).exec(function(error, people) {
            if(error){
               done(error);
            }
            
            done(null, people);
          })
          
        };
        
    [/code]

Then @lasjorg (Lasse) said

    Why did you change the value of `foodToSearch` and why did you remove the declaration?
    
    Edit: you should also keep the code format like it was, it's really hard to read now.

So @akshit0201 (akshit chaturvedi) replied

    No value for foodToSearch was provided beforehand.I've been taught to use ‘var' instead of ‘const' (makes it more flexible). So, I changed the format.

To which @lasjorg (Lasse) replied

    akshit0201:
    
    > No value for foodToSearch was provided beforehand.
    
    Yes, it was. Here is the starter code.
    [code] 
        const queryChain = (done) => {
          const foodToSearch = "burrito";
        
          done(null /*, data*/);
        };
        
    [/code]
    
    akshit0201:
    
    > I've been taught to use ‘var' instead of ‘const' (makes it more flexible). So, I changed the format.
    
    Not sure who taught you that but I would unlearn that ASAP.

So @akshit0201 (akshit chaturvedi) replied

    I'll use const from now on.
    [code] 
        const queryChain = (done) => {
          const foodToSearch = "burrito";
          Person.find({favoriteFoods: foodToSearch}).sort({name:1}).limit(2).select({age:0}).exec(function(error, people) {
            if(error){
               done(error);
            }
            
            done(null, people);
          })
          
        };
        
    [/code]
    
    I still can't pass the test.

After which, @lasjorg (Lasse) added

    Your code seems to be passing for me. Did you remember to restart the server?

@akshit0201 (akshit chaturvedi) replied

    I restarted the server , still no luck.

@lasjorg (Lasse) replied

    Not sure what is wrong.
    
    When I take your code and put it in my own project it passes the test, if I fork your project and add my own .env file it passes the test.
    
    Are you sure you are connecting to the DB correctly?

To which @ilenia (Ilenia) replied

    


{'source': 'discourse', 'url': 'https://forum.freecodecamp.org/t/test-not-passing-when-chaining-helpers/435760', 'title': 'Test not passing when chaining helpers', 'views': 171, 'has_accepted_answer': False, 'word_count': 487, 'like_count': 0, 'reply_count': 4, 'participant_count': 2, 'posts': 11, 'tags': '', 'author': '@akshit0201 (akshit chaturvedi)', 'participants': '@akshit0201 (akshit chaturvedi), @lasjorg (Lasse), @ilenia (Ilenia)', 'image_url': [None], 'created_at': '2020-12-16T13:29:12.480Z', 'last_posted_at': '2021-06-01T09:58:24.803Z'}