Skip to content

Commit 1143370

Browse files
committed
use ErrorWithStack helper
1 parent c4d6c81 commit 1143370

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/waitForElementToBeRemoved.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
2-
import waitFor from './waitFor';
3-
import type { WaitForOptions } from './waitFor';
2+
import waitFor, { type WaitForOptions } from './waitFor';
3+
import { ErrorWithStack } from './helpers/errors';
44

55
const isRemoved = (result) =>
66
!result || (Array.isArray(result) && !result.length);
@@ -10,13 +10,17 @@ export default async function waitForElementToBeRemoved<T>(
1010
options?: WaitForOptions
1111
): Promise<T> {
1212
// Created here so we get a nice stacktrace
13-
const timeoutError = new Error('Timed out in waitForElementToBeRemoved.');
13+
const timeoutError = new ErrorWithStack(
14+
'Timed out in waitForElementToBeRemoved.',
15+
waitForElementToBeRemoved
16+
);
1417

1518
// Elements have to be present initally and then removed.
1619
const initialElements = expectation();
1720
if (isRemoved(initialElements)) {
18-
throw new Error(
19-
'The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.'
21+
throw new ErrorWithStack(
22+
'The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.',
23+
waitForElementToBeRemoved
2024
);
2125
}
2226

0 commit comments

Comments
 (0)