Skip to content

Commit

Permalink
filter tests without test prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Nov 30, 2022
1 parent 1eef949 commit 276f3af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,11 @@ export const fails = f => {
* @param {Object<string, Object<string, function(TestCase):void|Promise<any>>>} tests
*/
export const runTests = async tests => {
const numberOfTests = object.map(tests, mod => object.map(mod, f => /* istanbul ignore next */ f ? 1 : 0).reduce(math.add, 0)).reduce(math.add, 0)
/**
* @param {string} testname
*/
const filterTest = testname => testname.startsWith('test') || testname.startsWith('benchmark')
const numberOfTests = object.map(tests, mod => object.map(mod, (f, fname) => /* istanbul ignore next */ f && filterTest(fname) ? 1 : 0).reduce(math.add, 0)).reduce(math.add, 0)
let successfulTests = 0
let testnumber = 0
const start = performance.now()
Expand All @@ -548,7 +552,7 @@ export const runTests = async tests => {
for (const fname in mod) {
const f = mod[fname]
/* istanbul ignore else */
if (f) {
if (f && filterTest(fname)) {
const repeatEachTest = 1
let success = true
for (let i = 0; success && i < repeatEachTest; i++) {
Expand Down
5 changes: 5 additions & 0 deletions testing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import * as buffer from './buffer.js'
import * as map from './map.js'
import * as promise from './promise.js'

/* istanbul ignore next */
export const nottestingNotTested = () => {
t.assert(false, 'This test should not be executed because the name doesnt start with "test"')
}

/**
* @param {t.TestCase} tc
*/
Expand Down

0 comments on commit 276f3af

Please sign in to comment.