If you calculate the electricity bill for the amount of electricity that is consumed to mine a bitcoin, it can be seen that there is no profit in mining bitcoins.
It really depends on the cost itself. Some miners can have their own power source that doesn't rely on the national power grid, for example. I heard some miners use hydropower to run their farms. While that is rare, the fact that those mining farms keep operating means either they earn decent profit or they believe they can sell BTC for a profit later. CMIIW.
If you need the power source anyways for other stuff (like your house) you can use the power basically for free. This is because in many cases you will get no compensation if you feed the power into the general system (or you dont even have that option).