Skip to content

Commit 6be6e2e

Browse files
authored
fix: Add Promise<void> return type for expectation (#26)
* fix: add Promise<void> return type for expectation Since 0.6.0 promises and async/await are supported and tested, but the return type of the expectation function did not yet reflect this change. * fix SecurityError when running tests Jest fails the tests with “SecurityError: localStorage is not available for opaque origins”. Setting the Jest configuration option "testURL" to "http://localhost/" fixes this (also see: jsdom/jsdom#2304 (comment)). It’s probably a good idea to upgrade dependencies and remove this option afterwards, since with the current release of Jest this option is no longer required (it defaults to "http://localhost/“ instead of “about:blank”).
1 parent a59b638 commit 6be6e2e

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"transform": {
7979
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest"
8080
},
81-
"testRegex": "/src/.*\\.spec\\.(js|ts|tsx)$"
81+
"testRegex": "/src/.*\\.spec\\.(js|ts|tsx)$",
82+
"testURL": "http://localhost/"
8283
}
8384
}

src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
* @param interval Number Wait-between-retries interval, 50ms by default
77
* @return Promise Promise to return a callback result
88
*/
9-
export default function waitForExpect(expectation: () => void, timeout?: number, interval?: number): any;
9+
export default function waitForExpect(expectation: () => void | Promise<void>, timeout?: number, interval?: number): any;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const defaults = {
1414
* @return Promise Promise to return a callback result
1515
*/
1616
const waitForExpect = function waitForExpect(
17-
expectation: () => void,
17+
expectation: () => void | Promise<void>,
1818
timeout = defaults.timeout,
1919
interval = defaults.interval
2020
) {

0 commit comments

Comments
 (0)