diff --git a/src/hooks/__tests__/instrument.test.ts b/src/hooks/__tests__/instrument.test.ts index c4f33fb3..8bd8f387 100644 --- a/src/hooks/__tests__/instrument.test.ts +++ b/src/hooks/__tests__/instrument.test.ts @@ -34,7 +34,7 @@ describe(instrument.transform, () => { }]; function testFun(arg) { - return global.AppMapRecordHook.call(this, function testFun(arg) { + return global.AppMapRecordHook.call(this, arg => { return arg + 1; }, arguments, __appmapFunctionRegistry[0]); } @@ -75,7 +75,7 @@ describe(instrument.transform, () => { class TestClass { foo(value) { - return global.AppMapRecordHook.call(this, function (value) { + return global.AppMapRecordHook.call(this, value => { return value + 1; }, arguments, __appmapFunctionRegistry[0]); } diff --git a/src/hooks/__tests__/jest.test.ts b/src/hooks/__tests__/jest.test.ts index a6974996..480997b6 100644 --- a/src/hooks/__tests__/jest.test.ts +++ b/src/hooks/__tests__/jest.test.ts @@ -35,7 +35,7 @@ describe(jestHook.patchRuntime, () => { transformFile() { return global.AppMap[0].call( this, - function () { + () => { if (false) return 4; return 5; }, diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 1063dfb2..4b2dc719 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -32,7 +32,13 @@ export function wrap { expect(runAppmapNode("index.mjs").status).toBe(0); expect(readAppmap()).toMatchSnapshot(); }); + +integrationTest("mapping js class methods containing super keyword", () => { + expect(runAppmapNode("class.js").status).toBe(0); + expect(readAppmap()).toMatchSnapshot(); +}); diff --git a/test/simple/class.js b/test/simple/class.js new file mode 100644 index 00000000..505e01a5 --- /dev/null +++ b/test/simple/class.js @@ -0,0 +1,18 @@ +class A { + m1() { + console.log("A.m1()"); + } + m2() { + console.log("A.m2()"); + return "return m2"; + } +} + +class B extends A { + m1() { + super.m1(); + console.log("B.m1()"); + } +} + +new B().m1();