Preparing search index...
The search index is not available
Midway v3 Api Reference
Midway v3 Api Reference
@midwayjs/core
MidwayMockService
Class MidwayMockService
Hierarchy
MidwayMockService
Index
Constructors
constructor
Properties
application
Context
cache
context
Mocks
mocks
simulator
List
prepare
Mocks
Methods
apply
Context
Mocks
get
Context
Mocks
Size
init
init
Simulation
is
Mocked
mock
Class
Property
mock
Context
mock
Property
restore
run
Simulator
App
Setup
run
Simulator
App
Tear
Down
run
Simulator
Context
Setup
run
Simulator
Context
Tear
Down
run
Simulator
Setup
run
Simulator
Tear
Down
mock
Class
Property
mock
Property
Constructors
constructor
new
Midway
Mock
Service
(
applicationContext
:
IMidwayContainer
)
:
MidwayMockService
Parameters
applicationContext:
IMidwayContainer
Returns
MidwayMockService
Properties
Readonly
application
Context
application
Context
:
IMidwayContainer
Protected
cache
cache
:
Map
<
any
,
any
>
= ...
Protected
context
Mocks
context
Mocks
:
{
app
:
IMidwayBaseApplication
<
Context
>
;
key
:
string
|
(
(
ctx
:
Context
)
=>
void
)
;
value
:
any
;
}
[]
= []
Protected
mocks
mocks
:
any
[]
= []
Protected
simulator
List
simulator
List
:
ISimulation
[]
= []
Static
prepare
Mocks
prepare
Mocks
:
any
[]
= []
Methods
apply
Context
Mocks
apply
Context
Mocks
(
app
:
IMidwayBaseApplication
<
Context
>
, ctx
:
Context
)
:
void
Parameters
app:
IMidwayBaseApplication
<
Context
>
ctx:
Context
Returns
void
get
Context
Mocks
Size
get
Context
Mocks
Size
(
)
:
number
Returns
number
init
init
(
)
:
Promise
<
void
>
Returns
Promise
<
void
>
init
Simulation
init
Simulation
(
)
:
Promise
<
void
>
Returns
Promise
<
void
>
is
Mocked
is
Mocked
(
obj
:
any
, key
:
any
)
:
any
Parameters
obj:
any
key:
any
Returns
any
mock
Class
Property
mock
Class
Property
(
clzz
:
(
new
(
...
args
:
any
[]
)
=>
any
)
, propertyName
:
string
, value
:
any
)
:
void
Parameters
clzz:
(
new
(
...
args
:
any
[]
)
=>
any
)
new
(
...
args
:
any
[]
)
:
any
Parameters
Rest
...
args:
any
[]
Returns
any
propertyName:
string
value:
any
Returns
void
mock
Context
mock
Context
(
app
:
IMidwayBaseApplication
<
Context
>
, key
:
string
|
(
(
ctx
:
Context
)
=>
void
)
, value
?:
any
)
:
void
Parameters
app:
IMidwayBaseApplication
<
Context
>
key:
string
|
(
(
ctx
:
Context
)
=>
void
)
Optional
value:
any
Returns
void
mock
Property
mock
Property
(
obj
:
any
, key
:
string
, value
:
any
)
:
void
Parameters
obj:
any
key:
string
value:
any
Returns
void
restore
restore
(
)
:
void
Returns
void
run
Simulator
App
Setup
run
Simulator
App
Setup
(
app
:
IMidwayBaseApplication
<
Context
>
)
:
Promise
<
void
>
Parameters
app:
IMidwayBaseApplication
<
Context
>
Returns
Promise
<
void
>
run
Simulator
App
Tear
Down
run
Simulator
App
Tear
Down
(
app
:
IMidwayBaseApplication
<
Context
>
)
:
Promise
<
void
>
Parameters
app:
IMidwayBaseApplication
<
Context
>
Returns
Promise
<
void
>
run
Simulator
Context
Setup
run
Simulator
Context
Setup
(
ctx
:
Context
, app
:
IMidwayBaseApplication
<
Context
>
)
:
Promise
<
void
>
Parameters
ctx:
Context
app:
IMidwayBaseApplication
<
Context
>
Returns
Promise
<
void
>
run
Simulator
Context
Tear
Down
run
Simulator
Context
Tear
Down
(
ctx
:
Context
, app
:
IMidwayBaseApplication
<
Context
>
)
:
Promise
<
void
>
Parameters
ctx:
Context
app:
IMidwayBaseApplication
<
Context
>
Returns
Promise
<
void
>
run
Simulator
Setup
run
Simulator
Setup
(
)
:
Promise
<
void
>
Returns
Promise
<
void
>
run
Simulator
Tear
Down
run
Simulator
Tear
Down
(
)
:
Promise
<
void
>
Returns
Promise
<
void
>
Static
mock
Class
Property
mock
Class
Property
(
clzz
:
(
new
(
...
args
:
any
[]
)
=>
any
)
, propertyName
:
string
, value
:
any
)
:
void
Parameters
clzz:
(
new
(
...
args
:
any
[]
)
=>
any
)
new
(
...
args
:
any
[]
)
:
any
Parameters
Rest
...
args:
any
[]
Returns
any
propertyName:
string
value:
any
Returns
void
Static
mock
Property
mock
Property
(
obj
:
(
new
(
...
args
:
any
[]
)
=>
any
)
, key
:
string
, value
:
any
)
:
void
Parameters
obj:
(
new
(
...
args
:
any
[]
)
=>
any
)
new
(
...
args
:
any
[]
)
:
any
Parameters
Rest
...
args:
any
[]
Returns
any
key:
string
value:
any
Returns
void
Settings
Member Visibility
Protected
Inherited
External
Theme
OS
Light
Dark
Modules
Midway v3
Api
Reference
@midwayjs/bootstrap
@midwayjs/core
Consumer
Metadata
FaaSMetadata
GRPCMetadata
@midwayjs/decorator
@midwayjs/koa
Midway
Mock
Service
constructor
application
Context
cache
context
Mocks
mocks
simulator
List
prepare
Mocks
apply
Context
Mocks
get
Context
Mocks
Size
init
init
Simulation
is
Mocked
mock
Class
Property
mock
Context
mock
Property
restore
run
Simulator
App
Setup
run
Simulator
App
Tear
Down
run
Simulator
Context
Setup
run
Simulator
Context
Tear
Down
run
Simulator
Setup
run
Simulator
Tear
Down
mock
Class
Property
mock
Property
Generated using
TypeDoc