From bb9b796efe4f49640c4c3842190ba658464c8898 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 7 May 2021 14:39:21 +0100 Subject: [PATCH] Tweak test runner to support more directories This expands the test filtering in the test runner so that you can supply e.g. `test/tests/feed*` from your shell in the `zotero` directory and correctly filter to all feed-related tests. --- test/content/runtests.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/content/runtests.js b/test/content/runtests.js index 3ba7bfa6f3..714537a6f1 100644 --- a/test/content/runtests.js +++ b/test/content/runtests.js @@ -210,12 +210,13 @@ var assert = chai.assert, // Set up tests to run var run = ZoteroUnit.runTests; -if(run && ZoteroUnit.tests) { +if (run && ZoteroUnit.tests) { function getTestFilename(test) { - // Allow foo, fooTest, fooTest.js, and tests/fooTest.js + // Remove any directory prefixes e.g. tests/fooTest.js, test/tests/fooTest.js + test = test.split(/[/\\]/).pop(); + // Allow foo, fooTest, fooTest.js test = test.replace(/\.js$/, ""); test = test.replace(/Test$/, ""); - test = test.replace(/^tests[/\\]/, ""); return test + "Test.js"; } @@ -284,4 +285,4 @@ if(run) { return mocha.run(); }) }; -} \ No newline at end of file +}