Markdown Previewer Tests

Hi all. Currently working on the second project of Front End Development Libraries, but I’ve seem to run into an odd issue that I haven’t had before. I’ve got my app working, and from what I can tell meets all of the criteria. However, I’m failing the final 2 (3, if you count the bonus) tests, even though it seems to me as though my code is doing what the tests are considering failing.

I’m not entirely sure what code would be relevant for this problem, so I’ll just show a screenshot of what my app currently looks like so that I’m not spoiling any code at all…

Edit: This is my render method

render() {
    const markDown = marked.parse(this.state.text);
    
    return (
      <div>
        <textarea id="editor" onChange={this.handleChange}>{this.state.text}</textarea>
        <div id="preview" dangerouslySetInnerHTML={{__html: markDown}}/>
      </div>
    )
  }

Any help or ideas would be greatly appreciated! I can also show snippets of code if anyone thinks there may be something obvious that I’m missing.

Challenge: Build a Markdown Previewer

Link to the challenge:

I think this is going to be hard to help without see the code. Is this in an online IDE somewhere? In a repo?

If it helps, here is where the tests are defined.

This is just from the codepen.io link that’s provided to us when starting a challenge. Also just to add, the h1 test assertion seems to be the one failing…
“AssertionError: write some markdown representing an <h1> : expected false to be true”
I just don’t quite understand because it very clearly is working both on load up, and when I enter a new h1 into my textarea.

OK, can we have a link to that pen?

Sure. I just thought it might be frowned upon to share all of my code to other people who may be in the process of completing the challenge themselves.

I can’t recall the exact issue but there is a bug in the tests if you use a newer version of the marked library. The FCC example uses:

https://cdnjs.cloudflare.com/ajax/libs/marked/2.0.3/marked.min.js

When I replace the one you are using (4.0.2) with the above then all the tests pass.

2 Likes

Do you think this is ok to submit then? Or is there a way to manually change it to use an older version of marked so that my tests pass?

Just use the version of the package that bbsmooth recommends. There is not requirement that you have to use the latest package, in FCC projects or in “the real world”.

I’m slightly confused on how to actually use that 2.0.3 version instead of the 4.0.2 that’s being used. Would it be as simple as this?

import "https://cdnjs.cloudflare.com/ajax/libs/marked/2.0.3/marked.min.js"

Click on the little gear config icon in the codepen JS editor. You should see your current version in there. Just change the numbers to 2.0.3 and you should be good to go.

Thank you so much for both of your help!

1 Like