github
1320 of 1468 branches covered (89.92%)
Branch coverage included in aggregate %.
104 of 2237 new or added lines in 31 files covered. (4.65%)
5289 of 8941 relevant lines covered (59.15%)
31.81 hits per line
NEW
|
import type { InitConfig, OnInitParams, PageSpyPlugin } from '../../types'; |
× |
NEW
|
import { psLog } from '../../utils'; |
× |
NEW
|
import AxiosProxy from './axios'; |
× |
NEW
|
import HttpProxy from './axios'; |
× |
NEW
|
|
× |
NEW
|
export default class NetworkPlugin implements PageSpyPlugin { |
× |
NEW
|
public name = 'NetworkPlugin'; |
× |
NEW
|
|
× |
NEW
|
public axiosProxy: HttpProxy | null = null;
|
× |
NEW
|
|
× |
NEW
|
public static hasInitd = false; |
× |
NEW
|
|
× |
NEW
|
public onInit({ config }: OnInitParams<InitConfig>) {
|
× |
NEW
|
const { axios } = config;
|
× |
NEW
|
if (!axios) {
|
× |
NEW
|
psLog.warn(`Please pass "axios" option to enable ${this.name}`); |
× |
NEW
|
return;
|
× |
NEW
|
} |
× |
NEW
|
|
× |
NEW
|
if (NetworkPlugin.hasInitd) return; |
× |
NEW
|
NetworkPlugin.hasInitd = true;
|
× |
NEW
|
|
× |
NEW
|
this.axiosProxy = new AxiosProxy(axios); |
× |
NEW
|
} |
× |
NEW
|
|
× |
NEW
|
public onReset() {
|
× |
NEW
|
this.axiosProxy.reset();
|
× |
NEW
|
NetworkPlugin.hasInitd = false;
|
× |
NEW
|
} |
× |
NEW
|
} |
× |