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

Path resolution issues with Jest@20 #3542

Closed
kentcdodds opened this issue May 10, 2017 · 5 comments
Closed

Path resolution issues with Jest@20 #3542

kentcdodds opened this issue May 10, 2017 · 5 comments

Comments

@kentcdodds
Copy link
Contributor

Do you want to request a feature or report a bug?

bug

What is the current behavior?

I'm unsure what's happened, but maybe a diff will help reveal what's going on.

Here's how I had to change things when upgrading from a working Jest@19 setup to an almost working setup with Jest@20

diff --git a/tests/jest.config.client.json b/tests/jest.config.client.json
index 242ccad0ed..9abc83cdb3 100644
--- a/tests/jest.config.client.json
+++ b/tests/jest.config.client.json
@@ -1,13 +1,13 @@
 {
   "roots": [
-    "<rootDir>/public/js"
+    "../public/js"
   ],
   "setupFiles": [
-    "<rootDir>/tests/lib/setup-test-env-jest-client.js"
+    "./lib/setup-test-env-jest-client.js"
   ],
-  "setupTestFrameworkScriptFile": "<rootDir>/tests/lib/before-each-test-client.js",
+  "setupTestFrameworkScriptFile": "./lib/before-each-test-client.js",
   "transform": {
-    "^.+\\.js$": "<rootDir>/tests/lib/client-preprocessor.js"
+    "^.+\\.js$": "./lib/client-preprocessor.js"
   },
   "testURL": "http://example.com",
   "testPathIgnorePatterns": [
@@ -15,7 +15,7 @@
     "/__tests__/helpers/",
     "/__tests__/fixtures/"
   ],
-  "testEnvironment": "jest-environment-jsdom",
+  "testEnvironment": "jsdom",
   "moduleNameMapper": {
     "^.+\\.svg$": "<rootDir>/public/js/__mocks__/custom/file-mock.js"
   },

I think this is important to note: My config is located in <rootDir>/tests/jest.config.client.json and my root is in <rootDir>/public/js.

Really sorry I was unable to try the alpha out on my project :-(

With these changes, Jest starts running the tests, but it appears it's not transpiling things properly.

@kentcdodds
Copy link
Contributor Author

This is probably related to #3541

@thymikee
Copy link
Collaborator

thymikee commented May 10, 2017

This should fix it: #3538 (except for testEnvironment issue)

@kentcdodds
Copy link
Contributor Author

Thanks @thymikee! Does that also cover the transform, setupTestFrameworkScriptFile, roots, and setupFiles changes?

@thymikee
Copy link
Collaborator

Hm, not sure about that, we need to test nested configs more thoroughly after recent rewrite.
In one project with config being in different dir than root, I had to explicitly set "rootDir": "../path/to/root". So I'll keep this open.

@cpojer cpojer closed this as completed Aug 24, 2017
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants