我正在做一些測試,我正在測試 POST 路由,我認為測試寫得很好,但是現在我收到一個錯誤,上面寫著“從磁盤讀取文件時出錯:錯誤:ENOENT:沒有這樣的文件或目錄,打開'./database.json”describe ("POST /post methods",() => {? it("should get /post ",(done)=>{? ? ?const incomingRequest = {? ? ? ? name: "charanjit",? ? ? ? content: "im posting",? ? ? ? gif: ""? ? ?};? ? chai.request(server)? ? .post("/posts")? ? .send(incomingRequest)? ? .end(function (err, res) {? ? ? expect(res).to.have.status(500)? ? ? done()? ? });? ??? ??? ??})it("should get /comments ",(done)=>{? ? const commente = {? ? ? ?comment: "hi omg"? ? };? ? chai.request(server)? ? .post("/comments")? ? .send(commente)? ? .end(function (err, res) {? ? ? expect(res).to.have.status(200)? ? ? done()? ? });?})? ?it("should get /emoji ",(done)=>{? ? const commente = {? ? comment: "hi omg"?};?chai.request(server)?.post("/comments")?.send(commente)?.end(function (err, res) {? expect(res).to.have.status(200)? done()? });是什么導致了這個錯誤,我是否需要編寫一個訪問數據庫的測試,我有點困惑,我該怎么做?
從磁盤讀取文件時出錯:錯誤:ENOENT:沒有這樣的文件或目錄,打開'./database.json
德瑪西亞99
2023-08-18 17:19:29