Git Product home page Git Product logo

Comments (4)

ArturT avatar ArturT commented on May 28, 2024 2

@yagudaev I've released a new version of @knapsack-pro/cypress 4.0.0. It uses peerDependency so it means your cypress version defined in your project package.json will be used by @knapsack-pro/cypress.

I also added support for Cypress 5.x so @knapsack-pro/cypress currently works with Cypress 3.x, 4.x, 5.x.

from knapsack-pro-cypress.

ArturT avatar ArturT commented on May 28, 2024 1

Hey @yagudaev

This change "cypress": ">= 4.9.0" is not needed but I did it and released a new version of @knapsack-pro/cypress where I applied your suggestion.

This "cypress": ">= 4.9.0" will make @knapsack-pro/cypress work also with Cypress 5.x if it will be ever released in the future.

Here is PR with my change: #33

After the fact. Once I released above change I realized that the "cypress": "^4.9.0" was already good enough so your suggestion was not needed.
https://docs.npmjs.com/misc/semver#caret-ranges-123-025-004
Caret range allows updating minor and patch version so any 4.x version of cypress should be possible to install.

What you did in package.json is expect. Programmer should be able to control what Cypress version he wants to use. You should explicitly specify Cypress version you want to use.

{
  "devDependencies": {
    "@knapsack-pro/cypress": "3.1.0",
    "cypress": "^4.11.0",
  },
}

Side thought. A while ago someone suggest to me to use peerDepenency https://docs.npmjs.com/files/package.json#peerdependencies so I'm thinking about it as a solution to make it more explicit for programmers to manage test runner like Cypress or Jest version that is used in their project.

from knapsack-pro-cypress.

ArturT avatar ArturT commented on May 28, 2024 1

I consulted this bug with @rafaltrzop who initially helped develop the project.

It made me realized that I did not understand the full picture.

@yagudaev You are using https://www.npmjs.com/package/npm-force-resolutions package to force installing a specific version of Cypress. This explains why in your project you have resolutions.

// package.json of your project
{
  "devDependencies": {
    "cypress": "^4.11.0",
   } ,
  "resolutions": {
    "cypress": "^4.11.0"
   }
}

If you wouldn't use resolutions then the fact that I added "cypress": ">= 4.9.0" in package.json for @knapsack-pro/cypress it would do nothing. When you add @knapsack-pro/cypress to your project package.json then knapsack will be installed with cypress version exactly specified inside of package-lock.json of @knapsack-pro/cypress. Because of that when you will run tests with knapsack then it will use old Cypress version.
But when you use Cypress in development environment without knapsack then you will use newer version of cypress.

This could lead to bugs because someone in the development environment may use new cypress features but on CI he will use @knapsack-pro/cypress with older Cypress version.

To fix this problem we should use peerDepenency specified in package.json for @knapsack-pro/cypress. Then when someone will install @knapsack-pro/cypress he must also explicitly install Cypress in his project package.json (we could add info about it in our readme to make installation smooth because not every developer may be familiar with peerDependency). Thanks to that developer will control what version of Cypress is used and exactly the same Cypress version will be used in development when running tests without knapsack (only with cypress) and the same version of cypress will be used on CI when running tests with @knapsack-pro/cypress.

FYI @shadre

from knapsack-pro-cypress.

yagudaev avatar yagudaev commented on May 28, 2024 1

Thank you @ArturT for the quick and detailed response.

from knapsack-pro-cypress.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.