avencera / rustywind

CLI for organizing Tailwind CSS classes
Apache License 2.0
474 stars 26 forks source link

What is the best practice to use rustywind with jest ? #41

Open puneetmakkar opened 3 years ago

puneetmakkar commented 3 years ago

Hi @praveenperera ,

Thanks for the great package.

We are using lint-staged and husky for pre-commit hooks.

rustywind changes the class order on changed files on commit and later jest test fails as snapshots have not been updated. test failure causes the rustywind changes to be reverted.

any idea on how can we resolve the issue ?

  "lint-staged": {
    "*.{js,jsx,ts,tsx}": [
      "rustywind --write",
      "cross-env CI=true react-scripts test --findRelatedTests"
    ]
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "post-commit": "git update-index -g"
    }
  }

Thanks.

ftonato commented 2 years ago

Hello @puneetmakkar,

I could be completely wrong, but if you need to generate the snapshots correctly, you need to run the command rustywind --write as well before generating them, this way the problem will be avoided 🏆