Jest mock a constructor

I am using Angular with Jest to mock a class. I am finding difficulty in mocking the constructor as the test function is invoked within the constructor. Any input on how to mock the constructor with jest would be helpful

export class AppComponent {


constructor(){

this.test();

}

test(){

return 'Test'
}
}

test

describe( 'AppComponent', () => {
    let fixture: WorkerFormComponent;

    beforeEach( () => {
        
        fixture = new AppComponent(
            
        );
    });


Read more here: https://stackoverflow.com/questions/67391987/jest-mock-a-constructor

Content Attribution

This content was originally published by Subham at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: