You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to add events for this package but when I'm runing test it shows error
TypeError: Cannot read properties of undefined (reading 'booted')
First I tried this way
test('Ensure event is emitted when assigning role',async()=>{constdb=awaitcreateDatabase()awaitcreateTables(db)const{ User, Post, Product, Role, Permission, ModelRole, ModelPermission }=awaitdefineModels()constmodelManager=newModelManager()modelManager.setModel('permission',Permission)modelManager.setModel('role',Role)modelManager.setModel('modelPermission',ModelPermission)modelManager.setModel('modelRole',ModelRole)AclManager.setModelManager(modelManager)AclManager.setMorphMap(morphMap)modelManager.setModel('scope',Scope)awaitseedDb({ User, Post, Product })constevents=emitter.fake()// by commenting event related codes it will work goodconstuser=awaitUser.first()if(!user){thrownewError('User not found')}// create roleawaitRole.create({slug: 'admin',})awaitAcl.model(user).assign('admin')// Assert the event was emittedevents.assertEmitted(RoleAssigned)// by commenting event related code it will work good}).pin()
test('Ensure event is emitted when assigning role',async(ctx,done)=>{constdb=awaitcreateDatabase()awaitcreateTables(db)const{ User, Post, Product, Role, Permission, ModelRole, ModelPermission }=awaitdefineModels()constmodelManager=newModelManager()modelManager.setModel('permission',Permission)modelManager.setModel('role',Role)modelManager.setModel('modelPermission',ModelPermission)modelManager.setModel('modelRole',ModelRole)modelManager.setModel('scope',Scope)AclManager.setModelManager(modelManager)AclManager.setMorphMap(morphMap)awaitseedDb({ User, Post, Product })constuser=awaitUser.first()if(!user){thrownewError('User not found')}// create roleawaitRole.create({slug: 'admin',})awaitAcl.model(user).assign('admin')emitter.on(RoleAssigned,(role)=>{console.log(role)done()})// Assert the event was emitted// events.assertEmitted(RoleAssigned)}).pin().waitForDone()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I want to add events for this package but when I'm runing test it shows error
First I tried this way
then this option but same error.
databse setup I took based on this discussion
Beta Was this translation helpful? Give feedback.
All reactions