stalniy / bdd-lazy-var

Provides UI for testing frameworks such as mocha, jasmine and jest which allows to define lazy variables and subjects.
MIT License
162 stars 14 forks source link

Yarn 2 PnP stricter module resolution and mocha detection #117

Closed vonagam closed 3 years ago

vonagam commented 3 years ago

Yarn 2 introduced new alternative stricter resolution system for modules - Plug'n'Play.

The problem: bdd-lazy-var does not have mocha as a dependency but still relies on it being resolvable during framework detection. PnP system does not allow that.

There is "loose" mode that makes it work, but it still generates warnings about ambiguity and unsoundness of such require call.

stalniy commented 3 years ago

Mocha is a peer dependency. Does it mean yarn PnP doesn’t support peerdeps?

vonagam commented 3 years ago

If it was declared as peer dependency it would have worked. Currently there are no peer dependencies in package.json. I assume that i was done to support both jasmine and mocha.

But now there is peerDependenciesMeta field in package.json (npm, yarn). So you can add mocha into peerDependencies and then mark it as optional in peerDependenciesMeta.

stalniy commented 3 years ago

You are right. For some reason I thought they are all optional peerdeps. Need to change this.

If you have time PR is very welcome!

vonagam commented 3 years ago

This requires only small changes to package.json but i don't know current supported version range for mocha (and jasmine or jest which can be added too), unless you want to use wildcard.

stalniy commented 3 years ago

this ones works for sure + up:

  "optionalDependencies": {
    "mocha": "^4.0.0 || ^3.0.0 || ^2.3.0 || ^5.0.0 || ^6.0.0",
    "jasmine-core": "^2.0.0 || ^3.0.0",
    "jest": "^20.0.0 || ^22.0.0 || ^23.0.0 || ^24.0.0"
  },

just need to use peerDeps + peerDepsMeta

stalniy commented 3 years ago

:tada: This issue has been resolved in version 2.6.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: