Another solution: you could also use a try/catch block
try { // if the element is found, the following expect will fail the test expect(getByTestId('your-test-id')).not.toBeVisible(); } catch (error) { // otherwise, the expect will throw, and the following expect will pass the test expect(true).toBeTruthy(); }