sindresorhus / gulp-mocha

Run Mocha tests
MIT License
375 stars 91 forks source link

Mocha is spawned in a child process #166

Closed braxnu closed 7 years ago

braxnu commented 7 years ago

Not sure if this is a real issue or is it me doing it wrong.

In my case, gulp starts the express server and then runs mocha to test the route handlers. Some of the route handlers issue their own request as their purpose is a sort of a proxy service.

Before, in the mocha specs I was able to use nock to mock the requests issued by route handlers. Since mocha is now run in a separate process, nock does not affect these requests (as they still run in the "main" process).

Is it me doing it wrong or quite unexpected change of behaviour?

sindresorhus commented 7 years ago

You have to use Nock in your test file, not your gulpfile. Something you should have done in the first place anyways.

braxnu commented 7 years ago

Please read it again. This is what I do.

sindresorhus commented 7 years ago

By Nock, I meant Express. You have to have everything in your test file, or imported into it. This is a good thing. Your gulpfile should not be intertwined with testing logic.

braxnu commented 7 years ago

That's a fair point. Thanks