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
In my plugins, I have Puppeteer E2E tests available for roughly three major versions for backward compatibility. I am struggling because selectors, labels, and expected snapshots change in different versions of WordPress.
As far as I could find, I could not find an API to get the WordPress version, so I created the following function to detect the version number from the body tag:
And as shown below, I have changed the behavior depending on the version:
it('XXX',async()=>{constwpVersion=awaitgetWpVersion();// ...constlabel=['6-1','6-2'].includes(wpVersion)
? 'Label of WordPress 6.1 and 6.2'
: 'Label of other versions';// ...constsnapShot=['6-1','6-2'].includes(wpVersion)
? `Snapshots of WordPress 6.1 and 6.2`
: `Snapshots of other versions`;expect(awaitgetEditedPostContent()).toBe(snapShot);});
If you have a more reasonable approach to these situations, I would love to hear about it.
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
-
In my plugins, I have Puppeteer E2E tests available for roughly three major versions for backward compatibility. I am struggling because selectors, labels, and expected snapshots change in different versions of WordPress.
As far as I could find, I could not find an API to get the WordPress version, so I created the following function to detect the version number from the
body
tag:And as shown below, I have changed the behavior depending on the version:
If you have a more reasonable approach to these situations, I would love to hear about it.
Beta Was this translation helpful? Give feedback.
All reactions