Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console.log(localStorage) is returning "null" #87

Open
Kadessy opened this issue Mar 19, 2024 · 0 comments
Open

console.log(localStorage) is returning "null" #87

Kadessy opened this issue Mar 19, 2024 · 0 comments

Comments

@Kadessy
Copy link

Kadessy commented Mar 19, 2024

(https://github.com/SuperSimpleDev/javascript-course/assets/92880605/499f5d7c-b17c-4679-a0ad-25c9507c6d20

SCREENSHOT Above

CODE below

import { addToCart, cart } from '../../data/cart.js';

describe('test suite: addToCart', () => {
it('adds and exisiting product to the cart', () => {

});
it('add a new product to the cart', () => {
spyOn(localStorage, 'getItem').and.callFake(() => {
return JSON.stringify({});
});
console.log(localStorage.getItem('cart'));

addToCart('e43638ce-6aa0-4b85-b27f-e1d07eb678c6');
expect(cart.length).toEqual(1);

});
});

From - Lesson 16 (Testing)
Using Jasmine Testing Framework

The above lines of code is supposed to display an empty array in the console since the code is supposed to spyOn locaStorage('getItem')and call fake the cart array, but instead it's returning "null" in the console. I don't know where I went wrong. I need assistance, I have been trying to solve this issue for the past 3 days now.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant