Skip to content

Adds a unit test framework.#186

Merged
nolag merged 4 commits intomainfrom
rtinianov_testFramework
Feb 17, 2026
Merged

Adds a unit test framework.#186
nolag merged 4 commits intomainfrom
rtinianov_testFramework

Conversation

@nolag
Copy link
Contributor

@nolag nolag commented Feb 12, 2026

Draft PR showing how the templates will be updated to use this. Note, I used a local override for the SDK. If you want to try it locally, you'll need to update package.json to expose the file reference and update the file location.

Next PRs

  1. Merge and cut release
  2. Update cli to use it and check in the draft PR w/o overrides to my local files (small update once release is cut)
  3. Add helpers for EVM that Go has to the SDK (TODO)
  4. Add bindings to the CLI, have the bindings also generate test helpers like Go and update the templates again (TODO)

@github-actions
Copy link

👋 nolag, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

…ing or encoding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@nolag nolag enabled auto-merge February 12, 2026 18:11
@nolag nolag requested a review from a team as a code owner February 17, 2026 15:38
@nolag nolag force-pushed the rtinianov_testFramework branch from 1c3c28e to b8d6ae7 Compare February 17, 2026 16:49
Copy link
Contributor

@ernest-nowacki ernest-nowacki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Docs are well structured and examples easy to follow. I would probably change the relative paths so the generated code start from @cre .

Generally it's mostly nitpicking. I'll write some unit tests myself this week (I'm thinking coverage for workflows I have under packages/cre-sdk-examples) and can always follow up with potential improvements if I have fresh ideas 👌

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs for this are great 👏

"test": "bun test",
"test:standard": "./scripts/run-standard-tests.sh",
"typecheck": "tsc"
"typecheck": "tsc -p tsconfig.json --noEmit"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this needed? tsconfig.json should be picked by default if not specified otherwise and --noEmit shouldn't be needed either as it's part of the tsconfig.json itself.

Comment on lines +17 to +18
// Use JSON.stringify to correctly escape backslashes, quotes, and control characters,
// then strip the surrounding quotes it adds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Props for comment 👍

Comment on lines +49 to +50
const dirDepth = dirname(file.name).split('/').length + 2
const registerImportPath = '../'.repeat(dirDepth) + 'testutils/test-runtime'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What potentially could work is just const registerImportPath = '@cre/sdk/testutils/test-runtime' (non issue, just readability and non-blocking).

Comment on lines +130 to +132
const capIdParts = capOption.capabilityId.split('@')
const capabilityName = capIdParts[0]
const capabilityVersion = capIdParts[1] || ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another tiny thing is that we could have reusable way of extracting capability names and versions shared in generator/utils so both regular generator and mock generator can have it the same way.

export function parseCapabilityId(capabilityId: string): { name: string; version: string } {
      const [name, version = ''] = capabilityId.split('@')
      return { name, version }
}

__getTestMockInstance,
__setTestMockInstance,
registerTestCapability,
} from '../../../../../../testutils/test-runtime'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is connected to the way we resolve paths in generator - as you can see above other generated code just uses @cre/generated/... instead of relative paths, which I find easier to follow.

@nolag nolag merged commit 82d731c into main Feb 17, 2026
10 checks passed
@nolag nolag deleted the rtinianov_testFramework branch February 17, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants