The effects of fluid viscoelasticity on the expansion of gas bubbles in polymer foams for both non-reactive and reactive polymers are investigated. Polymer foams are used extensively in consumer products, from car parts to upholstery. They are produced either by injection moulding (of non-reactive polymeric fluids) or reaction injection moulding. We use standard rheological models (Oldroyd B and Pompom) to investigate bubble growth driven by gas diffusion as a model for injection moulding. To model reaction injection moulding, we develop a new fluid model based on existing linear theory for a gelling liquid. In this case gas is produced as a by-product of the polymer reaction. At small bubble volume fractions gas bubbles remain spherical and isolated from neighbouring bubbles during expansion. In this regime we demonstrate the effects of rheology and gelation on the bubble growth. At high bubble volume fractions neighbouring bubbles compete for the available gas and become distorted in shape. The effects of viscoelasticity on the expansion of gas bubbles arranged in a two-dimensional hexagonal array in a non-reacting polymeric fluid are investigated. In addition to a full finite element calculation of the two-dimensional flow, two one-dimensional approximations valid in the limits of small and large gas area fractions are presented. We show that these approximations give accurate predictions of the evolution of the bubble area, but give less accurate predictions of the bubble shape. Finally we consider how bubbles of different sizes evolve in an expanding foam. We illustrate how the surface tension driven phenomenon known as Ostwald Ripening causes large bubbles to grow at the expense of smaller ones. For the case of bubbles of two different sizes we examine the effects of viscoelasticity on the shapes of the bubbles within the structure and show that viscoelasticity has a different effect on the bubble size distribution depending upon the initial geometry.