allure-framework / allure-js

Allure integrations for JavaScript test frameworks
https://allurereport.org/
Apache License 2.0
217 stars 112 forks source link

Fix peer deps, remove redundant deps #1046

Closed delatrie closed 4 days ago

delatrie commented 4 days ago

Peer dependencies (Yarn PnP and version warnings support)

The main focus of this PR is to improve Yarn PnP support by properly declaring all runtime dependencies in manifests.

Many Allure packages import packages of the test frameworks. Those could be top-level packages (vitest, mocha), or packages, that are transitive dependencies of some top-level package (e.g., allure-vitest imports @vitest/runner, which is a transitive dependency of vitest).

Yarn PnP requires such packages to be present in the manifest. E.g., @vitest/runner must be declared as a dependency of allure-vitest. Otherwise, Yarn PnP considers it a ghost dependency and fails the import.

Such dependencies are parts of the execution runtime and are installed separately. Therefore, in this PR those are declared as peer dependencies. It prevents unwanted isolation between the version that comes with the test framework (e.g., after yarn install vitest) and the version that otherwise would've been chosen by our package (e.g., after yarn install allure-vitest).

Additionally, is allows to show a warning in case the user installs an unsupported version of the test framework.

Additionally, some Allure packages don't import test framework packages at runtime while are still intended to be run in the test framework environment (e.g., allure-jasmine doesn't import Jasmine packages at runtime). The PR declares such dependencies as optional peer dependencies. It allows users to introduce such packages in any way they find suitable (e.g., Jasmin, although not recommended, could be installed globally) while keeping the unsupported version warnings.

The downside is that Yarn PnP users have to install all non-optional peer dependencies explicitly. I.e., instead of yarn add -D vitest allure-vitest they have to run yarn add -D vitest @vitest/runner allure-vitest.

Peer dependencies table

[!NOTE] I've specified version ranges as >=min-version. That allows users to use newer versions of test frameworks, which often don't break anything, without waiting for us to update the manifest. Alternatively, we may cap the ranges with the current major versions. That will still allow users to update test frameworks but will show them the version mismatch warning until we release the version with updated peer dependencies.

Allure Package Peer Dependency Min Version Optional Optionality comment
allure-codeceptjs codeceptjs 2.3.6 no Unconditional import
allure-cucumberjs @cucumber/cucumber 10.8.0 no Unconditional import
@cucumber/messages 24.1.0 no Unconditional import
allure-cypress cypress 12.17.4 yes Type imports only; allow global install
allure-jasmine jasmine 2.7.0 yes Depends implicitly via the jasmine namespace; allow global install
allure-jest jest 28.0.0 yes No imports; allow global install
jest-cli 28.0.0 yes No imports; allow global install
jest-environment-jsdom 28.0.0 yes Choise between jsdom and node
jest-environment-node 28.0.0 yes Choise between jsdom and node
allure-js-commons allure-playwright workspace yes Conditional import (autoconfig)
allure-mocha mocha 6.2.0 no Unconditional import
allure-playwright @playwright/test 1.36.0 no Unconditional import
allure-vitest @vitest/runner 1.3.0 no Unconditional import
vitest 1.3.0 no Unconditional import
newman-reporter-allure newman 3.5.0 yes Type imports only; allow global install

Redundant dependencies

The PR removes the following redundant dependencies:

Other changes