fix(vite): Only attempt to amend test object if one exists (#26822)
Test object is assigned using optional chaining but previously did not check that any value had actually been assigned which would cause the `getStart` call to fail resulting in a failed migration. ## Current Behavior Migration fails if no matching test object is found. ## Expected Behavior Migration should not fail. ## Related Issue(s) I haven't opened an issue, just the PR. I can open an issue if required for tracking.
This commit is contained in:
parent
73858a094e
commit
8fd38cba9a
@ -102,11 +102,14 @@ export function fixCoverageAndRerporters(
|
||||
configNode,
|
||||
`PropertyAssignment:has(Identifier[name="test"])`
|
||||
)?.[0];
|
||||
changes.push({
|
||||
type: ChangeType.Insert,
|
||||
index: testObject.getStart() + `test: {`.length + 1,
|
||||
text: `reporters: ['default'],`,
|
||||
});
|
||||
|
||||
if (testObject) {
|
||||
changes.push({
|
||||
type: ChangeType.Insert,
|
||||
index: testObject.getStart() + `test: {`.length + 1,
|
||||
text: `reporters: ['default'],`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (changes.length > 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user