Egg: How to automatically re-run test when file changes?

Created on 31 Mar 2017  ·  6Comments  ·  Source: eggjs/egg

  • Node Version: 6
  • Egg Version: 1.0.0
  • Plugin Name: NONE
  • Plugin Version: NONE
  • Platform: NONE

I think this issue should belong to egg-bin repo, but that repo is no abled to create any issue now. So I posted it here.

  • How to automatically re-run test when file changes?
  • facebook's jest library is really neat, like the ability to run a single test in watch mode, or run tests with mach reg expression. Personally I found it much better than running mocha. Is it possible for me to integrate jest in egg dev environment?

Most helpful comment

egg-bin test support all argv of mocha.

try egg-bin test --watch or npm run test-local -- --watch

All 6 comments

egg-bin test support all argv of mocha.

try egg-bin test --watch or npm run test-local -- --watch

currently egg-bin test is only support mocha, you can extend egg-bin to my-egg-bin and replace test (or add new command such as egg-bin jest) with your own implementation to use others like jest.

see https://github.com/eggjs/egg-bin#custom-egg-bin-for-your-team

egg-bin won't support jest, but you can write test using jest with egg-mock.

cool. I can try to integrate jest when I have time.
egg-bin test --watch and npm run test-local -- --watch works. 👍

npx egg-bin test --watch

won't restart in typescript version although it runs at the first time

It don't work in following command line

    "test-local": "egg-bin test --watch -r egg-ts-helper/register",

maybe mocha don't watch **/*.ts by default, see mocha docs for --watch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dizhifeng picture dizhifeng  ·  3Comments

bupafengyu picture bupafengyu  ·  3Comments

weijiatan456 picture weijiatan456  ·  3Comments

Ailein picture Ailein  ·  3Comments

skyyangpeng picture skyyangpeng  ·  3Comments