Skip to content

Commit

Permalink
fix: remaining tests, split transformer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Nov 1, 2024
1 parent 242d02f commit 758db03
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 887 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,35 @@ jobs:
if: github.event_name != 'pull_request'
run: yarn run test:ts $TURBO_FLAGS

# ===================
# Test if the transformers are working
test-transformers:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18, 20]
os: [ubuntu-latest]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}

# Transformer tests need their dependencies to be compiled
- name: Compile test dependencies
run: |
yarn workspace @zwave-js/shared run build
yarn workspace @zwave-js/core run build
# For pull requests, only run tests for changed files
- name: Test transformers
run: yarn workspace @zwave-js/transformers run test:ts

# # ===================
# # This job checks if a PR changes the public API surface
# api-surface:
Expand Down
6 changes: 3 additions & 3 deletions packages/cc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"ts": "tsx --conditions=@@dev",
"lint:ts": "eslint --cache \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix",
"test:ts": "ava",
"test:ts": "vitest",
"test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run"
},
"dependencies": {
Expand All @@ -79,10 +79,10 @@
"@types/node": "^18.19.55",
"@zwave-js/maintenance": "workspace:*",
"@zwave-js/transformers": "workspace:*",
"ava": "^6.1.3",
"del-cli": "^6.0.0",
"es-main": "^1.3.0",
"tsx": "^4.19.2",
"typescript": "5.6.2"
"typescript": "5.6.2",
"vitest": "^2.1.4"
}
}
4 changes: 2 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"ts": "tsx --conditions=@@dev",
"lint:ts": "eslint --cache --cache-location .eslintcache/ts \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix",
"test:ts": "ava",
"test:ts": "vitest",
"test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run"
},
"dependencies": {
Expand All @@ -78,7 +78,6 @@
"@types/xml2js": "^0.4.14",
"@types/yargs": "^17.0.33",
"@zwave-js/maintenance": "workspace:*",
"ava": "^6.1.3",
"comment-json": "^4.2.5",
"del-cli": "^6.0.0",
"es-main": "^1.3.0",
Expand All @@ -91,6 +90,7 @@
"ts-pegjs": "patch:ts-pegjs@npm%3A4.2.1#~/.yarn/patches/ts-pegjs-npm-4.2.1-0f567a1059.patch",
"tsx": "^4.19.2",
"typescript": "5.6.2",
"vitest": "^2.1.4",
"xml2js": "^0.6.2",
"yargs": "^17.7.2"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"extract-api": "yarn api-extractor run",
"lint:ts": "eslint --cache \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix",
"test:ts": "ava",
"test:ts": "vitest",
"test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run"
},
"dependencies": {
Expand All @@ -79,11 +79,11 @@
"@types/semver": "^7.5.8",
"@types/sinon": "^17.0.3",
"@types/triple-beam": "^1.3.5",
"ava": "^6.1.3",
"del-cli": "^6.0.0",
"esbuild": "0.24.0",
"sinon": "^19.0.2",
"tsx": "^4.19.2",
"typescript": "5.6.2"
"typescript": "5.6.2",
"vitest": "^2.1.4"
}
}
6 changes: 3 additions & 3 deletions packages/nvmedit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"extract-api": "yarn api-extractor run",
"lint:ts": "eslint --cache \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix",
"test:ts": "ava",
"test:ts": "vitest",
"test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run"
},
"devDependencies": {
Expand All @@ -68,10 +68,10 @@
"@types/node": "^18.19.55",
"@types/semver": "^7.5.8",
"@types/yargs": "^17.0.33",
"ava": "^6.1.3",
"del-cli": "^6.0.0",
"esbuild": "0.24.0",
"tsx": "^4.19.2",
"typescript": "5.6.2"
"typescript": "5.6.2",
"vitest": "^2.1.4"
}
}
6 changes: 3 additions & 3 deletions packages/serial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"extract-api": "yarn api-extractor run",
"lint:ts": "eslint --cache \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix",
"test:ts": "ava",
"test:ts": "vitest",
"test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run"
},
"dependencies": {
Expand All @@ -80,11 +80,11 @@
"@types/node": "^18.19.55",
"@types/sinon": "^17.0.3",
"ansi-colors": "^4.1.3",
"ava": "^6.1.3",
"del-cli": "^6.0.0",
"esbuild": "0.24.0",
"sinon": "^19.0.2",
"tsx": "^4.19.2",
"typescript": "5.6.2"
"typescript": "5.6.2",
"vitest": "^2.1.4"
}
}
6 changes: 3 additions & 3 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
"extract-api": "yarn api-extractor run",
"lint:ts": "eslint --cache \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix",
"test:ts": "ava",
"test:ts": "vitest",
"test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run"
},
"devDependencies": {
"@alcalzone/esm2cjs": "^1.1.2",
"@microsoft/api-extractor": "^7.47.9",
"@types/node": "^18.19.55",
"@types/sinon": "^17.0.3",
"ava": "^6.1.3",
"del-cli": "^6.0.0",
"esbuild": "0.24.0",
"sinon": "^19.0.2",
"tsx": "^4.19.2",
"typescript": "5.6.2"
"typescript": "5.6.2",
"vitest": "^2.1.4"
}
}
6 changes: 3 additions & 3 deletions packages/transformers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
"pretest": "del-cli \"test/fixtures/*.js\" && tsc -p tsconfig.test.json && cpy \"test/build/test/fixtures/*.js\" test/fixtures && del-cli test/build",
"lint:ts": "eslint --cache \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix",
"test:ts": "ava",
"test:ts": "vitest",
"test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run"
},
"devDependencies": {
"ava": "^6.1.3",
"cpy-cli": "^5.0.0",
"del-cli": "^6.0.0",
"execa": "^5.1.1",
"tsutils": "^3.21.0",
"typescript": "5.6.2"
"typescript": "5.6.2",
"vitest": "^2.1.4"
}
}
9 changes: 9 additions & 0 deletions packages/transformers/vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
include: [
"./src/**/*.test.ts",
],
},
});
6 changes: 3 additions & 3 deletions packages/zwave-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"extract-api": "yarn api-extractor run",
"lint:ts": "eslint --cache \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix",
"test:ts": "ava",
"test:ts": "vitest",
"test:dirty": "tsx ../maintenance/src/resolveDirtyTests.ts --run"
},
"dependencies": {
Expand Down Expand Up @@ -133,13 +133,13 @@
"@xstate/test": "^0.5.1",
"@zwave-js/maintenance": "workspace:*",
"@zwave-js/transformers": "workspace:*",
"ava": "^6.1.3",
"del-cli": "^6.0.0",
"esbuild": "0.24.0",
"mockdate": "^3.0.5",
"proxyquire": "^2.1.3",
"sinon": "^19.0.2",
"tsx": "^4.19.2",
"typescript": "5.6.2"
"typescript": "5.6.2",
"vitest": "^2.1.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@ import { ZWaveErrorCodes, assertZWaveError } from "@zwave-js/core";
// import { Message, MessageType, messageTypes } from "@zwave-js/serial";
import { MockSerialPort } from "@zwave-js/serial/mock";
import { Bytes, mergeDeep } from "@zwave-js/shared";
import proxyquire from "proxyquire";
import sinon from "sinon";
import { test } from "vitest";
import { PORT_ADDRESS, createAndStartDriver } from "../test/utils.js";
import { type PartialZWaveOptions, driverPresets } from "./ZWaveOptions.js";

// @messageTypes(MessageType.Request, 0xff)
// class TestMessage extends Message {}

// load the driver with stubbed out Serialport
const { Driver } = proxyquire<typeof import("./Driver")>("./Driver", {
"@zwave-js/serial": {
ZWaveSerialPort: MockSerialPort,
},
});
// FIXME: Check if we need these tests. If so, migrate to createAndStartDriverWithMockPort()

test.sequential("starting the driver should open a new serialport", async (t) => {

const driver = new Driver(PORT_ADDRESS, {
testingHooks: {
skipBootloaderCheck: true,
Expand Down
Loading

0 comments on commit 758db03

Please sign in to comment.