Can't pass two tests though everything works correctly

I am out of ideas. Why this tests are not fulfilled?

  1. The audio element with id of “beep” must stop playing and be rewound to the beginning when the element with the id of “reset” is clicked.
    Audio element was not stopped when reset was clicked.: expected false to be true
    AssertionError: Audio element was not stopped when reset was clicked.: expected false to be true
    at o. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:531:15281)
    at o.e (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:401:182)
    at Reflect.get ()
    at Object.e [as get] (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:68:1382)
    at n.isTrue (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:556:1222)
    at n. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:581:184436)
    at https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:575:265533
    at Kb.run (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:575:265828)
    at CC.runTest (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:575:280794)
    at https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:575:281730

And I CAN stop the sound by clicking reset element and it stops and being rewound as is asked.

This is my pen https://codepen.io/ovr58/pen/OJqQpdM

Your audio file is the issue and here is a link that might help.

1 Like

The trick with the ref didn’t worked out. But again - the audio file that I have took from the link in the example progect of FCC stops playing when I CLICK the reset element - whenever I use the Ref or documnet.getElementById - and test doesn’t pass nevertheless.

Thank you so much for your help :smiling_face:

1 Like

I feel like something is going on behind the scenes of this code. But cannot catch it. I think it is connected to the fact that after all tests finished beep continues to beep - may be in some cases my stop code for the sound has no action… Please help! :melting_face: :melting_face: :melting_face:

Clicking the reset button should pause and set the currentTime property of the element to 0.

How you want to do that is up to you but just to prove it, simply adding the direct DOM manipulation to the reducer will make it pass.

case ActionTypes.reFresh:
	document.getElementById('beep').pause();
	document.getElementById('beep').currentTime = 0;
	return initialState;
1 Like

Thank you so much for helping me so many times! it worked, though I don’t understand why my solution didn’t? is it appropriate to add code in reducer like that?

Not really considering the reducer is supposed to be pure and DOM manipulation is not part of its responsibility, only state updates. That is why I said it was just “proof” of the issue.

1 Like

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