github
1354 of 1531 branches covered (88.44%)
Branch coverage included in aggregate %.
113 of 1543 new or added lines in 23 files covered. (7.32%)
3 existing lines in 3 files now uncovered.5522 of 10725 relevant lines covered (51.49%)
28.35 hits per line
NEW
|
// eslint-disable no-case-declarations
|
× |
NEW
|
import type { PageSpyPlugin } from '@huolala-tech/page-spy-types'; |
× |
NEW
|
import XhrProxy from './proxy/xhr-proxy'; |
× |
NEW
|
|
× |
NEW
|
// In react native, fetch() is built with whatwg-fetch, which is a polyfill of fetch using XMLHttpRequest. So we only need to proxy XMLHttpRequest.
|
× |
NEW
|
|
× |
NEW
|
export default class NetworkPlugin implements PageSpyPlugin { |
× |
NEW
|
public name = 'NetworkPlugin'; |
× |
NEW
|
|
× |
NEW
|
public xhrProxy: XhrProxy | null = null;
|
× |
NEW
|
|
× |
NEW
|
public static hasInitd = false; |
× |
NEW
|
|
× |
NEW
|
public onInit() {
|
× |
NEW
|
if (NetworkPlugin.hasInitd) return; |
× |
NEW
|
NetworkPlugin.hasInitd = true;
|
× |
NEW
|
|
× |
NEW
|
this.xhrProxy = new XhrProxy(); |
× |
NEW
|
} |
× |
NEW
|
|
× |
NEW
|
public onReset() {
|
× |
NEW
|
this.xhrProxy?.reset();
|
× |
NEW
|
NetworkPlugin.hasInitd = false;
|
× |
NEW
|
} |
× |
NEW
|
} |
× |