From f8fffc6a3037066b7e596fc35df69879c030f82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Che=C5=82kowski?= Date: Wed, 1 Apr 2026 20:48:09 +0200 Subject: [PATCH] feat: add --tests option to test command Registers a new --tests Commander option (env var: TESTS) on the test command. Accepts semicolon-separated glob patterns passed through to kopytko-unit-testing-framework for build-time test file filtering. Examples: kopytko test --tests="Home*;Video*;Button" TESTS="Home*" kopytko test --- README.md | 24 ++++++++++++++++++++++++ commands/test.js | 2 ++ options/tests.js | 4 ++++ package-lock.json | 2 +- package.json | 2 +- 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 options/tests.js diff --git a/README.md b/README.md index 795b922..d753202 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,27 @@ kopytko --help | start | s | Compiles and runs an application on a Roku device | | test | t | Compiles and runs unit tests on a Roku device | | new | n | Creates new kopytko application | + +## Test command options + +| Option | Env var | Description | +|--------|---------|-------------| +| `--testFileName=` | `TEST_FILE_NAME` | Run only tests whose file name matches `` | +| `--tests=` | `TESTS` | Semicolon-separated glob patterns of unit names to build and run (e.g. `Home*;Video*;Button`). Filters at build time — only matching test files are compiled and deployed | +| `--forceConnect` | — | Kill any process occupying port 8085 before connecting to read test results | +| `--rokuIP=` | `ROKU_IP` | IP address of the target Roku device | +| `--rokuDevPassword=` | `ROKU_DEV_PASSWORD` | Developer password for the target Roku device | + +```shell +# Run all tests +npm test + +# Run tests for a single unit (shorthand) +npm test -- MyService + +# Run tests matching glob patterns in a single build+deploy +npm test -- --tests="Home*;Video*;Button" + +# Force-take port 8085 if occupied +npm test -- --forceConnect +``` diff --git a/commands/test.js b/commands/test.js index 2ef2f2d..0ca3aa4 100644 --- a/commands/test.js +++ b/commands/test.js @@ -1,5 +1,6 @@ const rokuDevPasswordOption = require('../options/rokuDevPassword'); const testFileNameOption = require('../options/testFileName'); +const testsOption = require('../options/tests'); const forceConnectOption = require('../options/forceConnect'); const forceHttpOption = require('../options/forceHttp'); const rokuIPOption = require('../options/rokuIP'); @@ -13,6 +14,7 @@ function load(program) { .addOption(rokuIPOption) .addOption(rokuDevPasswordOption) .addOption(testFileNameOption) + .addOption(testsOption) .addOption(telnetOption) .addOption(forceHttpOption) .addOption(forceConnectOption) diff --git a/options/tests.js b/options/tests.js new file mode 100644 index 0000000..5e7b3c7 --- /dev/null +++ b/options/tests.js @@ -0,0 +1,4 @@ +const { Option } = require('commander'); + +module.exports = new Option('--tests ', 'Semicolon-separated glob patterns of unit test names to run (e.g. Rail*;Video*;Tile*)') + .env('TESTS'); diff --git a/package-lock.json b/package-lock.json index 39b9461..1938f7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ }, "peerDependencies": { "@dazn/kopytko-packager": "^1.4.2", - "@dazn/kopytko-unit-testing-framework": "^2.5.2" + "@dazn/kopytko-unit-testing-framework": "^2.6.0" } }, "node_modules/@actions/core": { diff --git a/package.json b/package.json index 771cee0..a3d2308 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "peerDependencies": { "@dazn/kopytko-packager": "^1.4.2", - "@dazn/kopytko-unit-testing-framework": "^2.5.2" + "@dazn/kopytko-unit-testing-framework": "^2.6.0" }, "license": "MIT", "repository": {