Skip to content

Commit b335e23

Browse files
authored
Merge pull request #2 from dev-five-git/add-static-func
Add static functions
2 parents 0a22e95 + 227ccb5 commit b335e23

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"changes": { "package.json": "Patch" },
3+
"note": "Add static function",
4+
"date": "2026-01-02T04:42:38.859062400Z"
5+
}

src/__tests__/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ describe('expect with primitive value', () => {
2222
test('should pass through primitive values', () => {
2323
expect('hello').toBe('hello')
2424
expect(123).toBe(123)
25+
expect(123).toEqual(expect.any(Number))
2526
})
2627
})

src/index.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ if (!GlobalRegistrator.isRegistered) {
1414

1515
const originalExpect = expect
1616
test.mock.module('bun:test', () => {
17+
const expect = (value: unknown) => {
18+
if (isReactElement(value)) {
19+
const { container } = render(value as ReactElement)
20+
return originalExpect(formatHTMLElement(container))
21+
}
22+
if (value instanceof HTMLElement) {
23+
return originalExpect(formatHTMLElement(value))
24+
}
25+
return originalExpect(value)
26+
}
27+
Object.assign(expect, originalExpect)
1728
return {
1829
...test,
19-
expect: (value: unknown) => {
20-
if (isReactElement(value)) {
21-
const { container } = render(value as ReactElement)
22-
return originalExpect(formatHTMLElement(container))
23-
}
24-
if (value instanceof HTMLElement) {
25-
return originalExpect(formatHTMLElement(value))
26-
}
27-
return originalExpect(value)
28-
},
30+
expect,
2931
}
3032
})
3133

0 commit comments

Comments
 (0)