Odd issue: "Run the Tests" button intermittently working

Current pushing through the React section of Front End Development Libraries and on Use State to Toggle an Element the damn “run the tests” button refuses to check my work. Just does nothing. Inspector shows <button type="button" class="btn btn-primary btn-block">Run the Tests</button> == $0

Tested with both the current Firefox and Chrome to no avail. Anyone else having this issue?

Welcome there,

Would you mind sharing your code?

Also, keep in mind to watch out for browser extensions which could be affecting the tests.

Hope this helps

1 Like

Full code for examination. I think it’s right but even if it’s incorrect the “Run The Tests” button helps me figure out where I went amiss =)
Thanks for any help!

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visibility: false
    };
    // Change code below this line
    this.toggleVisibility = this.toggleVisibility.bind(this);
    }
    // Change code above this line
  }
  // Change code below this line
toggleVisibility() {
  this.setState(state => {
    if (state.visibility === true) {
      return { visibility: false };
    } else {
      return { visibility: true };
    }
  });
}
  // Change code above this line
  render() {
    if (this.state.visibility) {
      return (
        <div>
          <button onClick={this.toggleVisibility}>Click Me</button>
          <h1>Now you see me!</h1>
        </div>
      );
    } else {
      return (
        <div>
          <button onClick={this.toggleVisibility}>Click Me</button>
        </div>
      );
    }
  }
}

Hi @ManiacalMaynard !

I have edited your post.

For large sections of code it is easier to read if you place three backticks on top and below your code instead of in between two backticks.

I’ll try running your code and see if the run tests button is working for me.

1 Like

Finally found the issue.

Your code wasn’t running because you had a syntax error.

You have an extra curly brace here.

1 Like

Thank you for the tip! Guess reddit habits got the better of me for posting code =)

Gah! Found it, extra “}” borked it for me. Issue resolved, sorry for wasting everyone’s time. I will be more critical next time. Thanks again for your time and kind attention, cheers.

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