Skip to content

Commit 0938136

Browse files
Merge pull request #133 from abhilashkasula/master
Provide transcript for handling
2 parents 9e7a69b + 5e82e1c commit 0938136

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

src/BotiumBindings.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module.exports = class BotiumBindings {
7777
}
7878
}
7979

80-
setupTestSuite (testcaseCb, assertCb, failCb) {
80+
setupTestSuite (testcaseCb, onTranscriptReady = () => {}, assertCb, failCb) {
8181
if (this.convodirs && this.convodirs.length) {
8282
this.convodirs.forEach((convodir) => {
8383
this.compiler.ReadScriptsFromDirectory(convodir)
@@ -124,7 +124,7 @@ module.exports = class BotiumBindings {
124124
const retryHelper = new RetryHelper(this.container.caps, 'CONVO')
125125
promiseRetry(async (retry, number) => {
126126
try {
127-
await convo.Run(this.container)
127+
return await convo.Run(this.container)
128128
} catch (err) {
129129
if (retryHelper.shouldRetry(err)) {
130130
debug(`Running Convo "${convo.header.name}" trial #${number} failed, retry activated`)
@@ -138,12 +138,14 @@ module.exports = class BotiumBindings {
138138
}
139139
}
140140
}, retryHelper.retrySettings)
141-
.then(() => {
141+
.then((transcript) => {
142142
debug(`Test Case "${convo.header.name}" ready, calling done function.`)
143+
onTranscriptReady(transcript)
143144
testcaseDone()
144145
})
145146
.catch((err) => {
146147
debug(`Test Case "${convo.header.name}" failed: ${util.inspect(err)}`)
148+
onTranscriptReady(err.transcript)
147149
testcaseDone(this.wrapBotiumError(err))
148150
})
149151
} else {

src/helpers/jasmine.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const BotiumBindings = require('../BotiumBindings')
44

55
const defaultTimeout = process.env.BOTIUM_JASMINE_TIMEOUT || 60000
66

7-
const setupJasmineTestCases = ({ timeout = defaultTimeout, testcaseSelector, bb } = {}) => {
7+
const setupJasmineTestCases = ({ timeout = defaultTimeout, testcaseSelector, onTranscriptReady, bb } = {}) => {
88
bb = bb || new BotiumBindings()
99

1010
bb.setupTestSuite(
@@ -24,12 +24,13 @@ const setupJasmineTestCases = ({ timeout = defaultTimeout, testcaseSelector, bb
2424
timeout)
2525
return true
2626
},
27+
onTranscriptReady,
2728
null,
2829
(err) => fail(err)
2930
)
3031
}
3132

32-
const setupJasmineTestSuite = ({ timeout = defaultTimeout, name, testcaseSelector, bb } = {}) => {
33+
const setupJasmineTestSuite = ({ timeout = defaultTimeout, name, testcaseSelector, onTranscriptReady, bb } = {}) => {
3334
bb = bb || new BotiumBindings()
3435
name = name || bb.getTestSuiteName()
3536

@@ -50,7 +51,7 @@ const setupJasmineTestSuite = ({ timeout = defaultTimeout, name, testcaseSelecto
5051
bb.afterAll().then(() => done()).catch(done.fail)
5152
}, timeout)
5253

53-
setupJasmineTestCases({ timeout, testcaseSelector, bb })
54+
setupJasmineTestCases({ timeout, testcaseSelector, onTranscriptReady, bb })
5455
})
5556
}
5657

src/helpers/jest.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const BotiumBindings = require('../BotiumBindings')
44

5-
const setupJestTestCases = ({ testcaseSelector, bb } = {}) => {
5+
const setupJestTestCases = ({ testcaseSelector, onTranscriptReady, bb } = {}) => {
66
bb = bb || new BotiumBindings()
77

88
let testCount = 0
@@ -13,14 +13,15 @@ const setupJestTestCases = ({ testcaseSelector, bb } = {}) => {
1313
testCount++
1414
test(testcase.header.name, testcaseFunction)
1515
return true
16-
}
16+
},
17+
onTranscriptReady
1718
)
1819
if (testCount === 0) {
1920
it.skip('skip empty test suite', () => {})
2021
}
2122
}
2223

23-
const setupJestTestSuite = ({ name, testcaseSelector, bb } = {}) => {
24+
const setupJestTestSuite = ({ name, testcaseSelector, onTranscriptReady, bb } = {}) => {
2425
bb = bb || new BotiumBindings()
2526
name = name || bb.getTestSuiteName()
2627

@@ -41,7 +42,7 @@ const setupJestTestSuite = ({ name, testcaseSelector, bb } = {}) => {
4142
bb.afterAll().then(() => done()).catch(done)
4243
})
4344

44-
setupJestTestCases({ bb, testcaseSelector })
45+
setupJestTestCases({ bb, testcaseSelector, onTranscriptReady })
4546
})
4647
}
4748

src/helpers/mocha.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const BotiumBindings = require('../BotiumBindings')
44

55
const defaultTimeout = process.env.BOTIUM_MOCHA_TIMEOUT || 60000
66

7-
const setupMochaTestCases = ({ timeout = defaultTimeout, testcaseSelector, bb } = {}) => {
7+
const setupMochaTestCases = ({ timeout = defaultTimeout, testcaseSelector, onTranscriptReady, bb } = {}) => {
88
bb = bb || new BotiumBindings()
99

1010
bb.setupTestSuite(
@@ -13,11 +13,12 @@ const setupMochaTestCases = ({ timeout = defaultTimeout, testcaseSelector, bb }
1313

1414
it(testcase.header.name, testcaseFunction).timeout(timeout)
1515
return true
16-
}
16+
},
17+
onTranscriptReady
1718
)
1819
}
1920

20-
const setupMochaTestSuite = ({ timeout = defaultTimeout, name, testcaseSelector, bb } = {}) => {
21+
const setupMochaTestSuite = ({ timeout = defaultTimeout, name, testcaseSelector, onTranscriptReady, bb } = {}) => {
2122
bb = bb || new BotiumBindings()
2223
name = name || bb.getTestSuiteName()
2324

@@ -39,7 +40,7 @@ const setupMochaTestSuite = ({ timeout = defaultTimeout, name, testcaseSelector,
3940
bb.afterAll().then(() => done()).catch(done)
4041
})
4142

42-
setupMochaTestCases({ timeout, testcaseSelector, bb })
43+
setupMochaTestCases({ timeout, testcaseSelector, onTranscriptReady, bb })
4344
})
4445
}
4546

0 commit comments

Comments
 (0)