File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1- export default typeof AbortController === "undefined" ? mockit : it ;
1+ export default typeof AbortController === "undefined" || typeof performance === "undefined" ? mockit : it ;
22
33function mockit ( description , run ) {
44 return it ( description , withMock ( run ) ) ;
@@ -13,18 +13,29 @@ mockit.only = (description, run) => {
1313} ;
1414
1515class MockAbortController {
16+ constructor ( ) {
17+ this . signal = { aborted : false } ;
18+ }
1619 abort ( ) {
17- // mock noop for node 14
20+ this . signal . aborted = true ;
21+ }
22+ }
23+
24+ class MockPerformance {
25+ static now ( ) {
26+ return Date . now ( ) ;
1827 }
1928}
2029
2130function withMock ( run ) {
2231 return async ( ) => {
2332 global . AbortController = MockAbortController ;
33+ global . performance = MockPerformance ;
2434 try {
2535 return await run ( ) ;
2636 } finally {
2737 delete global . AbortController ;
38+ delete global . performance ;
2839 }
2940 } ;
3041}
You can’t perform that action at this time.
0 commit comments