Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add skipped tests support for jest-editor-support #4346

Merged
merged 1 commit into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions fixtures/failing_jsons/failing_jest_json.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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": []
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-editor-support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export class TestReconciler {

export type TestReconcilationState = "Unknown" |
"KnownSuccess" |
"KnownFail";
"KnownFail" |
"KnownSkip";

export interface TestFileAssertionStatus {
file: string;
Expand Down
11 changes: 11 additions & 0 deletions packages/jest-editor-support/src/__tests__/test_reconciler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

Expand Down
10 changes: 10 additions & 0 deletions packages/jest-editor-support/src/test_reconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = class TestReconciler {
fileStatuses: any;
fails: Array<TestFileAssertionStatus>;
passes: Array<TestFileAssertionStatus>;
skips: Array<TestFileAssertionStatus>;

constructor() {
this.fileStatuses = {};
Expand All @@ -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 => {
Expand All @@ -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);
}
});
}
Expand All @@ -68,6 +72,10 @@ module.exports = class TestReconciler {
return this.passes || [];
}

skipedStatuses(): Array<TestFileAssertionStatus> {
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
Expand Down Expand Up @@ -138,6 +146,8 @@ module.exports = class TestReconciler {
return 'KnownSuccess';
case 'failed':
return 'KnownFail';
case 'pending':
return 'KnownSkip';
default:
return 'Unknown';
}
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-editor-support/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down