This is part 3 of 6 posts, you can find the previous post here.
Sample JavaScript test in .js file:
The Add function mentioned in the previous post can have a test code as mentioned below:
function returnSumOfTwoNumber() { //Arrange var expectedOutput = 3; var actualOutput = null; //Act actualOutput = Add(1,2); //Assert assertEqual(expectOutput, actualOutput); }
The keyword here is assertEqual to match the expected output to actual output.
Other points will be explained in following post, read Part 4 here.
2 comments