diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..404e21e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: "Tests" + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + name: "Unit Tests" + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + + - name: Run tests with coverage + if: matrix.node-version == '20.x' + run: npm run test:ci + + - name: Upload coverage to Codecov + if: matrix.node-version == '20.x' + uses: codecov/codecov-action@v4 + with: + files: ./coverage/lcov.info + fail_ci_if_error: false + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 429de67..a89f219 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ yarn-error.log* # Build output / coverage coverage/ +.nyc_output/ dist/ build/ diff --git a/CLAUDE.md b/CLAUDE.md index 8329377..913b9f1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -15,6 +15,15 @@ This is a Node-RED extension providing custom nodes for interacting with the Seq ## Development Commands ```bash +# Install dependencies +npm install + +# Run tests +npm test + +# Run tests with coverage +npm run test:coverage + # Linting (uses pre-commit hooks) pre-commit run --all-files @@ -246,6 +255,9 @@ nodes/ - Node implementation files (.js + .html pairs) dataset-*.js - Dataset addition node datalink-*.js - Data Link list/poll nodes studios-*.js - Studio addition/monitor nodes +test/ - Mocha test files + helper.js - Shared test utilities and mock factories + *_spec.js - Test files for each node examples/ - Example flows (.json) docker/ - Dockerfiles and Node-RED config for containers docs/ - Documentation and images @@ -263,3 +275,4 @@ docs/ - Documentation and images 7. Use `node.status()` to update visual state in editor 8. Register node in [package.json](package.json) under `node-red.nodes` 9. Create corresponding HTML with `