npm posttest does not work when tests fail in npm test #5493

Closed
nirvanagit opened this Issue Jun 16, 2014 · 3 comments

Comments

Projects
None yet
5 participants

npm test has a pre and a post.
On passing test. npm test triggers npm posttest.

But when any of the test cases fail, npm test does not trigger posttest.

@isaacs - You are the best person for this.

@iarna iarna added the bug label Sep 19, 2014

Contributor

smikes commented Nov 20, 2014

Is this still a problem for you?

I believe this is unlikely to change, since the contract on the pre/thing/post scripts is implicitly npm run-script prefoo && npm run-script foo && npm run-script postfoo -- that is, the expectation is that the pre script can prevent later scripts from running, and that the post script will not run if the thing script failed.

Can you tell me a bit more about what you are trying to accomplish in posttest?

We are trying to clean up older npm issues, so if we don't hear back from you within a week, we will close this issue. (Don't worry -- you can always come back again and re-open it!)

Thanks!

Contributor

othiym23 commented Dec 2, 2014

In the vast majority of cases, users are going to be unpleasantly surprised if posttest runs after test failures (you don't want your test environment being cleaned up or new versions being published if there were test failures, for instance). As such, this behavior isn't going to change. Putting something like "test":"npm run-script test-failing || npm run-script mandatory-cleanup" into your package.json will give you what you want.

Closing as resolved!

@othiym23 othiym23 closed this Dec 2, 2014

@kangas kangas referenced this issue in mongodb-js/collection-sample Jan 27, 2016

Merged

INT-1105 add read preference explicitly to work with secondaries. #28

Not reopening this issue, but just in case anyone find it helpful, I used npm-run-all for cross-platform capatibility, since || means different things in Windows vs Mac

"the-actual-test": "…",
"test": "npm-run-all the-actual-test run-after-test-even-if-failed --continue-on-error",
"run-after-test-even-if-failed": "…"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment