how to run unit tests on packages that have changed

I am trying to use lerna (https://github.com/lerna/lerna) to manage my projects.

But one issue I am trying to find out is how to setup my test pipeline. If I only touch two projects, I would like only test cases from that two project will be executed.

But from what I read so far, seems like I will have to run all unit tests for all projects.

Does anyone have any idea how to execute on projects that changes only?

1 answer

  • answered 2018-03-13 21:15 Username123

    I think you can use this: https://www.npmjs.com/package/run-when-changed

    and write something like this for each package (taken from then npm page)

      $ run-when-changed \
      --watch "tests/**/*-test.js" \
      --exec "mocha --require babel-register %s" \
      --verbose
    

    enter code here

    But replace tests/**/*-test.js with the files in your package And replace mocha --require babel-register %s with a command running mocha on that specific package