Open Kumasan850314 opened 1 year ago
執行 npm run test
時,碰到一個 error,把 NodeJs 安裝最新版本就解決了,紀錄一下。
if (error?.stack) {
^
SyntaxError: Unexpected token '.'
at Object.compileFunction (vm.js:344:18)
at wrapSafe (internal/modules/cjs/loader.js:1048:15)
at Module._compile (internal/modules/cjs/loader.js:1082:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\Kumas\20221226test\node_modules\jest\node_modules\jest-cli\build\index.js:12:12)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 20221226test@1.0.0 test: `jest index.test.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 20221226test@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
正確的測試結果,會有 PASS
錯誤的測試結果,Test Suites 就可以看到有測試失敗的次數
在終端機輸入什麼可以執行測試?
npm run test
就可以執行了。index.js
index.test.js