簡體   English   中英

調試在vs代碼中以打字稿節點編寫的茉莉花測試

[英]Debug jasmine tests written in typescript node in vs code

我用茉莉花寫了單元測試,這些都用打字稿寫

// about.service.spec.ts
// say 4 to 5 test cases

// spec/support/jasmine.json
{
  "spec_dir": "src/tests/",
  "spec_files": ["**/*.spec.ts"],
  "helpers": ["jasmine-helpers/**/*.ts"],
  ...
}

// launch.json - vscode file
{
  "version": "0.2.0",
  "configurations": [{
      "type": "node",
      "request": "launch",
      "name": "Jasmine tests",
      "preLaunchTask": "debuggertests",
   }]
}

// tasks.json - vscode 
{
 "version": "2.0.0",
 "tasks": [{
    "label": "debuggertests",
    "type": "npm",
    "script": "test:unit",
    "problemMatcher": []
  }]
}

// package.json
// have to use jasmine-ts which is flavor over ts-node
"test:unit": "jasmine-ts JASMINE_CONFIG_PATH=spec/support/jasmine.json"

我已經使用此配置在vscode中調試.spec.ts文件,但是它沒有啟動調試器,而是運行所有測試並開始調試。

我在about.service.spec.ts的測試用例之一中放置了一個斷點,但未觸發任何斷點。 有人可以幫我設置茉莉測試的vscode調試嗎?

下面的配置將調試當前的測試文件-請在VS Code中打開所需的測試文件,然后使用此配置開始調試:

{
      "type": "node",
      "request": "launch",
      "name": "Jasmine Current File",
      "program": "${workspaceFolder}/node_modules/jasmine-ts/lib/index",
      "args": ["${file}"],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
 }

在新的jasmine-ts版本中,您必須將jasmine.json包含在args中,如下所示:

{
  "type": "node",
  "request": "launch",
  "name": "Jasmine Current File",
  "program": "${workspaceFolder}/node_modules/jasmine-ts/lib/index",
  "args": ["--config=jasmine.json", "${file}"],
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen"
}

為避免此問題:

找不到規格,在0.003秒內完成不完整:找不到規格隨機種子60766(茉莉花--random = true --seed = 60766)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM