Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Simple HTML JS issue i can't figure

progamertj

New Coder
Summary:
Hi guys its a very simple easy question but i can't seem to figure out. For my uni work they are using JS to test our code. I usually program as i go in my own style but it has to be done their way and i can't figure out why it wont pass the test:

Problem:
The HTML page is below and the task is to create a simple H1 Tag following the java script test (at the bottom of the page) my H1 Tag is working just find i'm trying to figure out why the test won't pass

Many thanks

TJ

P.S rough code trying to think of solutions for example the script tag




[CODE lang="html" title="HTML Page"]<!DOCTYPE html>
<html lang="en">
<head>
<title>Temperature Monitor</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" />
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>

<style type="text/css">
.background: #ffff99;

.H1 {


}


</style>

<script>
$(window).on("load", function() {
// Your JS code goes here.
}
</script>
</head>

<body>
<!-- Do not edit this section. -->
<div id="mocha" style="background-color: #fff"></div>

<script src="https://unpkg.com/chai/chai.js"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script>

<script class="mocha-init">
mocha.setup('tdd');
mocha.checkLeaks();
</script>

<script src="COMP3006_CW1_Tests.js"></script>

<script class="mocha-exec">
mocha.run();
</script>

<div id="monitor">
<div id="heading"><H1>Temperature Monitor</H1>
<form action="/action_page.php">
<label for="temperature">Enter Temperature</label>
<input type="text" id="temperature" name="temperature"><br><br>
<input type="submit" value="Submit">
</form>



</div>

</div>
<!-- Your HTML code goes here. -->

</body>
</html>
<script
[/CODE]
[CODE lang="javascript" title="Javascript test"]test("#Unit test 3 testing for heading presence", function(){
chai.assert.equal($("#heading").prop("tagName"), "H1", "Checking h1 element exists.");
chai.assert.equal($("#heading").html(), "Temperature Monitor", "Checking heading has the correct value");[/CODE]
 
With your JS try this

JavaScript:
test("#Unit test 3 testing for heading presence"), function(){
        chai.assert.equal($("#heading").prop("tagName"), "H1", "Checking h1 element exists.");
        chai.assert.equal($("#heading").html(), "Temperature Monitor", "Checking heading has the correct value");
}

I haven't got your whole code so I cannot see if it's working properly when I run what you have shown. Im getting no more errors.
 
Back
Top Bottom