I have everything like it asks

Tell us what’s happening:

It doesnt submit the tests even tho my code and server work

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Exercise Tracker

Link to the challenge:

hi i am new can you lern me how to code

anything im missing?

Your server is down:

Check now it should work

There is an error in your code, because every time I submit a new user, the app crashes.

Now it works but it doesnt pass those last ones

The returned object is missing a few things:

This is what the tests are doing:

const res = await fetch(url + '/api/exercise/new-user', {
        method: 'POST',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        body: `username=fcc_test_${Date.now()}`.substr(0, 29)

      if (res.ok) {
        const { _id, username } = await res.json(); // This is the response from your app
        // Now, using all the information provided, an expected object is created...
        const expected = {
          description: 'test',
          duration: 60,
          date: 'Mon Jan 01 1990'
  • A POST request is made to your app’s endpoint /api/exercise/new-user
  • In this POST, a username is passed: username=fcc_test_${Date.now()}.substr(0, 29)` (This is just a fancy way to ensure that every time a new user is posted, it has a different username, because the username is linked to the time of request)
  • An expected object gets created.
  • This has very little to do with the actual test, but is useful to use for testing
const addRes = await fetch(url + '/api/exercise/add', {
          method: 'POST',
          headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
          body: `userId=${_id}&description=${expected.description}&duration=${expected.duration}&date=1990-01-01`
  • A new POST request is made to the app endpoint: /api/exercise/add
  • The following arguments are passed in the request:
let body = {
  userId: _id,
  description: expected.description,
  duration: expected.duration,
  date: "1990-01-01"
  • The _id comes from this line above:
const { _id, username } = await res.json();

This is exactly the same as if you had made use of the UI to create a new-user:
Then, add an exercise:


if (addRes.ok) {
          const actual = await addRes.json();
          assert.deepEqual(actual, expected);
  • If the response returns an ok status, the actual user object is stored in the variable actual
  • actual is compared to the expected created earlier.

In summary:

  • New user created
  • expected values are based on this new user
  • An exercise is added to a user based on the _id
  • The returned (actual) user object is compared to the expected user object

An example expected object:

const expected = {
  username: 'fcc_test_1596648410971', // Obviously the numbers change
  description: 'test',
  duration: 60,
  _id: 5f29cd9e782d5f13d127b456, 
  date: 'Mon Jan 01 1990'

Notice the returned date format

it doesnt pass the first out of those

The app is still crashing with uncontrolled inputs.

Other than that. The only tests being done for the failed screenshot test are:

  1. Returned object contains a property log.
  2. log is an array
  3. log.length === 1

Give your app a few inputs, and see if those criteria are met.

Hope this helps.

it matches all those criteria
image image image

The test is failing, because the app is crashing:

It happens whenever there is no date passed to the api/exercise/add route. You need a default date, because it is optional.