Run PHPUnit tests on change

后端 未结 10 1702
星月不相逢
星月不相逢 2021-02-07 11:34

I\'d like to run my PHPUnit tests (or at least a subset of them) whenever a file changes on disk. Very similar to what you can do with \"grunt watch\". I have a project in which

10条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-07 11:53

    You can use node watch which is quite sweet:

    Run npm init to set up a package (takes a minute), then

    npm install --save-dev watch
    

    Then edit your package.json file to include these two entries:

    "scripts": {
      "test": "bin/phpunit tests --color",
      "test:watch": "watch 'npm run --silent test' ."
    },
    

    Then trigger the watching with:

    npm run test:watch
    

    (credit due to this interesting article)

提交回复
热议问题