TezosTaqueria / taqueria

*BETA* Taqueria provides a seamless development workflow to easily build, test and deploy your Tezos applications.
https://taqueria.io
Apache License 2.0
64 stars 20 forks source link

[Bug]: Jest plugin will not install jest into a usable state if the project is outside of the taqueria repo clone #1098

Closed alexzbusko closed 2 years ago

alexzbusko commented 2 years ago

What happened?

When initializing a taqueria project and wanting to add some tests you first install the jest plugin. If this project is initialized outside of the taqueria repo directory it will run into an issue where jest is not installed and it cannot find the ts-jest package

What should have happened?

We should install all jest dependencies/all things needed for the jest plugin to work as part of the installation process within a taqueria project

Steps to reproduce the bug

Steps to reproduce the error:

  1. Initialize a taqueria project outside of the taqueria repo directory with the taq init {directory_name}
  2. Install the taqueria jest plugin with the taq install @taqueria/plugin-jest command
  3. Run taq test --init
  4. Run taq test tests

Relevant log output

$ taq test tests
● Validation Error:

  Preset ts-jest not found.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

Screenshots and images

Screenshot and images

Code of Conduct

hu3man commented 2 years ago

Is this possibly becuase jest, the jest-cli or @types/jest needs to be moved to dependencies (rather than devDependencies)?

    "dependencies": {
        "@taqueria/node-sdk": "^0.12.0",
        "@taqueria/plugin-contract-types": "^0.10.0",
        "async-retry": "^1.3.3",
        "execa": "^6.1.0",
        "fast-glob": "^3.2.7",
        "jest-config": "^28.1.0"
    },
    "devDependencies": {
        "@types/async-retry": "^1.3.3",
        "@types/jest": "^27.5.1",
        "tsup": "^6.1.3",
        "typescript": "4.7.2",
        "jest": "^28.1.0",
        "jest-cli": "^28.1.0"
    },

@mweichert @GImbrailo @jchenche @AlirezaHaghshenas

hu3man commented 2 years ago

I have performed extensive troubleshooting based on my hypothesis that the issue was an incorrect/missing node dependency. After trying every permutation of Jest dependencies/devDependencies (jest, ts-jest , @types/jest, typescript, jest-config), and trying to install each on the main project; I'm at a dead end

It appears that the error we get:

npm WARN exec The following package was not found and will be installed: jest
● Validation Error:

  Preset ts-jest not found.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

Is actually due to a jest preset called ts-jest. It seems that if I manually install this package on my test project (npm i -D ts-jest), the plugin works as expected

Given that the dependency for ts-jest needs to be installed on the project not the plugin; I'm not sure how to resolve this. I'm not aware of how to solve this with node, but I assume we could check for and run the install command when the user runs taq test

hu3man commented 2 years ago

@mweichert @ricklove , do you have any ideas as to the best way to resolve this?