const now = new Date().toISOString();
const event = await payload.create({
collection: "event",
data: {
id: `test-event-categorisation-19-${now}`,
title: "Event that is revolving around the topic democracy",
dateTime: now,
sourceCalendar,
// the `sector` key is set in the events beforeChange hook
},
});
expect(event).toBeDefined();
expect((event.sector as Sector).title).toEqual(sector.title);
await payload.delete({
collection: "sector",
id: sector.id,
});
expect(event.sector).toBeNull();
I get this test failure:
error: expect(received).toBeNull()
Received: {
id: 1,
title: "Test Sector",
wordList: [
{
id: "69a196bd0a71d4029d16709b",
word: "Test",
}, {
id: "69a196bd0a71d4029d16709c",
word: "democracy",
}
],
updatedAt: "2026-02-27T13:06:05.663Z",
createdAt: "2026-02-27T13:06:05.662Z",
}
Do I need to await database changes or anything for this test to pass or what am I doing wrong? When I assign and delete a sector to an event in the ui, the change propagates corrently