wmonk/create-react-app-typescript

vscode jest not getting env=jsdom?

開放

#139 建立於 2017年8月14日

 (4 則留言) (1 個反應) (0 位負責人)JavaScript (480 個分叉)batch import
help wantedquestion

倉庫指標

星標
 (3,677 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Sorry this is kind of specific to my IDE (VSCode) but I hope many of you are using it too. I really like the Jest VSC extension but I haven't gotten it to work w/ my ejected CRA-typescript app yet. When I run the jest command from command line it works fine, but the IDE jest runner responds with:

 FAIL  src/routes/App.test.tsx
  ● renders without crashing

    ReferenceError: document is not defined
      
      at Object.<anonymous> (src/routes/App.test.tsx:6:15)
          at Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)


  ✕ renders without crashing (36ms)

I've tried changing my .vscode/settings.json in the project root folder to

{
   "jest.pathToJest": "node_modules/.bin/jest --env=jsdom"
}

貢獻者指南