-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
fix: Fix incorrect rootPath resolution in jest plugin #833
fix: Fix incorrect rootPath resolution in jest plugin #833
Conversation
Thanks for the PR, @tryggvigy! Would be great if you could add fixtures for this case. There's one for Jest in And there's DEVELOPMENT.md which might be helpful here. |
Thanks for the pointers @webpro, I'll try to get some test coverage on this asap |
commit: |
This test akes sure that jest configs specified in non-root folders can declare a rootPath option that can be referenced in places like setupFilesAfterEnv
@webpro I've pushed a new commit which includes a unit test that verifies the code changes fix the issue. |
I think I found two more missig features the jest plugin could handle.
reporters: [
'default',
[
'jest-junit',
{
outputDirectory: '<rootDir>',
outputName: 'junit-e2e.xml',
testSuitePropertiesFile: 'junitProperties.e2e.cjs',
},
],
...
]
testEnvironment:
'<rootDir>/tests/framework/e2e/jest-environments/E2EEnvironment.ts', I can make separate PRs to try and fix those. |
Perfect, thank you!
That would be great. Guess we could use the new fixture/test for this as well. Thanks in advance! |
🚀 This pull request is included in v5.37.0. See Release 5.37.0 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
This PR
Stops joining contructing a jest config rootDir via
join(configFileDir, localConfig.rootDir)
when a localConfig rootDir is defined. Instead, we always prefer the local config rootDir and fall back to
configFileDir
.I also include a new unit test that tests that this bug is fixed.
Context
I noticed that jest setup files that used the
'<rootDir>/...'
alias in places likesetupFilesAfterEnv
were resolving incorrectly. For example,when I specify
in the jest plugin,
Where
jest.config.base.ts
contains:I get the following incorrect resolve:
Where it was joining
/Users/me/work/repo/tests/framework/e2e/jest-configs/
)rootDir
in the config file (/Users/me/work/repo/
)tests/framework/e2e/setup-files/setup.base.ts
)This is happening
I might be wrong, I don't have all the context, but this feels like wrong behaviour.