Trouble with the Pomodoro Clock
It appears as though my Pomodor Clock is functioning, but it doesn’t seem to pass the tests. I am just trying to get the code working before diving into the design of it.
Tests 11, 22-26 all say : Error: timeout of 5000ms exceeded. Ensure the done() callback is being called in this test.
Tests 19-21 all say : Error: Pomodoro has started but time displayed is not changing
For the life of me I can’t figure out why it doesn’t pass.
Here’s a link to my JSFiddle:
Posted Jul 9, 2018, 2:58 PM UTC
54
I wish I had something more helpful to say, but something seems wrong in the fiddle itself. As soon as I change anything, add, delete, space, anything, it flashes up four errors under your constructor, not specific to what's actually there, just whatever happens to be below the constructor. (Even if you remove the constructor.)
I don't see anything wrong, but it keeps complaining that whatever is there is not being defined properly as a class, so for some reason it thinks you should be defining a class inside your class? Even if I remove everything and leave only
or even more extreme,
I get a variety of non-sensical errors (in the first one <div></div> is an unclosed regular expression (???), and in the second it expects a ')' after the 'render(' so isn't happy that you are trying to render something with the render command? I have never tried making a React app on jsFiddle so don't know if there is just something missing to get it to work, but those errors don't make any sense to me.
Something does seem odd with the clock itself though. When I change the break time during a session time, it resets the clock, but your code does not appear to change the state of the timer, only breakInt, so something seems fishy (though maybe I just missed where that's called). If you've had no trouble with other React apps in jsFiddle then I have no idea, but if this is a first attempt, maybe as a wild guess you need to import ReactDOM (in my projects I always need to import ReactDOM specifically in any file that uses it, on top of importing React) or some other compatibility things. Looking at another random React project on there I see another script being loaded
and things done a little differently (e.g., React.render() instead of ReactDOM.render() and JavaScript 1.7 instead of React for the language) so hopefully it's just a compatibility thing with jsFiddle.
An unrelated minor comment, in your code you have, for example,
When you are changing the state independent of what it was you don't need to pass prevState in, e.g., the following would be simpler
Thanks for the help, this was my first time using jsfiddle. I created the project with create-react-app and wrote it in Atom. I just didn't want to put it on github pages until I could get it working how I wanted it to. I figured it didn't make sense to continue writing my code in codepen since I wouldn't be using it in real life applications.
I've had no problem passing all the other tests for the front end projects, but I think it's because I built the apps based on the tests. This was the first one I attempted without building specifically for the tests. I'll probably just rewrite it from scratch. Hopefully my experience building the first one will allow me to tighten up my code.
Thanks for the feedback.
Fair enough, well that hopefully means your code was fine and it was just not being loaded the way jsFiddle needs it to work.
If you want to start getting into writing code on your own machine (which is good!) you can just test the page locally with the appropriate script and link tags in your HTML file. If you want to go a (big) step further, you can set up Webpack and test it 'live' on your machine with dev-server. (Not the simplest to set up, but really nice to have once it's up and running. There are loads of setup guides to help, but it's still a bit of work to get everything setup and have a boilerplate ready to use.)
I was testing the page locally--but I couldn't figure out why it wouldn't pass the FCC tests. So I had to transfer it to JSfiddle so I could post it and ask for help.
I'll look into setting up Webpack, thanks again!