Hi All.
I have just started writing tests for the basic algorithm challenges using JEST. Yesterday, while completing the Slice and Splice challenge
I hit upon an issue with the tests. The challenge requires that the input arrays (arr1 & arr2) are not mutated. Can anyone point me in the right direction as to what I need to research to help write this type of test? The tests for the function itself are relatively easy - and also given in the challenge, but I have no clue on how to check for mutation.
I also know that I can do this using console.log(), and I am using Quokka so I can visually check for this as I am going along. What I would like to do is to be able to write a unit test for this.
This is one of the tests I used for the function:
test('Test One', () => {
expect(frankenSplice([1, 2, 3], [4, 5], 1)).toEqual([4, 1, 2, 3, 5]);
});
I can pass the challenge, and I can get the function to work as it is supposed to, without mutating the original array, but I have no idea how to test for the mutation.
Thanks