Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit ef91026

Browse files
authored
fix: allow skip with object but no reason (#318)
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
1 parent b6bda46 commit ef91026

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: js/src/utils/mocha.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ chai.use(dirtyChai)
88

99
module.exports.expect = chai.expect
1010

11+
const isObject = (o) => Object.prototype.toString.call(o) === '[object Object]'
12+
1113
// Get a "describe" function that is optionally 'skipped' or 'onlyed'
1214
// If skip/only are boolean true, or an object with a reason property, then we
1315
// want to skip/only the whole suite
@@ -16,7 +18,9 @@ function getDescribe (config) {
1618
if (config.only === true) return describe.only
1719
if (config.skip === true) return describe.skip
1820

19-
if (config.skip && typeof config.skip === 'object' && config.skip.reason) {
21+
if (isObject(config.skip)) {
22+
if (!config.skip.reason) return describe.skip
23+
2024
const _describe = (name, impl) => {
2125
describe.skip(`${name} (${config.skip.reason})`, impl)
2226
}
@@ -44,7 +48,7 @@ function getIt (config) {
4448
const _it = (name, impl) => {
4549
if (Array.isArray(config.skip)) {
4650
const skip = config.skip
47-
.map((s) => s && typeof s === 'object' ? s : { name: s })
51+
.map((s) => isObject(s) ? s : { name: s })
4852
.find((s) => s.name === name)
4953

5054
if (skip) {

Diff for: js/src/utils/suite.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict'
22

3+
const isObject = (o) => Object.prototype.toString.call(o) === '[object Object]'
4+
35
function createSuite (tests, parent) {
46
const suite = (createCommon, options) => {
57
Object.keys(tests).forEach(t => {
@@ -8,7 +10,7 @@ function createSuite (tests, parent) {
810

911
if (Array.isArray(opts.skip)) {
1012
const skip = opts.skip
11-
.map((s) => s && typeof s === 'object' ? s : { name: s })
13+
.map((s) => isObject(s) ? s : { name: s })
1214
.find((s) => s.name === suiteName)
1315

1416
if (skip) {

0 commit comments

Comments
 (0)