Open DavidRieman opened 1 year ago
This needs to be documented better, but you can include a magic property in the child file (the one that has the "extends"
property) that looks like this "$testRegex.inheritanceType": "replace"
that will change the inheritance behavior from "append" to "replace" for that property.
There currently isn't a way to ignore a property from a parent config file, but it wouldn't be too difficult to add another case to that property.
"$testMatch.inheritanceType": "replace"
worked for me.
We can consider this a documentation bug since it is a useful but undiscoverable feature.
Initial documentation is now in the heft.json property inheritance directives section from our What's New in Heft 0.51 blog post.
I will start on the heft website doc updates next week.
I can't add other fields (I want add "$phaseDependencies.inheritanceType": "append",
), can not pass json-schema check:
Error: Resolved configuration object does not match schema: Error: JSON validation failed:
/data/DevelopmentRoot/github.com/gongt/baobao/@internal/dualstack-rig/build/heft.json
Error: #/phasesByName/build
must NOT have additional properties: $phaseDependencies.inheritanceType
Summary
In a custom-jest.config.json we can use "extends" to inherit a lot of good defaults as needed for rushstack. However, it's not clear how to replace a property like
testMatch
; instead the arrays are merged together, forcing us to run undesired tests. It's also not clear how to just unset such a property - for example, thetestRegex
andtestMatch
properties are mutually exclusive, so projects inheriting from the base config cannot choose to usetestRegex
at all.Repro steps
"extends"
from thejest-shared.config.json
..."testMatch": ["NO-MATCHES-PLEASE"]
and save the file.rushx test
).Expected: No tests run. Results: All the usual tests run.
Details
This makes it very hard to use a multiple-config strategy to separate, say, unit tests from integration tests, while still leveraging the jest-shared.config.json.
To me it seems weird that trying to override a property merges parts of the property instead. It took deep debugging of jest to figure out why the tests were still running. I have to wonder how many other subtle bugs arise from these issues, or if I'm somehow in the minority for thinking a { prop: [] } would override the base { prop: [] }.
That said, if I'm scanning through the right code (ConfigurationFile.ts?) there does appear to be code trying to make choices about what things to merge and what to replace/etc. It's not clear to me ATM whether it is possible/expected for us to control these behaviors from somewhere. If so, could someone point me to the documentation?
Standard questions
Please answer these questions to help us investigate your issue more quickly:
@rushstack/heft
version?node -v
)?