Riki
Riki2w ago

React-Native / Jest / Convex-test setup issue

Setting up convex-test (0.0.35) in a near fresh RN Expo sdk 52 app Basic test file
import { describe, expect, test } from '@jest/globals'
import { convexTest } from 'convex-test'
import schema from './schema'

describe('foo', () => {
test('foo', async () => {
const t = convexTest(schema)
expect(true).toBe(true)
})
})
import { describe, expect, test } from '@jest/globals'
import { convexTest } from 'convex-test'
import schema from './schema'

describe('foo', () => {
test('foo', async () => {
const t = convexTest(schema)
expect(true).toBe(true)
})
})
I receive an error when running the expo default npm run test command: SyntaxError: Cannot use import statement outside a module
No description
7 Replies
ballingt
ballingt2w ago
@Riki Know if this is a regression?
Riki
RikiOP2w ago
I don’t know, but good idea to jnow. I will do a manual bisect with different versions and let you know
ballingt
ballingt2w ago
@Riki good enough to know if it's every worked, but a bisect would be a dream
Riki
RikiOP2w ago
Hey @Tom it's strange but after investigation whenever I reinstall whatever version of convex-test, I get this error still
Riki
RikiOP2w ago
I tried a bunch of things like having convex-text added within the jest config field in my package.json as per recommended by the expo team: https://docs.expo.dev/develop/unit-testing/#additional-configuration-for-using-transformignorepatterns
"jest": {
"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|convex-test)"
]
},
"jest": {
"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|convex-test)"
]
},
But I still get a similar error.
Expo Documentation
Unit testing with Jest
Learn how to set up and configure the jest-expo library to write unit and snapshot tests for a project with Jest.
ballingt
ballingt2w ago
@Pierre it looks like convex-test doesn't work with Jest, just with vitest

Did you find this page helpful?