From 193d646beac20282eccc112767c16d41bd091a1f Mon Sep 17 00:00:00 2001 From: Bryan Nicholls Date: Thu, 24 Aug 2017 16:28:51 -0400 Subject: [PATCH] add skipped tests support for jest-editor-support (#4346) --- fixtures/failing_jsons/failing_jest_json.json | 9 +++++++-- packages/jest-editor-support/index.d.ts | 3 ++- .../src/__tests__/test_reconciler.test.js | 11 +++++++++++ packages/jest-editor-support/src/test_reconciler.js | 10 ++++++++++ packages/jest-editor-support/src/types.js | 3 ++- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/fixtures/failing_jsons/failing_jest_json.json b/fixtures/failing_jsons/failing_jest_json.json index 8f1ebafa47aa..5a3d6924f0be 100644 --- a/fixtures/failing_jsons/failing_jest_json.json +++ b/fixtures/failing_jsons/failing_jest_json.json @@ -1,10 +1,10 @@ { "numFailedTests": 1, "numPassedTests": 29, - "numPendingTests": 0, + "numPendingTests": 1, "numRuntimeErrorTestSuites": 0, "numTotalTestSuites": 5, - "numTotalTests": 30, + "numTotalTests": 31, "startTime": 1479634620590, "success": false, "testResults": [ @@ -62,6 +62,11 @@ "status": "passed", "title": "pulls it out of the env", "failureMessages": [] + }, + { + "status": "pending", + "title": "does not pull it out of the env", + "failureMessages": [] } ] }, diff --git a/packages/jest-editor-support/index.d.ts b/packages/jest-editor-support/index.d.ts index c7fc405960bf..47364ab1765d 100644 --- a/packages/jest-editor-support/index.d.ts +++ b/packages/jest-editor-support/index.d.ts @@ -69,7 +69,8 @@ export class TestReconciler { export type TestReconcilationState = "Unknown" | "KnownSuccess" | - "KnownFail"; + "KnownFail" | + "KnownSkip"; export interface TestFileAssertionStatus { file: string; diff --git a/packages/jest-editor-support/src/__tests__/test_reconciler.test.js b/packages/jest-editor-support/src/__tests__/test_reconciler.test.js index 74e505380f6c..a119a7f70aad 100644 --- a/packages/jest-editor-support/src/__tests__/test_reconciler.test.js +++ b/packages/jest-editor-support/src/__tests__/test_reconciler.test.js @@ -58,6 +58,17 @@ describe('Test Reconciler', () => { Expected value to be falsy, instead received true`); }); + + it('skips a skipped method', () => { + parser = reconcilerWithFile('failing_jest_json.json'); + const testName = 'does not pull it out of the env'; + const status: any = parser.stateForTestAssertion( + dangerFilePath, + testName, + ); + expect(status.status).toEqual('KnownSkip'); + expect(status.line).toBeNull(); + }); }); }); diff --git a/packages/jest-editor-support/src/test_reconciler.js b/packages/jest-editor-support/src/test_reconciler.js index 1ff8152ab761..7e2e9dc7e1bf 100644 --- a/packages/jest-editor-support/src/test_reconciler.js +++ b/packages/jest-editor-support/src/test_reconciler.js @@ -30,6 +30,7 @@ module.exports = class TestReconciler { fileStatuses: any; fails: Array; passes: Array; + skips: Array; constructor() { this.fileStatuses = {}; @@ -38,6 +39,7 @@ module.exports = class TestReconciler { updateFileWithJestStatus(results: JestTotalResults) { this.fails = []; this.passes = []; + this.skips = []; // Loop through all files inside the report from Jest results.testResults.forEach(file => { @@ -56,6 +58,8 @@ module.exports = class TestReconciler { this.fails.push(fileStatus); } else if (status === 'KnownSuccess') { this.passes.push(fileStatus); + } else if (status === 'KnownSkip') { + this.skips.push(fileStatus); } }); } @@ -68,6 +72,10 @@ module.exports = class TestReconciler { return this.passes || []; } + skipedStatuses(): Array { + return this.skips || []; + } + // A failed test also contains the stack trace for an `expect` // we don't get this as structured data, but what we get // is useful enough to make it for ourselves @@ -138,6 +146,8 @@ module.exports = class TestReconciler { return 'KnownSuccess'; case 'failed': return 'KnownFail'; + case 'pending': + return 'KnownSkip'; default: return 'Unknown'; } diff --git a/packages/jest-editor-support/src/types.js b/packages/jest-editor-support/src/types.js index ea92ce9f7397..d73f59fc1de5 100644 --- a/packages/jest-editor-support/src/types.js +++ b/packages/jest-editor-support/src/types.js @@ -58,7 +58,8 @@ export type JestTotalResults = { export type TestReconciliationState = | 'Unknown' // The file has not changed, so the watcher didn't hit it | 'KnownFail' // Definitely failed - | 'KnownSuccess'; // Definitely passed + | 'KnownSuccess' // Definitely passed + | 'KnownSkip'; // Definitely skipped /** * The Jest Extension's version of a status for