I am currently developing a basic JavaScript program for scoring in tenpin bowling. So far, I have created two functions - Frame and Game. For testing purposes, I have set up a mock frame named "frameOne". The specific test causing me trouble is as follows:
it('can take a frame as a parameter', function(){
frame.frameOne.and.callFake(function(){
[5, 5, 'spare'];
});
expect(game.frame1(frame)).toBe([5, 5, 'spare']);
});`
The game logic being tested by this code snippet is shown below:
Game.prototype.frame1 = function (frame) {
frame.frameOne;
return [5, 5, 'spare'];
};
Despite being new to Jasmine and coding in general, I believe that the code could be incorrect. However, my confusion arises from the error message displayed by Jasmine when running the test:
Expected [ 5, 5, 'spare' ] to be [ 5, 5, 'spare' ]
To me, this seems like a match rather than a failure. Interestingly, substituting the arrays with the value true results in a pass. Why does Jasmine claim that the arrays are not identical even though they seemingly match?
Any thoughts or suggestions would be highly appreciated!