Skip to content

Commit

Permalink
fix(jest-runner): mark 'todo' tests as skipped (#1420)
Browse files Browse the repository at this point in the history
Treat todo tests `it.todo('some description')` as skipped tests.
  • Loading branch information
ollelauribostrom authored and simondel committed Feb 26, 2019
1 parent 723f0ec commit 26d813f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/jest-runner/src/JestTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export default class JestTestRunner implements TestRunner {
return TestStatus.Success;
case 'pending':
return TestStatus.Skipped;
case 'todo':
return TestStatus.Skipped;
default:
return TestStatus.Failed;
}
Expand Down
55 changes: 55 additions & 0 deletions packages/jest-runner/test/helpers/testResultProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,58 @@ export const createPendingResult = () => ({
],
wasInterrupted: false
});

export const createTodoResult = () => ({
numFailedTests: 0,
numFailedTestSuites: 0,
numPassedTests: 1,
numPassedTestSuites: 1,
numPendingTests: 0,
numPendingTestSuites: 0,
numRuntimeErrorTestSuites: 0,
numTodoTests: 1,
numTotalTests: 2,
numTotalTestSuites: 1,
startTime: 1551045971122,
success: true,
testResults: [
{
console: null,
coverage: undefined,
displayName: undefined,
failureMessage: null,
leaks: false,
numFailingTests: 0,
numPassingTests: 1,
numPendingTests: 0,
numTodoTests: 1,
perfStats: [Object],
skipped: false,
snapshot: [Object],
sourceMaps: {},
testResults: [
{
ancestorTitles: [ 'App' ],
duration: 4,
failureMessages: [],
fullName: 'App renders without crashing',
location: null,
numPassingAsserts: 0,
status: 'passed',
title: 'renders without crashing'
},
{
ancestorTitles: [ 'App' ],
duration: 0,
failureMessages: [],
fullName: 'App renders without crashing with children',
location: null,
numPassingAsserts: 0,
status: 'todo',
title: 'renders without crashing with children'
}
],
}
],
wasInterrupted: false
});
25 changes: 25 additions & 0 deletions packages/jest-runner/test/unit/JestTestRunner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,31 @@ describe('JestTestRunner', () => {
});
});

it('should call the jestTestRunner run method and return a todo runResult', async () => {
jestTestAdapterMock.run.resolves({ results: fakeResults.createTodoResult() });

const result = await jestTestRunner.run(runOptions);

expect(result).to.deep.equal({
errorMessages: [],
status: RunStatus.Complete,
tests: [
{
failureMessages: [],
name: 'App renders without crashing',
status: TestStatus.Success,
timeSpentMs: 4
},
{
failureMessages: [],
name: 'App renders without crashing with children',
status: TestStatus.Skipped,
timeSpentMs: 0
}
]
});
});

it('should call the jestTestRunner run method and return a negative runResult', async () => {
jestTestAdapterMock.run.resolves({ results: fakeResults.createFailResult() });

Expand Down

0 comments on commit 26d813f

Please sign in to comment.