-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* re-do jest indents with snapshot patch * add script to remove all inline snapshots * linter
- Loading branch information
1 parent
8c26a4c
commit 86aac28
Showing
5 changed files
with
287 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
diff --git a/node_modules/jest-snapshot/build/InlineSnapshots.js b/node_modules/jest-snapshot/build/InlineSnapshots.js | ||
index 3481ad9..3c227dd 100644 | ||
--- a/node_modules/jest-snapshot/build/InlineSnapshots.js | ||
+++ b/node_modules/jest-snapshot/build/InlineSnapshots.js | ||
@@ -193,11 +193,24 @@ const saveSnapshotsForFile = (snapshots, sourceFilePath, rootDir, prettier) => { | ||
|
||
// A hack to prevent unexpected line breaks in the generated code | ||
node.loc.end.line = node.loc.start.line; | ||
+ const codeParts = generate(node, { | ||
+ retainLines: true | ||
+ }).code.trim().split("\n"); | ||
+ const codeIndented = codeParts | ||
+ .map((part, index) => { | ||
+ switch (index) { | ||
+ case 0: | ||
+ return part; | ||
+ case codeParts.length - 1: | ||
+ return " ".repeat(node.loc.start.column) + part; | ||
+ default: | ||
+ return " ".repeat(node.loc.start.column + 2) + part; | ||
+ } | ||
+ }) | ||
+ .join("\n"); | ||
return ( | ||
sourceSoFar.slice(0, node.start) + | ||
- generate(node, { | ||
- retainLines: true | ||
- }).code.trim() + | ||
+ codeIndented + | ||
sourceSoFar.slice(node.end) | ||
); | ||
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.