non-writable-assignment.js 348 B

123456789101112
  1. test("normal mode", () => {
  2. expect(() => {
  3. NaN = 5; // NaN is a non-writable global variable
  4. }).not.toThrow();
  5. });
  6. test("strict mode", () => {
  7. expect(() => {
  8. "use strict";
  9. NaN = 5; // NaN is a non-writable global variable
  10. }).toThrowWithMessage(TypeError, "Cannot write to non-writable property 'NaN'");
  11. });