@tapjs/filter
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -71,2 +71,3 @@ import { PromiseWithSubtest, TapPlugin, TestBase, TestBaseOpts } from '@tapjs/core'; | ||
description: string; | ||
nodeArgs: (v: boolean) => string[]; | ||
}; | ||
@@ -94,2 +95,3 @@ /** | ||
description: string; | ||
nodeArgs: (value: string[]) => string[]; | ||
}; | ||
@@ -120,3 +122,19 @@ /** | ||
}; | ||
/** | ||
* flag | ||
* | ||
* Do not apply a skip message to tests filtered using `--grep` | ||
* and `--only`. | ||
* | ||
* Enabled by default if `--fail-skip` is set. | ||
*/ | ||
'filter-quietly': { | ||
type: string; | ||
description: string; | ||
}; | ||
'no-filter-quietly': { | ||
type: string; | ||
description: string; | ||
}; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,2 +5,3 @@ "use strict"; | ||
const core_1 = require("@tapjs/core"); | ||
const reRegExpLiteral = /^\/(.*)\/([a-z]*)$/; | ||
/** | ||
@@ -16,2 +17,3 @@ * Class that provides the {@link @tapjs/filter!Filter#only} method, and | ||
#runOnly; | ||
#filterQuietly; | ||
get runOnly() { | ||
@@ -25,2 +27,5 @@ return this.#runOnly; | ||
this.#t = t; | ||
const eq = core_1.env?.TAP_FILTER_QUIETLY; | ||
this.#filterQuietly = | ||
eq === '1' || (!!t.options.failSkip && eq !== '0'); | ||
// don't filter test files when we're the cli test runner | ||
@@ -39,3 +44,3 @@ const { grep, grepInvert, runOnly } = opts.context === Symbol.for('tap.isRunner') | ||
this.#grep = core_1.env.TAP_GREP.split('\n').map(g => { | ||
const p = g.match(/^\/(.*)\/([a-z]*)$/); | ||
const p = g.match(reRegExpLiteral); | ||
g = p && p[1] ? p[1] : g; | ||
@@ -75,5 +80,7 @@ const flags = p ? p[2] : ''; | ||
if (!match) { | ||
const p = `filter${this.#grepInvert ? ' out' : ''}: ${pattern}`; | ||
opts.skip = p; | ||
return shouldSkipChild(opts); | ||
if (!this.#filterQuietly) { | ||
opts.skip = `filter${this.#grepInvert ? ' out' : ''}: ${pattern}`; | ||
} | ||
shouldSkipChild(opts); | ||
return true; | ||
} | ||
@@ -90,5 +97,7 @@ else { | ||
if (this.#runOnly && !opts.only) { | ||
const p = 'filter: only'; | ||
opts.skip = p; | ||
return shouldSkipChild(opts); | ||
if (!this.#filterQuietly) { | ||
opts.skip = 'filter: only'; | ||
} | ||
shouldSkipChild(opts); | ||
return true; | ||
} | ||
@@ -136,2 +145,3 @@ if (opts.only && !this.#runOnly) { | ||
the \`t.only(...)\` function.`, | ||
nodeArgs: (v) => v ? ['--test-only'] : [] | ||
}, | ||
@@ -167,2 +177,3 @@ /** | ||
case-insensitive matching.`, | ||
nodeArgs: (value) => value.map(g => `--test-name-pattern=${g}`), | ||
}, | ||
@@ -193,3 +204,27 @@ /** | ||
}, | ||
/** | ||
* flag | ||
* | ||
* Do not apply a skip message to tests filtered using `--grep` | ||
* and `--only`. | ||
* | ||
* Enabled by default if `--fail-skip` is set. | ||
*/ | ||
'filter-quietly': { | ||
type: 'boolean', | ||
description: ` | ||
Do not apply a skip message to tests filtered using \`--grep\` | ||
and \`--only\`. | ||
Defaults to true if \`--fail-skip\` is set. | ||
`, | ||
}, | ||
'no-filter-quietly': { | ||
type: 'boolean', | ||
description: ` | ||
Always set a skip message on filtered tests, even if \`--fail-skip\` | ||
is enabled. | ||
`, | ||
}, | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -71,2 +71,3 @@ import { PromiseWithSubtest, TapPlugin, TestBase, TestBaseOpts } from '@tapjs/core'; | ||
description: string; | ||
nodeArgs: (v: boolean) => string[]; | ||
}; | ||
@@ -94,2 +95,3 @@ /** | ||
description: string; | ||
nodeArgs: (value: string[]) => string[]; | ||
}; | ||
@@ -120,3 +122,19 @@ /** | ||
}; | ||
/** | ||
* flag | ||
* | ||
* Do not apply a skip message to tests filtered using `--grep` | ||
* and `--only`. | ||
* | ||
* Enabled by default if `--fail-skip` is set. | ||
*/ | ||
'filter-quietly': { | ||
type: string; | ||
description: string; | ||
}; | ||
'no-filter-quietly': { | ||
type: string; | ||
description: string; | ||
}; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
import { env, parseTestArgs, } from '@tapjs/core'; | ||
const reRegExpLiteral = /^\/(.*)\/([a-z]*)$/; | ||
/** | ||
@@ -12,2 +13,3 @@ * Class that provides the {@link @tapjs/filter!Filter#only} method, and | ||
#runOnly; | ||
#filterQuietly; | ||
get runOnly() { | ||
@@ -21,2 +23,5 @@ return this.#runOnly; | ||
this.#t = t; | ||
const eq = env?.TAP_FILTER_QUIETLY; | ||
this.#filterQuietly = | ||
eq === '1' || (!!t.options.failSkip && eq !== '0'); | ||
// don't filter test files when we're the cli test runner | ||
@@ -35,3 +40,3 @@ const { grep, grepInvert, runOnly } = opts.context === Symbol.for('tap.isRunner') | ||
this.#grep = env.TAP_GREP.split('\n').map(g => { | ||
const p = g.match(/^\/(.*)\/([a-z]*)$/); | ||
const p = g.match(reRegExpLiteral); | ||
g = p && p[1] ? p[1] : g; | ||
@@ -71,5 +76,7 @@ const flags = p ? p[2] : ''; | ||
if (!match) { | ||
const p = `filter${this.#grepInvert ? ' out' : ''}: ${pattern}`; | ||
opts.skip = p; | ||
return shouldSkipChild(opts); | ||
if (!this.#filterQuietly) { | ||
opts.skip = `filter${this.#grepInvert ? ' out' : ''}: ${pattern}`; | ||
} | ||
shouldSkipChild(opts); | ||
return true; | ||
} | ||
@@ -86,5 +93,7 @@ else { | ||
if (this.#runOnly && !opts.only) { | ||
const p = 'filter: only'; | ||
opts.skip = p; | ||
return shouldSkipChild(opts); | ||
if (!this.#filterQuietly) { | ||
opts.skip = 'filter: only'; | ||
} | ||
shouldSkipChild(opts); | ||
return true; | ||
} | ||
@@ -130,2 +139,3 @@ if (opts.only && !this.#runOnly) { | ||
the \`t.only(...)\` function.`, | ||
nodeArgs: (v) => v ? ['--test-only'] : [] | ||
}, | ||
@@ -161,2 +171,3 @@ /** | ||
case-insensitive matching.`, | ||
nodeArgs: (value) => value.map(g => `--test-name-pattern=${g}`), | ||
}, | ||
@@ -187,3 +198,27 @@ /** | ||
}, | ||
/** | ||
* flag | ||
* | ||
* Do not apply a skip message to tests filtered using `--grep` | ||
* and `--only`. | ||
* | ||
* Enabled by default if `--fail-skip` is set. | ||
*/ | ||
'filter-quietly': { | ||
type: 'boolean', | ||
description: ` | ||
Do not apply a skip message to tests filtered using \`--grep\` | ||
and \`--only\`. | ||
Defaults to true if \`--fail-skip\` is set. | ||
`, | ||
}, | ||
'no-filter-quietly': { | ||
type: 'boolean', | ||
description: ` | ||
Always set a skip message on filtered tests, even if \`--fail-skip\` | ||
is enabled. | ||
`, | ||
}, | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tapjs/filter", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "tap plugin providing t.only() and grep option", | ||
@@ -40,3 +40,3 @@ "author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me)", | ||
"peerDependencies": { | ||
"@tapjs/core": "1.0.3" | ||
"@tapjs/core": "1.1.0" | ||
}, | ||
@@ -43,0 +43,0 @@ "dependencies": { |
@@ -166,1 +166,20 @@ # `@tapjs/filter` | ||
``` | ||
## `--filter-quietly` | ||
By default, when a test is skipped with `--grep` or `--only`, a | ||
skip message is applied, indicating why it was omitted. | ||
This is often desireable, but can be noisy. The | ||
`--filter-quietly` config flag will disable this reporting, | ||
making filtered tests look like empty passing assertions. | ||
Since a skip message will cause failures when `--fail-skip` is | ||
set, in that case `--filter-quietly` will be enabled by default. | ||
Presumably, if you tell tap "fail on skipped tests", you don't | ||
also mean for it to fail on tests that you have told it to skip | ||
in that very same command with `--grep` or `--only`. | ||
If you _do_ mean to have it fail on intentionally skipped tests, | ||
then you can set `--no-filter-quietly` (or `filter-quietly: | ||
false` in a `.taprc` file) along with `--fail-skip`. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56191
701
185