allure-framework/allure-js

Allure-cypress: Type 'PluginConfigOptions' has no properties in common with type 'AllureCypressConfig'

nbouvrette opened this issue · 3 comments

Describe the bug
When using allure-cypress with TypeScript, the AllureCypressConfig config is invalid and we get the following error:

Type 'PluginConfigOptions' has no properties in common with type 'AllureCypressConfig'.ts(2559)

To Reproduce
Steps to reproduce the behavior:

  1. Setup your Cypress test using TypeScript and install allure-cypress
  2. Add the following code in cypress.config.ts:
import { defineConfig } from "cypress";
import { allureCypress } from 'allure-cypress/reporter'

export default defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      allureCypress(on, config)
    },
  },
})
  1. See the error on this line: allureCypress(on, config)

Expected behavior
There should be no error.

Additional context
The fix is most likely in allure-cypress/dist/reporter.d.ts : simply adding the Cypress type (PluginConfigOptions) in AllureCypressConfig:

export type AllureCypressConfig = Cypress.PluginConfigOptions & {
    resultsDir?: string;
    links?: {
        type: string;
        urlTemplate: string;
    }[];
};

I just noticed maybe Allure is not using any of the Cypress config and the proper way to use this is like this:

import { defineConfig } from "cypress";
import { allureCypress } from 'allure-cypress/reporter'

export default defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      allureCypress(on)
    },
  },
})

I'm going to close this issue for now!

Actually I just noticed, something is off here because in the documentation is does recommend passing config which is invalid. So either the documentation needs to be updated or the type needs to be updated.

Reference: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md

This is the example in the doc:

import { defineConfig } from "cypress";
import { allureCypress } from "allure-cypress/reporter";

export default defineConfig({
  e2e: {
    setupNodeEvents: (on, config) => {
      allureCypress(on, config);

      return config;
    },
    // ...
  },
});

Hi, @nbouvrette !
This should be fixed in allure-cypress@3.0.0-beta.10. Could you please verify that?

The new signature of allureCypress is this:

(on: Cypress.PluginEvents, cypressConfig?: Cypress.PluginConfigOptions, allureConfig?: AllureCypressConfig) => AllureCypress;