create-adapter icon indicating copy to clipboard operation
create-adapter copied to clipboard

add test:js script to test-and-realase workflow

Open Garfonso opened this issue 3 years ago • 4 comments

In package.json the creator defines test:js / test:ts scripcts: https://github.com/ioBroker/create-adapter/blob/master/templates/package.json.ts#L160 https://github.com/ioBroker/create-adapter/blob/master/templates/package.json.ts#L165

those will run **.test.js / **.test.ts files which can be used to define unit tests of single iobroker independent functions (or even iobroker dependent, if some mocking is done).

I think those tests should be added to the default github test-and-relaese workflow.

Garfonso avatar May 15 '21 19:05 Garfonso

we could replace test:package against npm run test which includes test:js / test:ts and test:package

Garfonso avatar May 15 '21 19:05 Garfonso

also unit tests should be removed: https://github.com/ioBroker/testing/pull/364

Garfonso avatar May 15 '21 19:05 Garfonso

To me it also seems wrong that not all unit tests are executed with npm test:

https://github.com/ioBroker/ioBroker.example/blob/19999a670c9b73a2436c2397467c2c7e54557437/JavaScript/package.json#L47-L51

(yes, I would exclude test:integration, but all others should run and the workflow should also simply run nmp test)

UncleSamSwiss avatar May 15 '21 19:05 UncleSamSwiss

I remember now. The intention behind npm test not including the integration tests was for it to be a fast check you can do often. Integration tests take a while with installing js-controller and the adapter etc., so the idea was that you run those on GitHub and locally only on demand. It would probably make sense to include the test:unit script, which basically only runs defineAdditionalTests from test/unit.js.

AlCalzone avatar May 15 '21 20:05 AlCalzone