Markdown Previewer fails test #6, not detecting h1 tag in preview

Tell us what’s happening:
Ok, so… I’ve beat my head against the wall trying to figure this out - I’m not sure why it’s not passing #6. This error triggers both locally and on CodePen, yet my #preview clearly has the h1 tags by default upon inspection with dev tools. So frustrating… it passes all of the other tests, including the bonuses. Is there a bug in the testing code?

Here’s the error from the “failed” test:

X 6. When my markdown previewer first loads, the default markdown in the #editor field should be rendered as HTML in the #preview element

AssertionError: #preview does not contain the H1 element represented by the markdown in the #editor field with the inner text Heading 1   : expected 0 to be at least 1
    at Function.assert.isAtLeast (https://gitcdn.link/cdn/freeCodeCamp/testable-projects-fcc/964ca952fd35ea7b8243c29ace6fbb3dbec50dbb/build/bundle.js:17878:36)
    at n.<anonymous> (https://gitcdn.link/cdn/freeCodeCamp/testable-projects-fcc/964ca952fd35ea7b8243c29ace6fbb3dbec50dbb/build/bundle.js:20353:23)
    at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:2:7852)
    at r.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:2:8853)
    at i.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:2:13553)
    at https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:2:14192
    at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:2:13024)
    at https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:2:13000
    at n (https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:2:12791)
    at https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:2:12855
    at i (https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.min.js:1:559)

Your code so far
https://codepen.io/brimarq/pen/ERryJE .

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:

1 Like

Maybe you should 't call function in div, it’s not good practice, is better to call state variable.
look here https://codepen.io/vanderdrilu/pen/RJbjry

Maybe so, but I got that directly from the React Docs.

1 Like

And, it still doesn’t explain why the test isn’t detecting the h1 tag that is obviously there.

Remove the whitespace after Heading 1 and Heading 2, you should be good.

Thx… that worked! Weird. I’ve always been in the habit of using two spaces before a CR when writing MD text. I guess the regex in the tests don’t like that.