From e13f3c10cac4fabff7e6cd4a4736703ca7c56d2d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 23 Aug 2018 19:47:43 -0400 Subject: Add ability to unit test by permissions. --- js/testing/testing.ts | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'js/testing/testing.ts') diff --git a/js/testing/testing.ts b/js/testing/testing.ts index 828ebec2f..b172688b7 100644 --- a/js/testing/testing.ts +++ b/js/testing/testing.ts @@ -24,22 +24,14 @@ export interface TestDefinition { export const exitOnFail = true; -/* A subset of the tests can be ran by providing a filter expression. - * In Node.js the filter is specified on the command line: - * - * ts-node test_node log # all tests with 'log' in the name - * ts-node test_node ^util # tests starting with 'util' - * - * In the browser, the filter is specified as part of the url: - * - * http://localhost:9876/test.html#script=some/script.js&filter=log - * http://localhost:9876/test.html#script=some/script.js&filter=^util - */ -let filterExpr: string = null; - -const filterRegExp = filterExpr ? new RegExp(filterExpr, "i") : null; +let filterRegExp: RegExp | null; const tests: TestDefinition[] = []; +// Must be called before any test() that needs to be filtered. +export function setFilter(s: string): void { + filterRegExp = new RegExp(s, "i"); +} + export function test(t: TestDefinition | TestFunction): void { const fn: TestFunction = typeof t === "function" ? t : t.fn; const name: string = t.name; -- cgit v1.2.3