@@ -56,10 +56,12 @@ export class NgtxScenarioTestEnvironment<T> {
56
56
57
57
public run ( ) {
58
58
const { _framework, _moduleConfig, _componentType, scenarios } = this ;
59
- const { describe, beforeEach } = _framework ;
59
+ const { describe, fdescribe , beforeEach } = _framework ;
60
60
61
61
for ( const scenario of scenarios ) {
62
- describe ( scenario [ '_description' ] , ( ) => {
62
+ const descriptor = scenario [ '_runFocused' ] ? fdescribe : describe ;
63
+
64
+ descriptor ( scenario [ '_description' ] , ( ) => {
63
65
beforeEach ( async ( ) => {
64
66
await TestBed . configureTestingModule (
65
67
_moduleConfig ,
@@ -84,6 +86,7 @@ export class NgtxTestScenario<T = any> {
84
86
) : NgtxTestScenario < T > {
85
87
return new NgtxTestScenario (
86
88
props . description ,
89
+ props . runFocused ,
87
90
environment ,
88
91
props . moduleConfig ,
89
92
props . componentType ,
@@ -95,6 +98,7 @@ export class NgtxTestScenario<T = any> {
95
98
96
99
private constructor (
97
100
private readonly _description : string ,
101
+ private readonly _runFocused : boolean ,
98
102
private readonly _testEnvironment : NgtxScenarioTestEnvironment < T > ,
99
103
private readonly _moduleConfig : TestModuleMetadata ,
100
104
private readonly _componentType : Type < T > ,
@@ -113,6 +117,7 @@ export class NgtxTestScenario<T = any> {
113
117
{
114
118
componentType : this . _componentType ,
115
119
description : this . _description ,
120
+ runFocused : this . _runFocused ,
116
121
moduleConfig : this . _moduleConfig ,
117
122
modificationsBeforeComponentCreation : [
118
123
...this . _modificationsBeforeComponentCreation ,
@@ -137,6 +142,7 @@ export class NgtxTestScenario<T = any> {
137
142
{
138
143
componentType : this . _componentType ,
139
144
description : this . _description ,
145
+ runFocused : this . _runFocused ,
140
146
moduleConfig : this . _moduleConfig ,
141
147
modificationsBeforeComponentCreation :
142
148
this . _modificationsBeforeComponentCreation ,
@@ -174,16 +180,27 @@ export function useScenarioTesting<T>(
174
180
props . componentType ,
175
181
) ;
176
182
177
- const controlLevelScenario = NgtxTestScenario . from (
178
- { ...props , description : 'Control' } ,
179
- environment ,
180
- ) ;
181
- const controlLevelExpect : NgtxTestScenario < T > [ 'expect' ] =
182
- controlLevelScenario . expect . bind ( controlLevelScenario ) ;
183
+ let runScenarioFocused = false ;
184
+ const only = ( userScenarios : ( ) => unknown ) => {
185
+ runScenarioFocused = true ;
186
+ userScenarios ( ) ;
187
+ runScenarioFocused = false ;
188
+ } ;
189
+
190
+ const controlLevelExpect : NgtxTestScenario < T > [ 'expect' ] = ( ...scenarios ) => {
191
+ return NgtxTestScenario . from (
192
+ { ...props , runFocused : runScenarioFocused , description : 'Control' } ,
193
+ environment ,
194
+ ) . expect ( ...scenarios ) ;
195
+ } ;
183
196
184
197
return {
198
+ only,
185
199
scenario : ( description : string ) =>
186
- NgtxTestScenario . from ( { ...props , description } , environment ) ,
200
+ NgtxTestScenario . from (
201
+ { ...props , runFocused : runScenarioFocused , description } ,
202
+ environment ,
203
+ ) ,
187
204
expect : controlLevelExpect ,
188
205
tests : environment ,
189
206
} ;
0 commit comments