const-reassignment.js 548 B

1234567891011121314151617
  1. // I'm not sure how this test passed before the refactor, but it definitely doesn't work at all
  2. test.skip("reassignment to const", () => {
  3. const constantValue = 1;
  4. expect(() => {
  5. constantValue = 2;
  6. }).toThrowWithMessage(TypeError, "Invalid assignment to const variable");
  7. expect(constantValue).toBe(1);
  8. });
  9. test("const creation in inner scope", () => {
  10. const constantValue = 1;
  11. do {
  12. const constantValue = 2;
  13. expect(constantValue).toBe(2);
  14. } while (false);
  15. expect(constantValue).toBe(1);
  16. });