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
Hello there. I'll make this as short as possible. My business is using jest to run tests on a pixi project of ours, and since these are tests, all resources are replaced with empty ones. This caused an issue because certain sprites that used pixi-spine would error due to the invalid data. I instead came up with the following function:
constmockData: ISkeletonData={animations: [],name: "",bones: [],slots: [],skins: [],defaultSkin: undefined,events: [],version: "",hash: "",width: 0,height: 0,ikConstraints: [],transformConstraints: [],pathConstraints: [],findBone: function(): IBoneData{thrownewError("Function not implemented.")},findBoneIndex: function(): number{thrownewError("Function not implemented.")},findSlot: function(): ISlotData{thrownewError("Function not implemented.")},findSlotIndex: function(): number{thrownewError("Function not implemented.")},findSkin: function(): ISkin{thrownewError("Function not implemented.")},findEvent: function(): IEventData{thrownewError("Function not implemented.")},findAnimation: function(name){returnmockData.animations.filter(a=>a.name===name)[0]},findIkConstraint: function(): IIkConstraintData{thrownewError("Function not implemented.")},findTransformConstraint: function(): ITransformConstraintData{thrownewError("Function not implemented.")},findPathConstraint: function(): IPathConstraintData{thrownewError("Function not implemented.")}}for(constanimNameofanimationNames){mockData.animations.push({name: animName,timelines: [],duration: 0})}returnmockData
Although this works fine for creating the spineData and loading it up to a new Spine object, we came across an issue when running the setAnimation() function. What happens is that the animation will fire off the started event, but will not fire any other ones. From my observation, it is like it it isn't running at all.
My question is, how could I make a mock spineData to be used by other resources while retaining the "functionality" of a real Spine (mainly, the completed event)? Thank you for your time and help, it is truly appreciated.
The text was updated successfully, but these errors were encountered:
Hello there. I'll make this as short as possible. My business is using jest to run tests on a
pixi
project of ours, and since these are tests, all resources are replaced with empty ones. This caused an issue because certain sprites that usedpixi-spine
would error due to the invalid data. I instead came up with the following function:This is then used like this:
Although this works fine for creating the
spineData
and loading it up to a newSpine
object, we came across an issue when running thesetAnimation()
function. What happens is that the animation will fire off thestarted
event, but will not fire any other ones. From my observation, it is like it it isn't running at all.My question is, how could I make a mock
spineData
to be used by other resources while retaining the "functionality" of a realSpine
(mainly, thecompleted
event)? Thank you for your time and help, it is truly appreciated.The text was updated successfully, but these errors were encountered: