As the title says, why i can't call Example.method2()?
Example class:
class Example {
private method1(): any{
return "it works"
}
#method2(): any {
return "it works"
}
}
Test that works
it('should call method1', () => {
// @ts-ignore
const result = Example.method1()
expect(result === "it works" ).toBeTruthy(); // OK
});
Test that should work
it('should call #method2', () => {
// @ts-ignore
const result = Example.#method2()
expect(result === "it works" ).toBeTruthy(); // NOT OK
});
Error log:
const result = Example..call(Example);
^
SyntaxError: Unexpected token '.'
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1796:14)