How to mock methods for writing unit tests in nodejs

I am writing unit tests in nodejs using mocha and sinon.js. I am facing issues in mocking the dependencies. So I want to test method1() which internally calls method2(). I want to mock the method2(). I am using this using sinon.stub() as shown in the code snippet below. But when I run the test case, the actual method is getting called instead of the stubbed one. What am I doing wrong here?


    async function method1() {
        // do something
        await method2()

    async function method2() {
        // do something


    fileA = require('./fileA')

    sinon.stub(fileA, 'method2').callsFake(fakeFn() {
        // do something else