push-based / user-flow

📦 Combine Chrome tooling like Lighthouse userflows and DevTools reconder scripts in your CI
MIT License
118 stars 3 forks source link

Can't persist multiple formats #165

Closed ChristopherPHolder closed 1 year ago

ChristopherPHolder commented 1 year ago

A bug is stopping the reports from being persisted in more than one format.

When adding more than one format in the RC file or via the command line, only persists the report in the first format of the array.

The suggested test to stop this bug from coming back is to add a test in collect.format.test.ts which test multiple persist formats at the same time.

Overwriting the formats to only select the first format is caused by initial format assignment

    let initialFormat: ReportFormat | undefined =
      // take the provided formats from cli params or the rc file if given and convert it to a string (yes we can't use multiple initial values :( )
      Array.isArray(config?.persist?.format) ? config.persist.format[0] :
        typeof config.persist.format === 'string' ? config.persist.format :
          // if not use default format from the preset as a suggestion in the prompt choice
          undefined;

It also seems odd that we are checking if format is a string as it should be a array of strings meaning this line should always be false:

typeof config.persist.format === 'string' ? config.persist.format

And not follow the same pattern as other setup methods where we use only one let for the initial value and final value.

However, when it fixing the assignment issue format[0] seems to cause an additional error.

To test it you can simply override the output of the method so that format is an array of more than one format-string.

  format = ['html', 'md'] // Overriding output format 
  return {
    ...config,
    persist: { ...config?.persist, format }
  };
BioPhoton commented 1 year ago

After fixing the format handling