From b3149cfaf388a24d7355525b859861192afc6d4e Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 5 Dec 2018 13:50:45 +0000 Subject: [PATCH 1/2] fix: allow only by object The only option will now accept an object for onlying a specific test. Previously you could only do this to only run a specific test: ```js { only: ['should test a thing'] } ``` Now you can do this: ```js { only: [{ name: 'should test a thing', reason: 'because development' // optional! }] } ``` License: MIT Signed-off-by: Alan Shaw --- js/src/utils/mocha.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/src/utils/mocha.js b/js/src/utils/mocha.js index c21ae8739..059592615 100644 --- a/js/src/utils/mocha.js +++ b/js/src/utils/mocha.js @@ -59,7 +59,14 @@ function getIt (config) { } if (Array.isArray(config.only)) { - if (config.only.includes(name)) return it.only(name, impl) // eslint-disable-line + const only = config.only + .map((o) => isObject(o) ? o : { name: o }) + .find((o) => o.name === name) + + if (only) { + if (only.reason) name = `${name} (${only.reason})` + return it.only(name, impl) // eslint-disable-line + } } it(name, impl) From e2a85a57850ed41a2ef1531a14f70a60527fe8b0 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 11 Dec 2018 20:02:42 +0000 Subject: [PATCH 2/2] fix: disable just the rule we're breaking License: MIT Signed-off-by: Alan Shaw --- js/src/utils/mocha.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/utils/mocha.js b/js/src/utils/mocha.js index 059592615..d9fe0fb68 100644 --- a/js/src/utils/mocha.js +++ b/js/src/utils/mocha.js @@ -65,7 +65,7 @@ function getIt (config) { if (only) { if (only.reason) name = `${name} (${only.reason})` - return it.only(name, impl) // eslint-disable-line + return it.only(name, impl) // eslint-disable-line no-only-tests/no-only-tests } } @@ -73,7 +73,7 @@ function getIt (config) { } _it.skip = it.skip - _it.only = it.only // eslint-disable-line + _it.only = it.only // eslint-disable-line no-only-tests/no-only-tests return _it }