feat(Core): create initial core package#2
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR establishes the initial core package by introducing a test framework implementation with classes and interfaces for managing test execution, results, and status tracking.
Key Changes:
- Introduces a
Testclass for executing and tracking individual test cases - Defines
TaskStatusenum and related interfaces (TestTask,TestResult) for test lifecycle management - Exports core testing types and classes for use across the package
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 21 changed files in this pull request and generated 8 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| "compilerOptions": { | ||
| "outDir": "./dist" | ||
| "outDir": "./dist", |
There was a problem hiding this comment.
[nitpick] Trailing comma after the last property in the compilerOptions object is inconsistent with JSON best practices and may cause issues with strict JSON parsers.
| "outDir": "./dist", | |
| "outDir": "./dist" |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 5 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| description: `${this.getFullDescription()} > ${test.description}`, | ||
| status: test.status, | ||
| error: test.error, | ||
| durationMs: test.durationMs ?? 0, |
There was a problem hiding this comment.
The test.durationMs field is initialized to 0 in the Test class constructor, so it will never be undefined. The nullish coalescing operator (?? 0) is unnecessary and suggests a mismatch between the implementation and usage.
| durationMs: test.durationMs ?? 0, | |
| durationMs: test.durationMs, |
packages/core/src/utils/deepEqual.ts
Outdated
| // Order of keys matter | ||
| for (let i = 0; i < xKeys.length; i++) { | ||
| if (xKeys[i] !== yKeys[i]) return false; | ||
| } | ||
|
|
There was a problem hiding this comment.
The comment states 'Order of keys matter', but Object.keys() does not guarantee a stable ordering across all JavaScript engines for all object types. This assumption may lead to false negatives when comparing objects with identical properties in different enumeration orders. Consider documenting this limitation or revising the logic to compare keys as sets.
| // Order of keys matter | |
| for (let i = 0; i < xKeys.length; i++) { | |
| if (xKeys[i] !== yKeys[i]) return false; | |
| } | |
| // Compare keys as sets (order does not matter) | |
| for (const key of xKeys) { | |
| if (!yKeys.includes(key)) return false; | |
| } | |
| for (const key of yKeys) { | |
| if (!xKeys.includes(key)) return false; | |
| } |
| }, | ||
|
|
||
| toEqual<T>(this: MatcherContext, received: T, expected: T) { | ||
| const pass = JSON.stringify(received) === JSON.stringify(expected); |
There was a problem hiding this comment.
JSON.stringify does not handle undefined values, functions, symbols, Maps, Sets, or circular references correctly. This will produce incorrect equality results for these types. Consider using deepEqual here or documenting that toEqual only supports JSON-serializable values.
| const pass = JSON.stringify(received) === JSON.stringify(expected); | |
| const pass = deepEqual(received, expected); |
| describe("Failing Test Suite", () => { | ||
| it("should fail this test", () => { | ||
| expect(1 + 1).toBe(3); | ||
| }); |
There was a problem hiding this comment.
This test suite intentionally includes a failing test, which will cause the test run to fail. If this is intended for testing framework behavior, consider isolating it or adding documentation explaining its purpose. Otherwise, fix the assertion to expect(1 + 1).toBe(2).
| }, | ||
| "exclude": [ | ||
| "ts-node": { | ||
| // Tell ts-node CLI to install the --loader automatically, explained below |
There was a problem hiding this comment.
The comment references 'explained below' but no further explanation is provided. Either add the promised explanation or remove this comment to avoid confusion.
| // Tell ts-node CLI to install the --loader automatically, explained below |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const describe = (description: string, fn: PromisableFn<void>) => { | ||
| return _describe(description, fn); | ||
| }; | ||
|
|
||
| const it = (description: string, fn: PromisableFn<void>) => { | ||
| return _it(description, fn); | ||
| }; | ||
|
|
||
| export { describe, it }; |
There was a problem hiding this comment.
[nitpick] These wrapper functions are unnecessary - they simply forward to the internal functions without adding any value. Consider exporting _describe and _it directly as describe and it.
| const describe = (description: string, fn: PromisableFn<void>) => { | |
| return _describe(description, fn); | |
| }; | |
| const it = (description: string, fn: PromisableFn<void>) => { | |
| return _it(description, fn); | |
| }; | |
| export { describe, it }; | |
| export { _describe as describe, _it as it }; |
$chore(core): remove comments, update pkg version.
faf4a38 to
3fcca6d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| "name": "@onyxjs/core", | ||
| "version": "1.0.0", | ||
| "name": "@onyx.js/core", |
There was a problem hiding this comment.
Package name inconsistency: the package is named '@onyx.js/core' but the import in onyx.config.ts uses '@onyxjs/core'. Consider using a consistent naming convention, either '@onyx.js/core' or '@onyxjs/core' throughout.
| @@ -0,0 +1,9 @@ | |||
| import { defineConfig } from "@onyxjs/core"; | |||
There was a problem hiding this comment.
Import path '@onyxjs/core' doesn't match the package name '@onyx.js/core' defined in package.json. Update to use '@onyx.js/core' for consistency.
| import { defineConfig } from "@onyxjs/core"; | |
| import { defineConfig } from "@onyx.js/core"; |
|
|
||
| import type { PromisableFn } from "./types"; | ||
|
|
||
| function _describe(description: string, fn: PromisableFn<void>) { |
There was a problem hiding this comment.
The fn parameter is typed as PromisableFn (which can return a Promise), but it's called synchronously on line 14 without await. This could cause issues if fn returns a Promise. Either change the type to exclude Promise or handle async execution properly.
No description provided.