Skip to content

feat: helper script to fail tests on unhandled rejections - #1422

Closed
vonagam wants to merge 1 commit into
feathersjs:masterfrom
vonagam:feat-test-rejections
Closed

vonagam wants to merge 1 commit into
feathersjs:masterfrom
vonagam:feat-test-rejections

Conversation

@vonagam

@vonagam vonagam commented Jun 27, 2019

Copy link
Copy Markdown
Member

Usage with mocha: --require @feathersjs/adapter-tests/lib/rejections.

@vonagam
vonagam force-pushed the feat-test-rejections branch from a6e74bb to 3f422f3 Compare June 28, 2019 00:28
@daffl

daffl commented Jul 1, 2019 •

Copy link
Copy Markdown
Member

I locked the version in KnexJS via feathersjs/feathers-knex@054360d so it is on the latest which doesn't have the unhandled promise rejection issue. Since it really was a bug in the upstream library do you think we'll still need this PR? I don't think I've seen this problem anywhere else before since actual test and adapter errors should still fail normally.

@vonagam

vonagam commented Jul 1, 2019

Copy link
Copy Markdown
Member Author

The problem was on both sides.

Knex introduced code which produced unhandled rejections. That their fault.

But on feathers side current test system did not catch those rejections, all was green and a pull request from greenkeeper was merged. That what should be fixed as unhandled rejections is a serious deal. And it will take only one line in mocha.opts to ensure this will not happen latter in knex adapter or any other.

Later on when node will change behaviour and start to crash on unhandled rejections by itself this file and the mocha option can be simply removed.

@vonagam
vonagam force-pushed the feat-test-rejections branch from 3f422f3 to 0c66925 Compare July 1, 2019 02:56
@vonagam

vonagam commented Jul 1, 2019

Copy link
Copy Markdown
Member Author

Changed the script. Now tests will continue to run after an unhandled rejection, but before process exit it will ensure that exit status is non-zero if there were any rejections. I think this is more suitable for tests than abrupt exit as you will be able to see tests results.

@vonagam

vonagam commented Jul 1, 2019

Copy link
Copy Markdown
Member Author

Alternative solution is to add loud-rejection to dependencies, then in adapter you use it like --require loud-rejection/register. This solution requires no additional file but an additional dependency.

@vonagam

vonagam commented Jul 1, 2019

Copy link
Copy Markdown
Member Author

Closing in favour of using loud-rejection directly in specific packages.

Here is PR for feathers-knex.

@vonagam vonagam closed this Jul 1, 2019
@daffl

daffl commented Jul 1, 2019

Copy link
Copy Markdown
Member

That makes sense, thank you! Since it's only a development dependency I think this is fine.

@vonagam
vonagam deleted the feat-test-rejections branch July 2, 2019 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants