-
Notifications
You must be signed in to change notification settings - Fork 297
Open
Description
This is just a minor bug in this project's repository. In time, Udacity will fix it.
There is a slight problem with the last Jest test (paying less than total works
), as the variable (totalPaid
) that holds the received cash and supports the pay()
function is being initialized with the value (100000000000000
) from the previous test.
If you want all ten tests to succeed, add two new lines of code in the:
https://github.com/udacity/cd2073-intro-to-js-1-project-starter/blob/main/starter/tests/script.test.js#L74
To fix this, reset the loaded module and require it again in the last jest test:
test('pay less than the total works', () => {
// reset the module
jest.resetModules();
// require it again
const cart = require('../src/assets/script.js');
cart.addProductToCart(product1.productId);
cart.addProductToCart(product2.productId);
expect(cart.pay(1)).toBeLessThan(grandTotal());
});
Now if all your functions are correct, all Jest tests will pass!
LightTreasure
Metadata
Metadata
Assignees
Labels
No labels