Skip to content

Tests do not get executed by action. #1307

@SimonFischer04

Description

@SimonFischer04

Moving the recent discussion from telegram here:

By default an example unit test will be created:
https://github.com/ioBroker/create-adapter/blob/master/templates/main.test.raw.js
Which is only run by test:js/test:ts script.

But they will never get executed.
The testing-action only runs npm run test:unit (https://github.com/ioBroker/testing-action-adapter/blob/master/action.yml#L35).
Which are actually the old / deprecated Adapter startup Unit tests. (https://github.com/ioBroker/testing-action-adapter/blob/master/action.yml#L35)

I know there are not a lot of people writing unit tests in their adapters, but if the creator already supplies an example one at least I would assume they would also run in CI. Added myself a test into this existing testfile (and added new test files) and falsely though that actions would take care of ensuring tests.
PS: about not running it by default because it's "wasting time" for people not actually using them. In a quick test the example unit test provided by the creator took 0.2s to execute ...
It's an UNIT test, not an expensive to run integration test. So I don't think requiring extra manual steps to enable them and having users falsely believe they have test coverage is not worth it IMHO.

Options i see:

  1. remove main.test.js, test:js from the template
  2. rename the test:js / test:ts to test:unit.
    Probably simplest change. Existing action handles it. As the old test:unit is deprecated and no longer newly created. I don't see how this could cause issues (as it also only applies to new adapters created)
  3. add a new test:js / test:ts step to the action and make sure it does not break existing setups. (although for me it would be a valid error if the user has tests but they fail. The dependebot bump PR would then fail and if the dev is not using unit tests he could just delete the test file / script.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions