reactjs - Jest --findRelatedTests ilgili testleri bulamıyor
Komutu jest --bail --findRelatedTests src/components/BannerSet/BannerSet.tsx çalıştırdığımda aşağıdaki mesajı alıyorum:
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in C:\Users\user\code\repo.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern: .\\src\\components\\BannerSet\\BannerSet.tsx - 0 matches
Ancak dosyaları hazır tutuyorum:
src/components/BannerSet/BannerSet.test.tsx
src/components/BannerSet/BannerSet.tsx
Jest neden ilgili testleri bulamıyor? Sadece jest çalıştırmak tamamen sorunsuz çalışıyor.
Cevap #1
roots yapılandırmasını kullanıyorsanız, kaynak dizininizi klasörler listesinin içine eklediğinizden emin olun.
Bu sorunla karşılaştım ve bunun nedeni jest yapılandırmamda roots seçeneğini kullanmam ve sadece test klasörüne başvurmam olduğunu fark ettim. Aşağıdaki sorun ve roots belgeleri şunu belirtiyor:
roots, Jest'in dahili işlemleri tarafından test dosyalarını ve kaynak dosyalarını bulmak için kullanılır
İlgili bilgiler:
- Dokümanlar: https://jestjs.io/docs/configuration#roots-arraystring
- Sorun: https://github.com/facebook/jest/issues/11527