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
92f21d4
commit 274305a
Showing
345 changed files
with
11,278 additions
and
52 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,2 @@ | ||
# See the notes in the file for why this is needed | ||
packages/ast-spec/tests/util/typescript-estree-import.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
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
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
...ges/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/extends-literal/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 @@ | ||
class Foo extends 'Thing' {} |
3 changes: 3 additions & 0 deletions
3
...aration/ClassDeclaration/fixtures/_error_/extends-literal/snapshots/1-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 _error_ extends-literal TSESTree - Error 1`] = `"NO ERROR"`; |
3 changes: 3 additions & 0 deletions
3
...eclaration/ClassDeclaration/fixtures/_error_/extends-literal/snapshots/2-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 _error_ extends-literal Babel - Error 1`] = `"NO ERROR"`; |
3 changes: 3 additions & 0 deletions
3
...ration/ClassDeclaration/fixtures/_error_/extends-literal/snapshots/3-Alignment-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 _error_ extends-literal Error Alignment 1`] = `"No errors"`; |
1 change: 1 addition & 0 deletions
1
...ec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/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 @@ | ||
class Foo implements 'thing' {} |
3 changes: 3 additions & 0 deletions
3
...assDeclaration/fixtures/_error_/implements-non-identifier/snapshots/1-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 _error_ implements-non-identifier TSESTree - Error 1`] = `"NO ERROR"`; |
3 changes: 3 additions & 0 deletions
3
.../ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/2-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 _error_ implements-non-identifier Babel - Error 1`] = `[SyntaxError: Unexpected token (1:21)]`; |
3 changes: 3 additions & 0 deletions
3
...ssDeclaration/fixtures/_error_/implements-non-identifier/snapshots/3-Alignment-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 _error_ implements-non-identifier Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; |
1 change: 1 addition & 0 deletions
1
packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/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 @@ | ||
class Foo; |
3 changes: 3 additions & 0 deletions
3
...src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/1-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 _error_ no-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; |
3 changes: 3 additions & 0 deletions
3
...ec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/2-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 _error_ no-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:9)]`; |
3 changes: 3 additions & 0 deletions
3
...rc/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/3-Alignment-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 _error_ no-body Error Alignment 1`] = `"Both errored"`; |
1 change: 1 addition & 0 deletions
1
...ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/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 @@ | ||
class 'Foo' {} |
3 changes: 3 additions & 0 deletions
3
...ion/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-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 _error_ non-identifier-name TSESTree - Error 1`] = `[TSError: '{' expected.]`; |
3 changes: 3 additions & 0 deletions
3
...ration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-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 _error_ non-identifier-name Babel - Error 1`] = `[SyntaxError: A class name is required. (1:6)]`; |
3 changes: 3 additions & 0 deletions
3
...on/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-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 _error_ non-identifier-name Error Alignment 1`] = `"Both errored"`; |
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 }, | ||
}, | ||
}, | ||
] | ||
`; |
47 changes: 47 additions & 0 deletions
47
...es/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/3-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 }, | ||
}, | ||
} | ||
`; |
Oops, something went wrong.