Comments (9)
@GiaHuy216 - I just got my tests to work again, had to remove: testEnvironment: "jsdom",
as suggested by @frankcalise and then replaced the transform, here is what I have now as my jest.config.js (including commented out code):
const { defaults: tsjPreset } = require("ts-jest/presets")
/** @type {import('@jest/types').Config.ProjectConfig} */
module.exports = {
...tsjPreset,
preset: "jest-expo",
transformIgnorePatterns: [
"<rootDir>/node_modules/(react-clone-referenced-element|@react-native-community|react-navigation|@react-navigation/.*|@unimodules/.*|native-base|react-native-code-push)",
"jest-runner",
],
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/.maestro/", "@react-native", "<rootDir>/test/i18n.test.ts"],
// testEnvironment: "jsdom",
setupFiles: ["<rootDir>/test/setup.ts"],
"setupFilesAfterEnv": [
"@testing-library/jest-native/extend-expect"
],
coverageDirectory: "<rootDir>/test/coverage",
collectCoverageFrom: [
"**/*.{js,jsx,ts,tsx}",
"!**/node_modules/**",
"!**/vendor/**",
"!**/test/**",
"!**/coverage/**",
"!**/.expo/**",
"!**/android/**",
"!**/ios/**",
],
// moduleNameMapper: {
// "app/(.*)": "<rootDir>/app/$1",
// },
transform:{
// '^.+\\.test.tsx?$': ['ts-jest', {
// tsconfig: '<rootDir>/test/test-tsconfig.json'
// }],
"^.+\\.[jt]sx?$": "babel-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
"globals": {
"ts-jest": {
"diagnostics": false
}
}
}
Let me know if this works, or causes other issues I haven't come across yet
from ignite.
Hi @GiaHuy216
I couldn't reproduce that error exactly, but had run into the test just never completing until I removed testEnvironment: "jsdom"
from the jest config. Then the test provided worked as is.
Could you paste your Profile
component here as well?
from ignite.
This also might happen if you file is named .js
or .ts
instead of .jsx
/.tsx
. The "X" in the file name indicated that the compiler should expect XML in the javascript
from ignite.
@frankcalise
Here is Profile component
import * as React from "react"
import { StyleProp, TextStyle, View, ViewStyle } from "react-native"
import { observer } from "mobx-react-lite"
import { colors, typography } from "app/theme"
import { Text } from "app/components/Text"
export interface ProfileProps {
/**
* An optional style override useful for padding & margin.
*/
style?: StyleProp<ViewStyle>
}
/**
* Describe your component here
*/
export const Profile = observer(function Profile(props: ProfileProps) {
const { style } = props
const $styles = [$container, style]
return (
<View style={$styles}>
<Text style={$text}>Hello</Text>
</View>
)
})
const $container: ViewStyle = {
justifyContent: "center",
}
const $text: TextStyle = {
fontFamily: typography.primary.normal,
fontSize: 14,
color: colors.palette.primary500,
}
I also removed testEnvironment: "jsdom"
like you said but it doesn't work .Did i miss something?
from ignite.
@markrickert My component file and test file are both tsx files.
from ignite.
@3210jr thanks for confirming it's working. it also aligns with what I found here on RNTL's issue board: callstack/react-native-testing-library#896 (comment)
Will make that update to the boilerplate
from ignite.
I can't reproduce this in the latest Ignite, @GiaHuy216 are you still experiencing issues?
from ignite.
@3210jr After I copied your jest.config.js file and it worked perfectly,thank you.
from ignite.
Related Issues (20)
- node_modules/expo/AppEntry.js HOT 7
- Type enhancement for color palette HOT 2
- Changing app icon HOT 3
- Please add redux support HOT 3
- back button error on web HOT 1
- Doesn't run on android when running out of the box boilerplate.
- Screen and Splash Generator not working HOT 3
- Expo Go should not install expo-dev-client HOT 3
- App keep crashing when i do any changes HOT 3
- cli new fails due to undefined dependency (@expo/config-plugins) HOT 1
- Missing translation HOT 4
- cannot create a project HOT 3
- Error when running `pod install` in the `ios` directory. HOT 3
- Missing translation error with 9.4.2 HOT 1
- Toggle "switch" variant does not slide on web HOT 4
- [Enhancement] v10 - Remove Expo Go compatibility HOT 1
- [Enhancement] v10 - Replace async storage with mmkv HOT 3
- [Enhancement] v10 - Refactor Toggle HOT 4
- reportCrash shows up in Sentry
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ignite.