-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(formatter): Enable calling parseTestCaseAttempt on test cases tha…
…t haven't completed (#1531) * fix(formatter): Enable calling parseTestCaseAttempt on test cases that haven't completed yet * Instanciate a proper TestStepResult when parsing TestCaseAttempt * Add unit tests * Refactor testCaseAttemptParser unit tests Co-authored-by: Aurélien Reeves <aurelien.reeves@smartbear.com> Co-authored-by: Aslak Hellesøy <1000+aslakhellesoy@users.noreply.github.com>
- Loading branch information
1 parent
0fbb0fb
commit 6e958f1
Showing
2 changed files
with
87 additions
and
1 deletion.
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,81 @@ | ||
import { describe, it } from 'mocha' | ||
import { expect } from 'chai' | ||
import * as messages from '@cucumber/messages' | ||
import { parseTestCaseAttempt } from '.' | ||
import { getBaseSupportCodeLibrary } from '../../../test/fixtures/steps' | ||
import StepDefinitionSnippetBuilder from '../step_definition_snippet_builder' | ||
import { ParameterTypeRegistry } from '@cucumber/cucumber-expressions' | ||
import { reindent } from 'reindent-template-literals' | ||
import { getTestCaseAttempts } from '../../../test/formatter_helpers' | ||
|
||
describe('TestCaseAttemptParser', () => { | ||
describe('parseTestCaseAttempt', () => { | ||
const cwd = '' | ||
const supportCodeLibrary = getBaseSupportCodeLibrary() | ||
const snippetSyntax = { | ||
build: () => 'snippet', | ||
} | ||
|
||
const snippetBuilder = new StepDefinitionSnippetBuilder({ | ||
snippetSyntax, | ||
parameterTypeRegistry: new ParameterTypeRegistry(), | ||
}) | ||
|
||
const source = { | ||
data: reindent(` | ||
Feature: my feature | ||
Scenario: my scenario | ||
Given a passing step | ||
`), | ||
uri: 'a.feature', | ||
} | ||
|
||
describe('with no test step result', () => { | ||
it('initialize step result with status UNKNOWN', async () => { | ||
// Arrange | ||
const [testCaseAttempt] = await getTestCaseAttempts({ | ||
sources: [source], | ||
supportCodeLibrary, | ||
}) | ||
|
||
testCaseAttempt.stepResults = {} | ||
|
||
// Act | ||
const output = parseTestCaseAttempt({ | ||
cwd, | ||
testCaseAttempt, | ||
snippetBuilder, | ||
supportCodeLibrary, | ||
}) | ||
|
||
// Assert | ||
expect(output.testSteps[0].result.status).to.eq( | ||
messages.TestStepResultStatus.UNKNOWN | ||
) | ||
}) | ||
}) | ||
|
||
describe('with test step result', () => { | ||
it('uses the parsed step result', async () => { | ||
// Arrange | ||
const [testCaseAttempt] = await getTestCaseAttempts({ | ||
sources: [source], | ||
supportCodeLibrary, | ||
}) | ||
|
||
// Act | ||
const output = parseTestCaseAttempt({ | ||
cwd, | ||
testCaseAttempt, | ||
snippetBuilder, | ||
supportCodeLibrary, | ||
}) | ||
|
||
// Assert | ||
expect(output.testSteps[0].result.status).to.eq( | ||
messages.TestStepResultStatus.PASSED | ||
) | ||
}) | ||
}) | ||
}) | ||
}) |