Pigs (Sus scrofa domesticus) and most other farmed species are social animals for whom social isolation is known to cause stress. However, their social nature is commonly ignored in behavioural and cognitive tasks, on which they are trained and tested individually, which may impact their welfare and the validity of test results. We chose the Judgement Bias Task (JBT), a promising proxy measure of affective states, to compare training duration, task performance and behaviour of pigs trained and tested in social isolation (ISO; n = 12) with pigs trained and tested with physical and visual contact to social companions through an opening covered with wire mesh (SOC; n = 12). Eleven SOC pigs and eight ISO pigs learned the task, but SOC and ISO pigs did not differ in training duration or task performance when tested. However, ISO pigs showed a higher frequency of all behavioural measures indicative of stress, i.e. high-pitched vocalisation, freezing, exit-approaching behaviour, heavy escape attempts, defaecation and urination compared to SOC pigs. Future research should replicate our study, additionally in combination with other treatments like different housing conditions, to investigate potential interacting effects on learning and task performance. Several open questions remain, but the unambiguous behavioural differences we found strongly advocate for more research to decrease the stress and thus improve the welfare of pigs and other social animals used in behavioural and cognitive tasks.