Test variables
We can test the variables, check their value during the course of the scenario.
Local variable
@Event('start')
start() {
nb = 18
> Give me a number
Prompt()
nb += :text
}The test is as follows:
import assert from 'assert'
import { ConverseTesting } from 'newbot/testing'
import mainSkill from './main'
describe('My own test', () => {
let converse, userConverse
beforeEach(() => {
converse = new ConverseTesting(mainSkill)
userConverse = converse.createUser()
})
test('Test variable', () => {
return userConverse
.start(testing => {
const varNb = testing.variable('nb')
assert.equal(varNb, 18)
})
.prompt('12', testing => {
const varNb = testing.variable('nb')
assert.equal(varNb, 30)
})
.end()
})
})With the testing.variable() method, we can test the value of a local variable
Global variable
The test :
With the testing.userVariable() method, we can test the value of a global variable
Magic variable
The test :
With the testing.magicVariable() method, we can test the value of a magic variable :text
Last updated
Was this helpful?