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

"Unexpected typeof" error in a new expo project #16945

Open
chancesmith opened this issue Jan 31, 2025 · 1 comment
Open

"Unexpected typeof" error in a new expo project #16945

chancesmith opened this issue Jan 31, 2025 · 1 comment
Labels
bug Something isn't working bun:test Something related to the `bun test` runner confirmed bug We can reproduce this issue

Comments

@chancesmith
Copy link

chancesmith commented Jan 31, 2025

What version of Bun is running?

1.2.1

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

  1. Setup new expo project
bunx create-expo-app@latest
cd my-app
  1. Simplify (tabs)/index.ts
import { ThemedText } from "@/components/ThemedText";

export default function HomeScreen() {
  return <ThemedText type="title">Welcome!</ThemedText>;
}
  1. Add test (tabs)/index.test.tsx
import React from "react";
import { render } from "@testing-library/react-native";
import HomeScreen from "./index";

describe("HomeScreen", () => {
  it("renders the welcome message", () => {
    const { getByText } = render(<HomeScreen />);
    expect(getByText("Welcome!")).toBeTruthy();
  });
});
  1. Run bun test

What is the expected behavior?

Tests should not have type errors.

What do you see instead?

bun test v1.2.1 (ce532901)

index.test.tsx:

# Unhandled error between tests
-------------------------------
15 | import typeof ActionSheetIOS from './Libraries/ActionSheetIOS/ActionSheetIOS';
            ^
error: Unexpected typeof
    at /Users/user.name/wip/my-app/node_modules/react-native/index.js:15:8
-------------------------------


 0 pass
 1 fail
 1 error
Ran 1 tests across 1 files. [37.00ms]

Additional information

No response

@chancesmith chancesmith added bug Something isn't working types An issue with TypeScript types labels Jan 31, 2025
@RiskyMH RiskyMH added confirmed bug We can reproduce this issue and removed types An issue with TypeScript types labels Feb 1, 2025
@RiskyMH
Copy link
Member

RiskyMH commented Feb 1, 2025

Weird this is indeed published code on react-native: https://unpkg.com/[email protected]/index.js

However as this (import typeof) syntax isn't valid on node, I'd assume this file isn't meant to be directly imported.

So @testing-library/react-native must be doing something for jest that bun test isn't picking up.


Edit, could be something due to this in package.json:

 "jest": {
    "preset": "jest-expo"
 },

@RiskyMH RiskyMH added the bun:test Something related to the `bun test` runner label Feb 1, 2025
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
Projects
None yet
Development

No branches or pull requests

2 participants