We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8e9abf9 commit 874cec6Copy full SHA for 874cec6
tests/e2e/utils/utils.ts
@@ -1,9 +1,12 @@
1
2
-export function expectToFail(fn: () => Promise<any>): Promise<void> {
+export function expectToFail(fn: () => Promise<any>, errorMessage?: string): Promise<void> {
3
return fn()
4
.then(() => {
5
- throw new Error(`Function ${fn.source} was expected to fail, but succeeded.`);
6
- }, () => {});
+ const functionSource = fn.name || (<any>fn).source || fn.toString();
+ const errorDetails = errorMessage ? `\n\tDetails:\n\t${errorMessage}` : '';
7
+ throw new Error(
8
+ `Function ${functionSource} was expected to fail, but succeeded.${errorDetails}`);
9
+ }, () => { });
10
}
11
12
export function isMobileTest() {
0 commit comments