forked from nock/nock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (48 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict'
const back = require('./lib/back')
const emitter = require('./lib/global_emitter')
const {
activate,
isActive,
isDone,
pendingMocks,
activeMocks,
removeInterceptor,
disableNetConnect,
enableNetConnect,
removeAll,
abortPendingRequests,
} = require('./lib/intercept')
const recorder = require('./lib/recorder')
const { Scope, load, loadDefs, define } = require('./lib/scope')
module.exports = (basePath, options) => new Scope(basePath, options)
Object.assign(module.exports, {
activate,
isActive,
isDone,
pendingMocks,
activeMocks,
removeInterceptor,
disableNetConnect,
enableNetConnect,
// TODO-12.x Historically `nock.cleanAll()` has returned the nock global.
// The other global methods do not do this, so it's not clear this was
// deliberate or is even helpful. This shim is included for backward
// compatibility and shoulud be replaced with an alias to `removeAll()`.
cleanAll() {
removeAll()
return module.exports
},
abortPendingRequests,
load,
loadDefs,
define,
emitter,
recorder: {
rec: recorder.record,
clear: recorder.clear,
play: recorder.outputs,
},
restore: recorder.restore,
back,
})