Skip to content

Commit

Permalink
FIX unit tests & add a null-check before getting the array length of …
Browse files Browse the repository at this point in the history
…new property filesRemovedList
  • Loading branch information
ndelangen committed Jul 9, 2019
1 parent b680151 commit 3a450de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test('creates a snapshot summary', () => {
didUpdate: false,
filesAdded: 1,
filesRemoved: 1,
filesRemovedList: [],
filesUnmatched: 1,
filesUpdated: 1,
matched: 2,
Expand Down Expand Up @@ -49,6 +50,7 @@ test('creates a snapshot summary after an update', () => {
didUpdate: true,
filesAdded: 1,
filesRemoved: 1,
filesRemovedList: [],
filesUnmatched: 1,
filesUpdated: 1,
unchecked: 1,
Expand All @@ -75,6 +77,7 @@ it('creates a snapshot summary with multiple snapshot being written/updated', ()
didUpdate: false,
filesAdded: 2,
filesRemoved: 2,
filesRemovedList: [],
filesUnmatched: 2,
filesUpdated: 2,
unchecked: 2,
Expand Down Expand Up @@ -105,6 +108,7 @@ it('returns nothing if there are no updates', () => {
didUpdate: false,
filesAdded: 0,
filesRemoved: 0,
filesRemovedList: [],
filesUnmatched: 0,
filesUpdated: 0,
unchecked: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ test('snapshots needs update with yarn test', () => {
numTotalTestSuites: 1,
numTotalTests: 1,
snapshot: {
filesRemovedList: [],
filesUnmatched: 1,
total: 2,
uncheckedKeysByFile: [],
Expand Down Expand Up @@ -98,6 +99,7 @@ test('snapshots all have results (no update)', () => {
didUpdate: false,
filesAdded: 1,
filesRemoved: 1,
filesRemovedList: [],
filesUnmatched: 1,
filesUpdated: 1,
matched: 2,
Expand Down Expand Up @@ -134,6 +136,7 @@ test('snapshots all have results (after update)', () => {
didUpdate: true,
filesAdded: 1,
filesRemoved: 1,
filesRemovedList: [],
filesUnmatched: 1,
filesUpdated: 1,
matched: 2,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-reporters/src/get_snapshot_summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default (
);
}
}
if (snapshots.filesRemovedList.length) {
if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
const [head, ...tail] = snapshots.filesRemovedList;
summary.push(` ${DOWN_ARROW} ${DOT}${formatTestPath(globalConfig, head)}`);

Expand Down

0 comments on commit 3a450de

Please sign in to comment.