Skip to content

tools/scripts/tools.mjs does not actually run tests when --test --unit is specified #773

@susumutomita

Description

@susumutomita

Is there an existing issue for this?

  • I have searched the existing issues

SDK version

  • Using Lit JS SDK (master branch, commit xyz, etc.)

Lit Network

  • N/A (this is a tooling/script issue, not network-specific)

Description of the bug/issue

We have a script in tools/scripts/tools.mjs that handles various commands, including --test --unit. However, currently the testFunc() implementation only shows a usage message and exits, and does not actually call yarn test:unit. As a result, yarn tools --test --unit completes without running any tests.

Expected Behavior

  • When we do yarn tools --test --unit, the script should invoke yarn test:unit (or nx run-many --target=test) to run all unit tests.
  • The same should happen in CI, so that our tests really run as intended.

Severity of the bug

  • Our CI workflow uses run: yarn tools --test --unit (e.g., in .github/workflows/ci.yml) expecting to run the full unit test suite.
  • In reality, no tests are run, which can lead to undetected failing tests and false-positive CI passes.

Steps To Reproduce

  1. Run yarn tools --test --unit locally
  2. Notice that it prints usage info, then exits without invoking yarn test:unit
  3. Check your console or logs — no tests are actually executed.

Link to code

https://github.com/LIT-Protocol/js-sdk/blob/master/tools/scripts/tools.mjs#L230

Proposed Fix or Approaches

Inside tools/scripts/tools.mjs, in the testFunc() function, we can add logic like:

async function testFunc() {
  const TEST_TYPE = args[1];

  if (!TEST_TYPE || TEST_TYPE === '' || TEST_TYPE === '--help') {
    // show usage
    ...
    exit();
  }

  if (TEST_TYPE === '--unit') {
    // Actually run the tests
    await childRunCommand('yarn test:unit');
    exit();
  }

  // optionally handle other test types if needed
  redLog(\`Unrecognized test type: \${TEST_TYPE}\`);
  exit();
}

This way, yarn tools --test --unit truly calls yarn test:unit. After implementing this, our CI job run: yarn tools --test --unit will genuinely run the unit tests.

Anything else?

  • We might want to add more test categories (e.g. --test --integration) in the same manner.
  • If the CI intentionally wants a different test command, we should clarify that in the script logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions