Testing locally with uniswap pair failing

Hi,

How do I test locally with ganache-cli when using a uniswap pair?

IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
         // Create a uniswap pair for this new token
        address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
            .createPair(address(this), _uniswapV2Router.WETH());

My code fails to create a uniswapV2Pair when testing on a local network or infura

  1. what is address(this)?
  2. don't forget to give allowance to the router contract for your tokens and weth.

There is no Uniwap Router at this address in your local Ganache instance.

For testing integration with Uniswap V2 check out their guide:

https://docs.uniswap.org/protocol/V2/guides/smart-contract-integration/quick-start