Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.43 broke my tests 😭 #16312

Closed
subtleGradient opened this issue Jan 10, 2025 · 1 comment · Fixed by #16322
Closed

1.1.43 broke my tests 😭 #16312

subtleGradient opened this issue Jan 10, 2025 · 1 comment · Fixed by #16322
Labels
bug Something isn't working bun:test Something related to the `bun test` runner confirmed bug We can reproduce this issue regression

Comments

@subtleGradient
Copy link

What version of Bun is running?

1.1.43

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

(base) tom@tom-frens frontend % bun --version
1.1.43
(base) tom@tom-frens frontend % curl -fsSL https://bun.sh/install | bash -s "bun-v1.1.42"
######################################################################## 100.0%
bun was installed successfully to ~/.bun/bin/bun 
Run 'bun --help' to get started
(base) tom@tom-frens frontend % bun test
bun test v1.1.42 (50eec002)

 157 pass
 8 todo
 0 fail
 241 expect() calls
Ran 165 tests across 14 files. [871.00ms]

(base) tom@tom-frens frontend % curl -fsSL https://bun.sh/install | bash -s "bun-v1.1.43"
######################################################################## 100.0%
bun was installed successfully to ~/.bun/bin/bun 
Run 'bun --help' to get started
(base) tom@tom-frens frontend % bun test                                                 
bun test v1.1.43 (76800b04)

 147 pass
 8 todo
 10 fail
 212 expect() calls
Ran 165 tests across 14 files. [826.00ms]

What is the expected behavior?

tests that pass on 42 should still pass on 43

What do you see instead?

tests that pass on 42 fail on 43

Additional information

✓ frontend/src/micro-apps/usePromiseState.spec.tsx.md > PromiseStateWithResolvers > createPromiseStateWithResolvers > is a function [0.02ms]
145 | render(
146 | <React.Suspense fallback={<div>Loading...</div>}>
147 | <ViewSyncExternalStore2 store1={store} store2={store2} />
148 | </React.Suspense>,
149 | )
150 | expect(screen.getByText("Loading...")).toBeInTheDocument()
                                             ^
TypeError: expect(screen.getByText("Loading...")).toBeInTheDocument is not a function. (In 'expect(screen.getByText("Loading...")).toBeInTheDocument()', 'expect(screen.getByText("Loading...")).toBeInTheDocument' is undefined)
      at <anonymous> (/Users/tom/Developer/frens/rsc-subs/frontend/src/micro-apps/usePromiseState.spec.tsx.md.DEBUG.tsx:150:40)
      at <anonymous> (/Users/tom/Developer/frens/rsc-subs/frontend/src/micro-apps/usePromiseState.spec.tsx.md.DEBUG.tsx:143:42)
✗ frontend/src/micro-apps/usePromiseState.spec.tsx.md > LivePromiseState > multiple resolves > with multiple live states > when reset > does not suspend again [1.81ms]
119 | render(
120 | <React.Suspense fallback={<div>Loading...</div>}>
121 | <ViewSyncExternalStore2 store1={store} store2={store2} />
122 | </React.Suspense>,
123 | )
124 | expect(await screen.findByText("Loading...")).toBeInTheDocument()
                                                    ^
preload = ["./plugins/preload-before-anything.bun.ts"]

[test]
preload = [
    "./plugins/happydom.ts",
    "./plugins/testing-library.ts",
    "./plugins/preload-before-tests.tsx",
]
import { afterEach, expect } from "bun:test"
import { cleanup } from "@testing-library/react"
import * as matchers from "@testing-library/jest-dom/matchers"

expect.extend(matchers as any)

// Optional: cleans up `render` after each test
afterEach(() => {
  cleanup()
})

// console.debug("Testing Library registered")
@subtleGradient subtleGradient added bug Something isn't working needs triage labels Jan 10, 2025
@subtleGradient subtleGradient changed the title 43 broke my tests 1.1.43 broke my tests 😭 Jan 10, 2025
@pfgithub pfgithub added bun:test Something related to the `bun test` runner regression confirmed bug We can reproduce this issue and removed needs triage labels Jan 10, 2025
@pfgithub
Copy link
Contributor

pfgithub commented Jan 10, 2025

A workaround until this is fixed is to call expect.extend({ ...matchers })

Reproduction:

bun init -y
bun add @testing-library/react
bun add @testing-library/jest-dom
import { test, afterEach, expect } from "bun:test"
import { cleanup } from "@testing-library/react"
import * as matchers from "@testing-library/jest-dom/matchers"

expect.extend(matchers as any)
afterEach(() => {
  cleanup()
})

test("expect extended", () => {
    expect(expect.toBeInTheDocument).not.toBe(undefined);
})

Regression was introduced in 2b2ca32

pfgithub added a commit that referenced this issue Jan 11, 2025
@pfgithub pfgithub mentioned this issue Jan 11, 2025
cirospaciari pushed a commit that referenced this issue Jan 13, 2025
Co-authored-by: Jarred Sumner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun:test Something related to the `bun test` runner confirmed bug We can reproduce this issue regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants