-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Jest: Module import syntax error #2103
Comments
Yeah, this seems like more of a Jest/ESM config issue at first glance. Jest normally transforms ESM module files into CJS, as far as I know. Seems like it isn't transforming this file. Out of curiosity, what happens if you use the CodeSandbox CI build from #2102 ? Merged that additional tweak last night but haven't released it yet. |
Hi @markerikson ! After pulling from master and running Congrats on the release btw, really awesome work 🎉 |
Thanks! I'm out for the evening, but will publish that as 9.0.2 once I'm back |
Much appreciated! |
Unfortunately, I'm seeing a similar issue to this on version 9.0.2.
Although I can see the change to the filename you referenced, the outcome for my environment seems the same. @pwltr Did your Jest tests run fine once you upgraded? |
I did face the same issue while launching my jest tests with version 9.0.4. I manage to fix it by adding
hope it will help some folks :) |
Hi, @Optarion. Thanks for this but when I add
App.test.tsx import App from "App"
import React from "react"
import { act } from "react-test-renderer"
import { renderWithProviders } from "src/helpers/wrapper"
describe("App", () => {
it("should render successfully", async () => {
const view = renderWithProviders(<App />).toJSON()
await act(() => {
expect(view).toMatchSnapshot()
})
})
}) wrapper.tsx import { NavigationContainer } from "@react-navigation/native"
import { render, type RenderOptions } from "@testing-library/react-native"
import React, { type PropsWithChildren } from "react"
import { Provider } from "react-redux"
import { setupStore, type AppStore, type RootState } from "src/store"
interface ExtendedRenderOptions extends Omit<RenderOptions, "queries"> {
preloadedState?: Partial<RootState>
store?: AppStore
}
export function renderWithProviders(
ui: React.ReactElement,
extendedRenderOptions: ExtendedRenderOptions = {}
) {
const {
preloadedState = {},
// Automatically create a store instance if no store was passed in
store = setupStore(preloadedState),
...renderOptions
} = extendedRenderOptions
const Wrapper = ({ children }: PropsWithChildren) => (
<Provider store={store}>{children}</Provider>
)
// Return an object with the store and all of RTL's query functions
return {
store,
...render(ui, { wrapper: Wrapper, ...renderOptions })
}
} What could be the reason of getting |
What version of React, ReactDOM/React Native, Redux, and React Redux are you using?
What is the current behavior?
So this is probably not a Redux issue per se but since this is a popular project and this just came up with the new update I'm hoping somebody else has run into this and may offer some help. I've been dealing with this exact issue in other projects and was not able to resolve it.
When running unit tests with Jest I'm seeing the following error after upgrading to
react-redux
v9.0.0.jest.config.js
:Anybody able to share a working Jest config?
What is the expected behavior?
Expecting Jest unit tests to be able to parse all modules.
Which browser and OS are affected by this issue?
No response
Did this work in previous versions of React Redux?
The text was updated successfully, but these errors were encountered: