  One of the current challenges of planet formation theory is to explain the
enrichment of observed exoplanetary atmospheres. Past studies have focused on
scenarios where either pebbles or planetesimals were the heavy element
enrichment's drivers, we combine here both approaches to understand whether the
composition of a planet can constrain its formation pathway. We study three
different formation scenarios: pebble accretion, pebble accretion with
planetesimal formation, combined pebble and planetesimal accretion. We use the
chemcomp code to perform semi-analytical 1D simulations of protoplanetary
discs, including viscous evolution, pebble drift, and simple chemistry to
simulate the growth of planets from planetary embryos to gas giants as they
migrate through the disc, while tracking their composition. Our simulations
confirm that the composition of the planetary atmosphere is dominated by the
accretion of gas enriched by inward drifting and evaporating pebbles. Including
planetesimal formation hinders the enrichment, because the pebbles locked into
planetesimals cannot evaporate and enrich the disc. This results in a big drop
of the accreted heavy elements both in the planetesimal formation and accretion
case, proving that planetesimal formation needs to be inefficient in order to
explain planets with high heavy element content. Accretion of planetesimals
enhances the refractory component of the atmosphere, leading to low volatile to
refractory ratios, contrary to the pure pebble scenario. Such low volatile to
refractory ratios can also be achieved by planets migrating in the inner disc
in pure pebble scenario. Distinguishing these two scenarios requires knowledge
about the planet's atmospheric C/H and O/H ratios, which are higher for pure
pebble accretion. Therefore, a detailed knowledge of the composition of
planetary atmospheres could help to constrain the planet's formation pathway.
