How to not check cache for deployProxy

In my tests, I deploy contracts with upgrades.deployProxy since my contracts are UUPSUpgradeable and deploying only the logic doesn't work for me as I have disableInitializers in the constructor.

In one of my test file(test_file_1.ts), which runs first, I have something like this in.

const pluginA_ContractFactory = await ethers.getContractFactory('pluginA');
const plugin = upgrades.deployProxy(pluginA_ContractFactory);
... 
// some tests here on plugin instance

Then next runs test_file_2.ts in which I still need to use deployProxy with pluginA, but Instead of deploying it, await ethers.getContractFactory('pluginA'); I need to deploy mock for which I use wonderland smock package. So I end up having:

const pluginMock = await smock.mock('pluginA')
// @ts-ignore
plugin = await upgrades.deployProxy(pluginMock);
await plugin.initialize(...);

// One of the test 
await someOtherContract.executeProposal(dummyMetadata, dummyActions);
expect(plugin.execute).has.been.calledWith(BigNumber.from(proposalId));

The test fails. The reason is inside test_file_2, deployProxy doesn't deploy pluginMock as the implementation, because, it finds the one already in unknown-1337 file and uses it(the one it finds was deployed by test_file_1.

Whats the way to fix it ? I thought maybe upgrades package has a field I can set where I tell it to never check that file. NOTE that useDeployedImplementation won't fix it as this is something else(Just wanted to point that out).

Answering this question properly seems to require some knowledge of how smock works under the hood, but I couldn't find that in their documentation.

How do you know that this is the reason? When you delete the cache and run test_file_2 only, does it work?

Thanks @frangio for the answer. Let me explain better. Now, I realize there're even 2 problems.

// test_file_1.ts runs first
let contractFactory = await ethers.getContractFactory('DAO.sol');
let dao = await upgrades.deployProxy(contractFactory, []);
let implementation = await upgrades.erc1967.getImplementationAddress(dao.address)
console.log(implementation);

// test_file_2.ts runs second
let contractFactory = await smock.mock('DAO.sol');
let dao = await upgrades.deployProxy(contractFactory, []);
let implementation = await upgrades.erc1967.getImplementationAddress(dao.address)
console.log(implementation);

PROBLEM 1: in both files, implementation ends up the same address which is pretty easy to believe that second test file actually doesn't deploy mock implementation and takes it already deployed one which in the end is a problem because test_file_2 no more has smock deployment.

Ok, so, in test_file_1, I added:

fs.unlinkSync(path) // path of unknown-1337

After this, implementations are actually different which is good.

Problem 2: Even though I made it that they use now different implementations, I still have a problem where it says that in test_file_2, the implementation is not of smock. Problem should be coming from here:

let contractFactory = await smock.mock('DAO.sol');
let dao = await upgrades.deployProxy(contractFactory, []);

What smock does is extends ContractFactory and modifies its deploy which should be fine because OZ in the deployProxy would call .deploy which would use the smock's deploy, not the default one of hardhat. but still, it doesn't end up the smock deployment. The reason I know that is it fails that implementation is not Watchable, meaning it's not smock.

Possibly, Problem 2 should be solved first and then Problem 1. Any clue ?

Thank you

Does smock also modify ContractFactory.attach?