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

feat/add steps cas #21

Merged
merged 2 commits into from
Aug 28, 2024
Merged
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
66 changes: 66 additions & 0 deletions test/TestrailReporter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,72 @@ describe("TestrailReporter", () => {
})
})

describe("TESTRAIL_STEPS env value is", () => {
describe("true: reports multiple assertions as a steps if they have same test case ids", () => {
it("reports as an failed test case when one step fails, even if others succeed", () => {
// arrange
setEnvVars(vi)
vi.stubEnv("TESTRAIL_STEPS", "true")
const sut = new TestrailReporter(makeSampleEmitter(vi.fn()), {}, {})
sut.env = getEnv()
const executions = makeNewmanResult({
caseNumbers: "C1",
error: true,
}).concat(makeNewmanResult({ caseNumbers: "C1" }))

// act
sut.jsonifyResults(executions)

// assert
expect(sut.results).lengthOf(1)
// status_id: https://docs.testrail.techmatrix.jp/testrail/docs/702/api/reference/statuses/
expect(sut.results[0].status_id).toBe(5)
})

it("resports as an success test case when all steps are success", () => {
// arrange
setEnvVars(vi)
vi.stubEnv("TESTRAIL_STEPS", "true")
const sut = new TestrailReporter(makeSampleEmitter(vi.fn()), {}, {})
sut.env = getEnv()
const executions = makeNewmanResult({ caseNumbers: "C1" }).concat(
makeNewmanResult({ caseNumbers: "C1" }),
)

// act
sut.jsonifyResults(executions)

// assert
expect(sut.results).lengthOf(1)
// status_id: https://docs.testrail.techmatrix.jp/testrail/docs/702/api/reference/statuses/
expect(sut.results[0].status_id).toBe(1)
})
})

describe("false (default value): reports multipe assertions as multiple test results", () => {
it("reports as two test results", () => {
// arrange
setEnvVars(vi)
vi.stubEnv("TESTRAIL_STEPS", "false")
const sut = new TestrailReporter(makeSampleEmitter(vi.fn()), {}, {})
sut.env = getEnv()
const executions = makeNewmanResult({
caseNumbers: "C1",
error: true,
}).concat(makeNewmanResult({ caseNumbers: "C1" }))

// act
sut.jsonifyResults(executions)

// assert
expect(sut.results).lengthOf(2)
// status_id: https://docs.testrail.techmatrix.jp/testrail/docs/702/api/reference/statuses/
expect(sut.results[0].status_id).toBe(5)
expect(sut.results[1].status_id).toBe(1)
})
})
})

describe("User wants to establish connection by title not by case id", () => {
describe("When TESTRAIL_TITLE_MATCHING env value is `true`", () => {
it("Newman assertions with title `TestTitle` matched to TestRail test case with `TestTitle`", () => {
Expand Down