As others have said, size of company is important.
Mind you, I started a job for a tiny company while ttc years ago. I felt guilty when I got pregnant a month later, but I’d had no way of knowing it would happen that quickly, if at all (I wasn’t young).
I delayed telling my boss until I was six months in. He was furious; he had spent half a year training me so that I could take over from him. He sacked me immediately. Fair enough, I thought. Deserved that.
Then he sheepishly rang me back the following day and asked me to come back and work as long as I felt able to. I cheerfully went back and all was fine. I loved that job and was good at it.
I still feel a rather bad about stringing him along, but what was I supposed to do? Not work? Only look for work with large companies? - easier said than done, especially in my field which is dominated by small companies and sole traders.
At the end of the day, anything can happen. Not all pregnancies work out. Not all employees stay the course, for a variety of reasons. I didn’t end up going back after having my dc because the company lost that particular contract shortly afterwards anyway, so I would have been out of a job anyway, as it happens.
Go for the job. Good luck.