Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fixture tests for each and every AST node. To make things more readable I: - separated the AST from the tokens - this stops the individual snapshot from being so long it's impossible to understand - if there are changes to tokens - then they should be more obvious now. Before you had to expand the snapshot in github to understand that the token was part of the tokens array. - always write error snapshot, and always write AST/token snapshots - This is just for consistency and to make it easier whilst you're developing. - It will prevent us from accidentally leaving behind error snapshots if they weren't supposed to be there. - added a custom snapshot serializer - Having learned how useful they are with scope manager - I created a new one to improve the look of the snapshots. - Instead of sorting alphabetically, I place `type` at the top, and `range`/`loc` at the end. - Instead of outputting `Object` ahead of every node, instead it outputs the node `type`. - I adjusted the output `range`/`loc` so they take up fewer lines and are more compact. I prefixed the snapshot names with numbers just so we can control the sorting of them. No other reason.
- Loading branch information
1 parent
b1d4449
commit 9edbb00
Showing
124 changed files
with
4,633 additions
and
21 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
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
".tsx.shot", | ||
".js.shot", | ||
".jsx.shot", | ||
".shot", | ||
], | ||
"extends": "jest_snapshot" | ||
}, | ||
|
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
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
1 change: 1 addition & 0 deletions
1
packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/fixture.ts
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 @@ | ||
abstract class Foo {} |
47 changes: 47 additions & 0 deletions
47
...ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/1-TSESTree-AST.shot
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,47 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AST Fixtures declaration ClassDeclaration abstract TSESTree - AST 1`] = ` | ||
Program { | ||
type: "Program", | ||
body: Array [ | ||
ClassDeclaration { | ||
type: "ClassDeclaration", | ||
abstract: true, | ||
body: ClassBody { | ||
type: "ClassBody", | ||
body: Array [], | ||
|
||
range: [19, 21], | ||
loc: { | ||
start: { column: 19, line: 1 }, | ||
end: { column: 21, line: 1 }, | ||
}, | ||
}, | ||
id: Identifier { | ||
type: "Identifier", | ||
name: "Foo", | ||
|
||
range: [15, 18], | ||
loc: { | ||
start: { column: 15, line: 1 }, | ||
end: { column: 18, line: 1 }, | ||
}, | ||
}, | ||
superClass: null, | ||
|
||
range: [0, 21], | ||
loc: { | ||
start: { column: 0, line: 1 }, | ||
end: { column: 21, line: 1 }, | ||
}, | ||
}, | ||
], | ||
sourceType: "script", | ||
|
||
range: [0, 22], | ||
loc: { | ||
start: { column: 0, line: 1 }, | ||
end: { column: 0, line: 2 }, | ||
}, | ||
} | ||
`; |
56 changes: 56 additions & 0 deletions
56
...-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/2-TSESTree-Tokens.shot
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,56 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AST Fixtures declaration ClassDeclaration abstract TSESTree - Tokens 1`] = ` | ||
Array [ | ||
Identifier { | ||
type: "Identifier", | ||
value: "abstract", | ||
|
||
range: [0, 8], | ||
loc: { | ||
start: { column: 0, line: 1 }, | ||
end: { column: 8, line: 1 }, | ||
}, | ||
}, | ||
Keyword { | ||
type: "Keyword", | ||
value: "class", | ||
|
||
range: [9, 14], | ||
loc: { | ||
start: { column: 9, line: 1 }, | ||
end: { column: 14, line: 1 }, | ||
}, | ||
}, | ||
Identifier { | ||
type: "Identifier", | ||
value: "Foo", | ||
|
||
range: [15, 18], | ||
loc: { | ||
start: { column: 15, line: 1 }, | ||
end: { column: 18, line: 1 }, | ||
}, | ||
}, | ||
Punctuator { | ||
type: "Punctuator", | ||
value: "{", | ||
|
||
range: [19, 20], | ||
loc: { | ||
start: { column: 19, line: 1 }, | ||
end: { column: 20, line: 1 }, | ||
}, | ||
}, | ||
Punctuator { | ||
type: "Punctuator", | ||
value: "}", | ||
|
||
range: [20, 21], | ||
loc: { | ||
start: { column: 20, line: 1 }, | ||
end: { column: 21, line: 1 }, | ||
}, | ||
}, | ||
] | ||
`; |
3 changes: 3 additions & 0 deletions
3
...t-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/3-TSESTree-Error.shot
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AST Fixtures declaration ClassDeclaration abstract TSESTree - Error 1`] = `"NO ERROR"`; |
47 changes: 47 additions & 0 deletions
47
...es/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/4-Babel-AST.shot
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,47 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AST Fixtures declaration ClassDeclaration abstract Babel - AST 1`] = ` | ||
Program { | ||
type: "Program", | ||
body: Array [ | ||
ClassDeclaration { | ||
type: "ClassDeclaration", | ||
abstract: true, | ||
body: ClassBody { | ||
type: "ClassBody", | ||
body: Array [], | ||
|
||
range: [19, 21], | ||
loc: { | ||
start: { column: 19, line: 1 }, | ||
end: { column: 21, line: 1 }, | ||
}, | ||
}, | ||
id: Identifier { | ||
type: "Identifier", | ||
name: "Foo", | ||
|
||
range: [15, 18], | ||
loc: { | ||
start: { column: 15, line: 1 }, | ||
end: { column: 18, line: 1 }, | ||
}, | ||
}, | ||
superClass: null, | ||
|
||
range: [0, 21], | ||
loc: { | ||
start: { column: 0, line: 1 }, | ||
end: { column: 21, line: 1 }, | ||
}, | ||
}, | ||
], | ||
sourceType: "script", | ||
|
||
range: [0, 22], | ||
loc: { | ||
start: { column: 0, line: 1 }, | ||
end: { column: 0, line: 2 }, | ||
}, | ||
} | ||
`; |
56 changes: 56 additions & 0 deletions
56
...ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/5-Babel-Tokens.shot
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,56 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AST Fixtures declaration ClassDeclaration abstract Babel - Tokens 1`] = ` | ||
Array [ | ||
Identifier { | ||
type: "Identifier", | ||
value: "abstract", | ||
|
||
range: [0, 8], | ||
loc: { | ||
start: { column: 0, line: 1 }, | ||
end: { column: 8, line: 1 }, | ||
}, | ||
}, | ||
Keyword { | ||
type: "Keyword", | ||
value: "class", | ||
|
||
range: [9, 14], | ||
loc: { | ||
start: { column: 9, line: 1 }, | ||
end: { column: 14, line: 1 }, | ||
}, | ||
}, | ||
Identifier { | ||
type: "Identifier", | ||
value: "Foo", | ||
|
||
range: [15, 18], | ||
loc: { | ||
start: { column: 15, line: 1 }, | ||
end: { column: 18, line: 1 }, | ||
}, | ||
}, | ||
Punctuator { | ||
type: "Punctuator", | ||
value: "{", | ||
|
||
range: [19, 20], | ||
loc: { | ||
start: { column: 19, line: 1 }, | ||
end: { column: 20, line: 1 }, | ||
}, | ||
}, | ||
Punctuator { | ||
type: "Punctuator", | ||
value: "}", | ||
|
||
range: [20, 21], | ||
loc: { | ||
start: { column: 20, line: 1 }, | ||
end: { column: 21, line: 1 }, | ||
}, | ||
}, | ||
] | ||
`; |
3 changes: 3 additions & 0 deletions
3
.../ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/6-Babel-Error.shot
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AST Fixtures declaration ClassDeclaration abstract Babel - Error 1`] = `"NO ERROR"`; |
6 changes: 6 additions & 0 deletions
6
...pec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/7-AST-Alignment-AST.shot
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,6 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AST Fixtures declaration ClassDeclaration abstract AST Alignment - AST 1`] = ` | ||
"Snapshot Diff: | ||
Compared values have no visual difference." | ||
`; |
6 changes: 6 additions & 0 deletions
6
.../src/declaration/ClassDeclaration/fixtures/abstract/snapshots/8-AST-Alignment-Tokens.shot
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,6 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AST Fixtures declaration ClassDeclaration abstract AST Alignment - Token 1`] = ` | ||
"Snapshot Diff: | ||
Compared values have no visual difference." | ||
`; |
1 change: 1 addition & 0 deletions
1
packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/fixture.ts
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 @@ | ||
declare class Foo {} |
Oops, something went wrong.