runtime-error-call-stack-size.js 603 B

123456789101112131415161718192021
  1. test("infinite recursion", () => {
  2. function infiniteRecursion() {
  3. infiniteRecursion();
  4. }
  5. try {
  6. infiniteRecursion();
  7. } catch (e) {
  8. expect(e).toBeInstanceOf(Error);
  9. expect(e.name).toBe("Error");
  10. expect(e.message).toBe("Call stack size limit exceeded");
  11. }
  12. expect(() => {
  13. JSON.stringify({}, () => ({ foo: "bar" }));
  14. }).toThrowWithMessage(Error, "Call stack size limit exceeded");
  15. expect(() => {
  16. new Proxy({}, { get: (_, __, p) => p.foo }).foo;
  17. }).toThrowWithMessage(Error, "Call stack size limit exceeded");
  18. });