[ci] Provide a Mock PuppetWeb Instance for Integration Test
Created by: lijiarui
I modified function contact.find()
and want to use test file to check whether it works well, then I use the following code:
const contact1 = await Contact.find({name: 'NickNameTest'})
t.is(contact1.id, UserName, 'should find contact by name')
I didn't pass the test for the following error:
VERB Contact find({"name":"NickNameTest"})
VERB Cotnact findAll({ name: NickNameTest })
SILL (function (c) { return c.NickName === 'NickNameTest' })
ERR Contact findAll() rejected: contactFind fail: no bridge(yet)!
...
contact › Contact smoke testing
Error: find not found any contact
Function.<anonymous> (src/contact.ts:77:18)
Generator.next (<anonymous>)
fulfilled (dist/src/contact.js:1:29176)
I'm trying to find the solution in room.spec.ts
, I guess they maybe the same, then I found in your test file room.spec.ts
, you test function Room.find()
using the following function:
test('Room static method', async t => {
try {
await Room.find({ topic: 'xxx' })
t.fail('should throw but not')
} catch (e) {
t.pass('should throw before login or not found')
}
const roomList = await Room.findAll({
topic: 'yyy'
})
t.is(roomList.length, 0, 'should return empty array before login')
})
I think it means I couldn't use function Room.find()
before login, the same as Class Contact.find()
.
But I guess it is possible to use test file to check Contact.find()
, for example, mock login data, but I don't know how to do it.
So, could you help me to use test file to check function Contact.find()
.