Bahkan proyek yang paling sederhana, seperti yang dijelaskan dalam panduan _Memulai_ sekarang gagal.
Buat proyek sampel ( sum.js
dan sum.spec.js
) dan kemudian coba jalankan Jest, gagal dengan Couldn't find preset "es2015" relative to directory "/Users/ianp/Projects"
. Atau lihat Intisari ini: https://Gist.github.com/0e44151b16718ebc83bb25efb68a9395 .
Dalam konfigurasi debug (di bawah) saya dapat melihat bahwa itu mengatur usesBabelJest
menjadi true, meskipun saya tidak yakin mengapa itu harus menjadi dasar karena saya tidak menggunakan Babel dalam proyek saya. Saya sudah mencoba menambahkan usesBabelTest: false
ke package.json
tetapi itu tidak ada bedanya. Saya juga dapat melihat bahwa preset
tampaknya nol dalam konfigurasi, yang tampaknya aneh mengingat pesan kesalahan
jest version = 16.0.0
test framework = jasmine2
config = {
"rootDir": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395",
"name": "-Users-ianp-Projects-0e44151b16718ebc83bb25efb68a9395",
"setupFiles": [],
"testRunner": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395/node_modules/jest-jasmine2/build/index.js",
"scriptPreprocessor": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395/node_modules/babel-jest/build/index.js",
"usesBabelJest": true,
"automock": false,
"bail": false,
"browser": false,
"cacheDirectory": "/var/folders/5p/qfkdcjcj343gnxdn0cy8_6l40000gn/T/jest",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"globals": {},
"haste": {
"providesModuleNodeModules": []
},
"mocksPattern": "__mocks__",
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"json",
"jsx",
"node"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": [],
"noStackTrace": false,
"notify": false,
"preset": null,
"preprocessorIgnorePatterns": [
"/node_modules/"
],
"resetModules": false,
"testEnvironment": "jest-environment-jsdom",
"testPathDirs": [
"/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
"testURL": "about:blank",
"timers": "real",
"useStderr": false,
"verbose": null,
"watch": false,
"cache": true,
"watchman": true,
"testcheckOptions": {
"times": 100,
"maxSize": 200
}
}
Prasetel harus berasal dari .babelrc
di suatu tempat di pohon Anda. Jika ada, Jest saat ini akan menggunakannya secara otomatis.
Memperbaiki:
.babelrc
Doh! ada file .babelrc
di direktori induk, tidak yakin bagaimana itu sampai di sana
Terima kasih atas petunjuknya!
Komentar yang paling membantu
Prasetel harus berasal dari
.babelrc
di suatu tempat di pohon Anda. Jika ada, Jest saat ini akan menggunakannya secara otomatis.