-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Trouble importing modules to use in detox test files #1873
Comments
Has anyone been able to import ES6 modules into their project, and would able to recommend something in the interim? |
This is not a Detox issue per-se, it's an environment issue. You can do one of the two:
|
The result of my research setup up jest with babel https://stackoverflow.com/a/51842304 Thanks |
@jn3qf I had a similar issue. I noticed that the default runner's config path if you don't specify is the To avoid duplication of configs I created a base config file: module.exports = {
preset: "react-native",
transformIgnorePatterns: [
"node_modules/(?!(react-native|react-native-.*|react-navigation|react-navigation-.*|@react-navigation|@storybook|@react-native-community)/)",
"@shared/",
],
transform: {
"^.+\\.[jt]sx?$": [
"babel-jest",
{
configFile: "./babel.config.js",
},
],
},
roots: ["."],
testEnvironment: "jsdom",
}; Then I removed const baseConfig = require("./base.jest.config.js");
module.exports = {
...baseConfig,
setupFiles: [
"<rootDir>/../../node_modules/react-native/jest/setup.js",
"<rootDir>/../../node_modules/react-native-gesture-handler/jestSetup.js",
"<rootDir>/../../test/setup.ts",
],
testPathIgnorePatterns: ["/node_modules/", "/e2e"],
snapshotSerializers: ["enzyme-to-json/serializer"],
}; Then I replaced the const baseConfig = require("../base.jest.config.js");
module.exports = {
...baseConfig,
setupFilesAfterEnv: ["./init.ts"],
setupFiles: [
"<rootDir>/../../../node_modules/react-native/jest/setup.js",
"<rootDir>/../../../node_modules/react-native-gesture-handler/jestSetup.js",
"<rootDir>/../../../test/setup.ts",
],
testPathIgnorePatterns: ["/node_modules/"],
}; Finally, when calling the PS: Please notice that paths like |
Any updates on this with latest detox and rn ? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! For more information on bots in this reporsitory, read this discussion. |
The issue has been closed for inactivity. |
@jn3qf what did you end up doing? |
Thanks @chika-kasymov your post helped us to solve our issue, which involved adding the following to our detox specific
For reference the error we were seeing was:
|
Sounds like we just need some new guide for that in the docs... 🤔 |
Still relevant. We're looking for volunteers who are familiar with Jest and can help with writing such a guide for the Detox website. |
these solutions don't work, please help |
Is your feature request related to a problem? Please describe.
I'm struggling to import external packages to use with Detox test files. My specific use case is that a testID is linked to a unique key that I need to pull from a firebase database.
Is there a current consensus on the best way to import modules into a test.spec.js style e2e file so that Detox can use them in tests?
Describe the solution you'd like
It would be great if there was an example in documentation describing how to import ES6 modules.
Describe alternatives you've considered
I've looked through these threads documenting similar issues, but all the solutions that I've tried have not worked for me (the majority of the responses were from 2018/early 2019)
vuejs/vue-cli#1584
jestjs/jest#6933
Steps to reproduce:
Configuration
babel.config.js:
package.json:
Device and Verbose Detox Logs
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: