99import { JsonObject , schema } from '@angular-devkit/core' ;
1010import yargs from 'yargs' ;
1111
12- import { addSchemaOptionsToCommand , parseJsonSchemaToOptions } from './json-schema' ;
12+ import { Option , addSchemaOptionsToCommand , parseJsonSchemaToOptions } from './json-schema' ;
1313
1414describe ( 'parseJsonSchemaToOptions' , ( ) => {
1515 describe ( 'without required fields in schema' , ( ) => {
@@ -21,10 +21,9 @@ describe('parseJsonSchemaToOptions', () => {
2121 } ;
2222
2323 let localYargs : yargs . Argv < unknown > ;
24- beforeEach ( async ( ) => {
25- // Create a fresh yargs for each call. The yargs object is stateful and
26- // calling .parse multiple times on the same instance isn't safe.
27- localYargs = yargs ( ) . exitProcess ( false ) . strict ( ) . fail ( false ) . wrap ( 1_000 ) ;
24+ let options : Option [ ] ;
25+
26+ beforeAll ( async ( ) => {
2827 const jsonSchema = {
2928 'type' : 'object' ,
3029 'properties' : {
@@ -118,12 +117,20 @@ describe('parseJsonSchemaToOptions', () => {
118117 } ,
119118 } ,
120119 } ;
120+
121121 const registry = new schema . CoreSchemaRegistry ( ) ;
122- const options = await parseJsonSchemaToOptions (
122+ options = await parseJsonSchemaToOptions (
123123 registry ,
124124 jsonSchema as unknown as JsonObject ,
125125 false ,
126126 ) ;
127+ } ) ;
128+
129+ beforeEach ( async ( ) => {
130+ // Create a fresh yargs for each call. The yargs object is stateful and
131+ // calling .parse multiple times on the same instance isn't safe.
132+ localYargs = yargs ( ) . exitProcess ( false ) . strict ( ) . fail ( false ) . wrap ( 1_000 ) ;
133+
127134 addSchemaOptionsToCommand ( localYargs , options , true ) ;
128135 } ) ;
129136
0 commit comments