Help with Issue Tracker project

Hey guys,

I’m having some trouble with the last bit of the Issue Tracker Quality Assurance project, and want to see if anyone else is experiencing this as well.

If I leave NODE_ENV=test commented out in my .env file when I submit the project, all tests pass except for 2:

You can send a PUT request to /api/issues/{projectname} with an _id and one or more fields to update. On success, the updated_on field should be updated, and returned should be { result: 'successfully updated', '_id': _id } .

All 14 functional tests are complete and passing.

If I uncomment NODE_ENV=test, all of the functional tests pass when I run the app in repl.it, but then all tests fail when submitting the project to FCC.

I also cannot figure out why the requirement for the successful PUT request is not passing when I submit the project. It seems to be working correctly when I submit an update from the front end, and also passes the test in my functional-tests.js.

Here is the link to my project: https://repl.it/@murphy1188/issue-tracker

Has anyone else run into these issues? Or happen to have an idea of where I’m going wrong here?

Thanks!

UPDATE:

I was able to figure out the last test “All 14 function tests are complete and passing.” and it now passes with the NODE_ENV=test uncommented in my .env file. However I’m still not able to pass the PUT request with ‘successfully updated’ result test when I submit the project.

When I attempt to submit the project, that test is throwing this error in the console:

Error: expected undefined to be an object
at eval (eval at (frame-runner.js:84), :2:258)

I’m unable to figure out what is causing this error, because it seems that my code should be returning an object here, passes my functional tests, and updates correctly when I test it.

Does anyone have any advice?

Thank you!

Welcome, murphy.

When I submit your project code, I get the following errors in the browser console:

frame-runner.js:100 Error: expected undefined to be an object

Here is the test you are failing:

async (getUserInput) => {
  try {
    let initialData = {
      issue_title: 'Issue to be Updated',
      issue_text: 'Functional Test - Put target',
      created_by: 'fCC'
    };
    const url = getUserInput('url') + '/api/issues/fcc-project';
    const itemToUpdate = await $.post(url, initialData);
    const updateSucccess = await $.ajax({
      url: url,
      type: 'PUT',
      data: { _id: itemToUpdate._id, issue_text: 'New Issue Text' }
    });
    assert.isObject(updateSucccess);
    assert.deepEqual(updateSucccess, {
      result: 'successfully updated',
      _id: itemToUpdate._id
    });
    const getUpdatedId = await $.get(url + '?_id=' + itemToUpdate._id);
    assert.isArray(getUpdatedId);
    assert.isObject(getUpdatedId[0]);
    assert.isAbove(
      Date.parse(getUpdatedId[0].updated_on),
      Date.parse(getUpdatedId[0].created_on)
    );
  } catch (err) {
    throw new Error(err.responseText || err.message);
  }
};
1 Like

I have narrowed it down to this section of the tests:

const getUpdatedId = await $.get(url + '?_id=' + itemToUpdate._id);
    assert.isArray(getUpdatedId);
    assert.isObject(getUpdatedId[0]);

I recommend you go from there, and debug why the object is not an object.

Hope this helps

2 Likes

Got it finally! I had ‘===’ in my filter in my GET route, where it should have been ‘==’. Thank you for pointing me in the right direction!

1 Like

Just had this exact issue with this project. I didn’t event think to consider the implications of my strictly equal in my .get request. Hats off to you!

Many thanks to you for posing the question, and for posting your eventual resolution.
And many thanks to Sky020 for the test suite.