簡體   English   中英

start-server-and-test 啟動測試服務器后不啟動測試用例

[英]start-server-and-test not starting test cases after starting the test server

我正在嘗試使用start-server-and-test npm 包並想要運行測試用例。 為此,我首先需要啟動一個測試服務器,然后運行測試命令。 這就是我的package.json腳本部分的樣子。

現在的問題是 start-server-and-test 正在啟動測試服務器,但沒有啟動測試用例。

{
...
...
  "scripts": {
    "test": "jest --runInBand --config jest.config.json",
    "dev": "nodemon --watch 'src/**' --ext 'ts,js' --exec \"ts-node src/app.ts\"",
    "start": "ts-node src/app.ts",
    "test-server": "MYSQL_TABLE_PREFIX=TEST_ PORT=4001 ts-node src/app.ts",
    "ci": "start-server-and-test 'yarn test-server' http://localhost:4001/ 'yarn test'"
  },
...
...
}

所以我發現問題是我的端點http://localhost:4001/沒有響應 200 狀態代碼,因此命令yarn test沒有被執行。 然后我將端點更改為http://localhost:4001/health ,它給出了 200 狀態代碼,然后測試用例被執行。

所以現在 package.json 看起來像這樣

{
...
...
  "scripts": {
    "test": "jest --runInBand --config jest.config.json",
    "dev": "nodemon --watch 'src/**' --ext 'ts,js' --exec \"ts-node src/app.ts\"",
    "start": "ts-node src/app.ts",
    "test-server": "MYSQL_TABLE_PREFIX=TEST_ PORT=4001 ts-node src/app.ts",
    "ci": "start-server-and-test 'yarn test-server' http://localhost:4001/health 'yarn test'"
  },
...
...
}

暫無
暫無

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

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