Quality Assurance Projects - Issue Tracker - inconsistent time-outs

Tell us what’s happening:
I’ve only written the code for the post route - sometimes all 3 tests pass

 You can send a POST request to /api/issues/{projectname} with form data containing the required fields issue_title, issue_text, created_by, and
   optionally assigned_to and status_text.
 The POST request to /api/issues/{projectname} will return the created object, and must include all of the submitted fields.
   Excluded optional fields will be returned as empty strings.
   Additionally, include created_on (date/time), updated_on (date/time), open (boolean, true for open - default value, false for closed), and _id.
 If you send a POST request to /api/issues/{projectname} without the required fields,
   returned will be the error { error: 'required field(s) missing' }

Sometimes the first one times out and the other 2 pass.
Sometimes the first two time out and the third one passes.

I have tried logging the req.body, req.params and req.query but can’t see anything to help me.

Please advise

Your project link(s)

solution: boilerplate-project-issuetracker - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0

Challenge: Quality Assurance Projects - Issue Tracker

Link to the challenge:

There is an issue with repls crashing when running QA tests. I don’t know if that is your issue but do you have NODE_ENV set in your secrets tab? If so, trying changing the word ‘test’ to something else (e.g. ‘testicles’?) to prevent the tests from running whilst you’re testing other code.

I don’t have NODE_ENV in my secrets tab - I thought I’d get the route stuff working first before I tackled the assert tests

Submitting your current code to FCC gives me the following:

The only tests which time out are the ones which you haven’t written the code for yet.
I tried this a few times and got the same result each time.

Excluded optional fields will be returned as empty strings.

Is this where the POST request is failing perhaps? In the event that these fields are excluded, what will be returned?

Thanks for replying.

I console.logged newIssue console.log(newIssue:${newIssue}:);

and got this:

newIssue:{
  assigned_to: '',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9cea029f600e65ca261,
  project: 'fcc-project',
  issue_title: 'Faux Issue Title',
  issue_text: 'Functional Test - Required Fields Only',
  created_by: 'fCC'
}:
newIssue:{
  assigned_to: 'Chai and Mocha',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9cfa029f600e65ca263,
  project: 'fcc-project',
  issue_title: 'Faux Issue Title 2',
  issue_text: 'Functional Test - Every field filled in',
  created_by: 'fCC'
}:
newIssue:{
  assigned_to: '',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9cfa029f600e65ca265,
  project: 'get_issues_test_366783',
  issue_title: 'Faux Issue 1',
  issue_text: 'Get Issues Test',
  created_by: 'fCC'
}:
newIssue:{
  assigned_to: '',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9cfa029f600e65ca267,
  project: 'get_issues_test_366783',
  issue_title: 'Faux Issue 2',
  issue_text: 'Get Issues Test',
  created_by: 'fCC'
}:
newIssue:{
  assigned_to: '',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9d0a029f600e65ca269,
  project: 'get_issues_test_366783',
  issue_title: 'Faux Issue 3',
  issue_text: 'Get Issues Test',
  created_by: 'fCC'
}:
newIssue:{
  assigned_to: 'Bob',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9d4a029f600e65ca26b,
  project: 'get_issues_test_371828',
  issue_title: 'To be Filtered',
  issue_text: 'Filter Issues Test',
  created_by: 'Alice'
}:
newIssue:{
  assigned_to: 'Bob',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9d4a029f600e65ca26d,
  project: 'get_issues_test_371828',
  issue_title: 'To be Filtered',
  issue_text: 'Filter Issues Test',
  created_by: 'Alice'
}:
newIssue:{
  assigned_to: 'Eric',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9d5a029f600e65ca26f,
  project: 'get_issues_test_371828',
  issue_title: 'To be Filtered',
  issue_text: 'Filter Issues Test',
  created_by: 'Alice'
}:
newIssue:{
  assigned_to: 'Eric',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9d5a029f600e65ca271,
  project: 'get_issues_test_371828',
  issue_title: 'To be Filtered',
  issue_text: 'Filter Issues Test',
  created_by: 'Carol'
}:
newIssue:{
  assigned_to: '',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9d9a029f600e65ca273,
  project: 'fcc-project',
  issue_title: 'Issue to be Updated',
  issue_text: 'Functional Test - Put target',
  created_by: 'fCC'
}:
newIssue:{
  assigned_to: '',
  status_text: '',
  created_on: 2023-01-17T18:32:34.000Z,
  updated_on: 2023-01-17T18:32:34.000Z,
  open: true,
  _id: 63c6e9e8a029f600e65ca275,
  project: 'fcc-project',
  issue_title: 'Issue to be Deleted',
  issue_text: 'Functional Test - Delete target',
  created_by: 'fCC'
}:

This shows that the optional fields are set to empty strings.

What happens if you simply have res.json(data) when you save your new issue?

Wait, I think I got it. Your POST tests will fail because you’re checking for existing issues and only saving a new issue if there isn’t another already in the database. Every time you submit the challenge to FCC the same issues are being created when they run their tests, so you will always have duplicates (unless you go and erase them all each time before you run the tests).

I got your code to pass all POST tests when I removed the checks and simply saved every issue as a new issue.

newIssue.save((err, issueData) => {
      return (err) 
        ? res.json({error: 'error saving data'})
        : res.json(issueData)
      });

Thanks for replying. I tried replacing my code with yours and it still times out - even the second post test times out

Hmm, I don’t know why you’re having issues with timeouts.
I just submitted your project link to FCC and all POST tests passed fine first time.

Thank you for replying.

I decided to use VS Code locally and not replit. The POST tests are now passing (thank you :slight_smile: ). However, when I try to do the delete route it does not pass.

This is my delete code:

    .delete(function (req, res){
      let project = req.params.project;
      const {_id} = req.body;
      if (_id === undefined ) {
        return res.json({ error: 'missing _id' });
      }
      issue.findOneAndDelete({ _id: _id }, (err, issue) => {
        if (err) {
          return res.json({ error: 'could not delete', '_id': _id });
        }
        else {
          return res.json({ result: 'successfully deleted', '_id': _id });
        }
      });
    });

I cannot see where I am going wrong.

I have sorted out my error - I misunderstood the err, issue

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.