You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Request for improving Developer Experience
Adding an example Unit Test for IncrementCounter on streamdeck create
The example project is working, yet I have troubles getting a test workflow up and running. I tried unsuccessfully adding mocha / chai yet, yet I don't mind if you want to default to jest or something completely different. Having a specific and even locked-in test setup out of the box is better than having none.
Hence it be great if the cli on streamdeck create would also generates an example unit test of IncrementCounter with basic assertion on onWillAppear and onKeyDown, and that there is also a a test command in the package.json
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w --watch.onEnd=\"streamdeck restart com.kopernikus.odoo-time-tracker\""
"test": ... // this should be added
},
While I have background in nodejs and TypeScript development, I have never used rollup before and I find its configuration weird and I don't know what configuration to adapt and how to have my tests be executed. Should my tests files be transpiled into the same folder as my src files? How to run them?
Due to that: Any development setup that is already provided for me by the streamdeck sdk cli to adapt and continue would ease the friction and I can focus on actually implementing my plugin that setting up my project. I really appreciate it.
The text was updated successfully, but these errors were encountered:
Great suggestion! We will look into adding this to the output of the CLI tool. In the mean time, you can set up tests in your plugin project with the following steps.
Update your tsconfig.json file to include a test folder.
"include": [
"src/**/*.ts",
"tests/**/*.ts"
],
Install jest
npm install --save-dev jest @types/jest ts-jest
Create a jest.config.cjs file in your projects root directory.
Create a test in a tests folder in your projects root directory. i.e. tests/utils.test.ts
import{clamp}from"../src/utils";describe("utils.ts",()=>{describe("clamp",()=>{test("should return min when value is less than min",()=>{expect(clamp(2,5,10)).toBe(5);});test("should return max when value is greater than max",()=>{expect(clamp(12,5,10)).toBe(10);});test("should return value when value is between min and max",()=>{expect(clamp(7,5,10)).toBe(7);});});});
Update the your package.json.
"scripts": {
"test": "jest"
},
Run npm run test.
Some of the test configuration is subjective, if you'd prefer your tests in the src folder or to call your test files .spec.ts, you can make config adjustments accordingly.
Feature Request for improving Developer Experience
Adding an example Unit Test for IncrementCounter on
streamdeck create
The example project is working, yet I have troubles getting a test workflow up and running. I tried unsuccessfully adding mocha / chai yet, yet I don't mind if you want to default to jest or something completely different. Having a specific and even locked-in test setup out of the box is better than having none.
Hence it be great if the cli on
streamdeck create
would also generates an example unit test ofIncrementCounter
with basic assertion ononWillAppear
andonKeyDown
, and that there is also a a test command in thepackage.json
While I have background in nodejs and TypeScript development, I have never used rollup before and I find its configuration weird and I don't know what configuration to adapt and how to have my tests be executed. Should my tests files be transpiled into the same folder as my
src
files? How to run them?Due to that: Any development setup that is already provided for me by the streamdeck sdk cli to adapt and continue would ease the friction and I can focus on actually implementing my plugin that setting up my project. I really appreciate it.
The text was updated successfully, but these errors were encountered: