Similar to how avocados (and guacamole!) react once oxidized, basil has a similar kind of reaction and darkens when exposed to oxygen. To avoid the basil pesto darkening, you could blanch the basil leaves in boiling water for just a few seconds, then add to ice water and dry them before creating the basil pesto. Placing your food processor "blade" in the fridge for 10-15 minutes can also help to keep the green pesto for longer.