@@ -9,19 +9,30 @@ const debug = _debug("unflakable:plugins-common:config");
99
1010export type QuarantineMode = "no_quarantine" | "skip_tests" | "ignore_failures" ;
1111
12- export type UnflakableConfig = {
12+ type UnflakableConfigInner = {
1313 apiBaseUrl : string | undefined ;
14- enabled : boolean ;
1514 failureRetries : number ;
1615 gitAutoDetect : boolean ;
1716 quarantineMode : QuarantineMode ;
18- testSuiteId : string ;
1917 uploadResults : boolean ;
2018} ;
2119
22- type UnflakableConfigFile = Omit < UnflakableConfig , "testSuiteId" > & {
20+ export type UnflakableConfigEnabled = {
21+ enabled : true ;
22+ testSuiteId : string ;
23+ } & UnflakableConfigInner ;
24+
25+ export type UnflakableConfig =
26+ | UnflakableConfigEnabled
27+ | ( {
28+ enabled : false ;
29+ testSuiteId : string | undefined ;
30+ } & UnflakableConfigInner ) ;
31+
32+ type UnflakableConfigFile = {
33+ enabled : boolean ;
2334 testSuiteId : string | undefined ;
24- } ;
35+ } & UnflakableConfigInner ;
2536
2637const defaultConfig : UnflakableConfigFile = {
2738 apiBaseUrl : undefined ,
@@ -196,12 +207,17 @@ const mergeConfigWithEnv = (
196207 config . testSuiteId . length > 0
197208 ) {
198209 debug ( `Using suite ID \`${ config . testSuiteId } \` from config file` ) ;
199- return config as UnflakableConfig ;
200- } else {
210+ return config . enabled
211+ ? // TypeScript has trouble inferring that these types are correct otherwise.
212+ { ...config , enabled : true , testSuiteId : config . testSuiteId }
213+ : { ...config , enabled : false } ;
214+ } else if ( config . enabled ) {
201215 throw new Error (
202216 `Unflakable test suite ID not found in config file or ${ suiteIdOverride . name } environment ` +
203217 "variable"
204218 ) ;
219+ } else {
220+ return { ...config , enabled : false } ;
205221 }
206222} ;
207223
0 commit comments