Add component tests to the demo SDK#287
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive component testing infrastructure to the demo SDK. The changes reorganize the project structure from test_sdk to demo_sdk and introduce a new component test suite alongside existing unit tests.
Changes:
- Renamed project directory from
test_sdktodemo_sdkthroughout package.json scripts - Added component test infrastructure with utilities for HTTP client operations and event subscription testing
- Introduced TypeScript compilation step for unit tests and new test organization structure
Reviewed changes
Copilot reviewed 22 out of 36 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | New TypeScript configuration for compiling unit tests |
| jest.config.json | Updated test regex to support .mjs files |
| package.json | Reorganized test scripts and updated all references from test_sdk to demo_sdk |
| test/suite/remove-unused-schemas.test.js | Fixed import path after directory restructure |
| demo_sdk/test/unit/*.test.ts | Updated import paths for relocated test files |
| demo_sdk/test/transpiled-suite/*.test.js | Generated JavaScript files from TypeScript unit tests |
| demo_sdk/test/component/*.mjs | New component tests for properties and events |
| demo_sdk/test/component/utils/* | New utility modules for component testing |
| demo_sdk/sharedSchemas/types.json | New shared type definitions |
| demo_sdk/schemas/types.json | Extended type definitions for the SDK |
| demo_sdk/openrpc/*.json | OpenRPC specification files for simple, provider, property, and event modules |
| demo_sdk/sdk/* | SDK configuration and index files |
| demo_sdk/*.js | Test harness and setup files |
Comments suppressed due to low confidence (1)
demo_sdk/test/unit/simple.test.ts:50
- Avoid automated semicolon insertion (93% of all statements in the enclosing script have an explicit semicolon).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| requestBasicMethod(...args) { | ||
| providerMethodRequestReceived = true; | ||
| throw { | ||
| message: 'An error occured!', |
There was a problem hiding this comment.
There is a spelling error in "occured". This should be "occurred".
| test('Provider method throw an exeption', () => { | ||
| expect(providerMethodRequestReceived).toBe(true); | ||
| expect(providerMethodErrorSent).toBe(true); | ||
| expect(errorMessage).toBe('An error occured!'); |
There was a problem hiding this comment.
There is a spelling error in "occured". This should be "occurred".
| test('Provide method 1 called with two args', () => { | ||
| expect(numberOfArgsMethodOne).toBe(1); | ||
| }); | ||
| test('Provide method 1 parame1 is true', () => { |
There was a problem hiding this comment.
The naming in the test description "Provide method 1 parame1 is true" contains a typo. It should be "Provide method 1 param1 is true".
| test('Provide method 1 parame1 is true', () => { | |
| test('Provide method 1 param1 is true', () => { |
| "test:unit": "NODE_OPTIONS=--experimental-vm-modules npx --config=jest.config.json --detectOpenHandles jest ./test/suite", | ||
| "test:component": "NODE_OPTIONS=--experimental-vm-modules npx jest --runInBand ./demo_sdk/test/component", | ||
| "test": "npm run test:setup && npm run test:unit && NODE_OPTIONS=--experimental-vm-modules npx --config=jest.config.json --detectOpenHandles jest ./demo_sdk/test/transpiled-suite", |
There was a problem hiding this comment.
The test script includes a mix of npx and npm run commands with inconsistent options. The --config=jest.config.json flag should come after jest, not after npx. The correct syntax should be npx jest --config=jest.config.json rather than npx --config=jest.config.json jest.
| // this one is good as long as there's no errors yet | ||
| expect(1).toBe(1); | ||
| }); | ||
| test('Provider method throw an exeption', () => { |
There was a problem hiding this comment.
There is a spelling error in "exeption". This should be "exception".
| test('Provider method throw an exeption', () => { | |
| test('Provider method throw an exception', () => { |
| "test:setup": "rm -rf demo_sdk/test/transpiled-suite && npx tsc --target es6 --moduleResolution node --outDir demo_sdk/test/transpiled-suite", | ||
| "test:unit": "NODE_OPTIONS=--experimental-vm-modules npx --config=jest.config.json --detectOpenHandles jest ./test/suite", | ||
| "test:component": "NODE_OPTIONS=--experimental-vm-modules npx jest --runInBand ./demo_sdk/test/component", | ||
| "test": "npm run test:setup && npm run test:unit && NODE_OPTIONS=--experimental-vm-modules npx --config=jest.config.json --detectOpenHandles jest ./demo_sdk/test/transpiled-suite", |
There was a problem hiding this comment.
Line 16 contains inconsistent whitespace - it uses tabs instead of spaces like the rest of the file. This should use spaces for consistency with the rest of the package.json file.
| import "./utils/bootstrap.mjs"; | ||
|
|
||
|
|
||
| import { PropertyExtension, Simple, EventExtension } from "../../../build/sdk/javascript/src/sdk.mjs"; |
There was a problem hiding this comment.
Unused import Simple.
| import { PropertyExtension, Simple, EventExtension } from "../../../build/sdk/javascript/src/sdk.mjs"; | |
| import { PropertyExtension, EventExtension } from "../../../build/sdk/javascript/src/sdk.mjs"; |
| @@ -0,0 +1,111 @@ | |||
| import "./utils/bootstrap.mjs"; | |||
|
|
|||
| import { test, expect, describe } from "@jest/globals"; | |||
There was a problem hiding this comment.
Unused import describe.
| import { test, expect, describe } from "@jest/globals"; | |
| import { test, expect } from "@jest/globals"; |
| beforeAll(() => { | ||
| transport.onSend((json) => { | ||
| if (json.method) { | ||
| let [module, method] = json.method.split('.'); |
There was a problem hiding this comment.
Unused variable method.
| let [module, method] = json.method.split('.'); | |
| let [module] = json.method.split('.'); |
| } | ||
| transport.onSend((json) => { | ||
| if (json.method) { | ||
| let [module, method] = json.method.split('.'); |
There was a problem hiding this comment.
Unused variable method.
| let [module, method] = json.method.split('.'); | |
| const [module] = json.method.split('.'); |
No description provided.