Testing for electromagnetic compatibility in electronic devices involves using an EMC test chamber, measuring emissions and susceptibility, and conducting tests as per international standards like CISPR, IEC, or MIL-STD. Additionally, pre-compliance testing can be performed using spectrum analysers and EMC test receivers.