Skip to content

Commit

Permalink
fix(vite): Only attempt to amend test object if one exists
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jaspooky authored Jul 3, 2024
1 parent 28939dd commit bc6ca70
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bc6ca70

Please sign in to comment.