@skyramp/skyramp 1.2.32 → 1.2.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyramp/skyramp",
3
- "version": "1.2.32",
3
+ "version": "1.2.34",
4
4
  "description": "module for leveraging skyramp cli functionality",
5
5
  "scripts": {
6
6
  "lint": "eslint 'src/**/*.js' 'src/**/*.ts' --fix",
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- export function newSkyrampPlaywrightPage(page: any, testInfo: any): any;
2
+ export function newSkyrampPlaywrightPage(page: any, testInfo?: any): any;
3
3
 
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
5
  export function expect(obj: any): any;
@@ -816,10 +816,11 @@ function newSkyrampPlaywrightPage(page, testInfo) {
816
816
  * Check if snapshot exists, create if missing, then compare. Enabling single-run screenshots
817
817
  */
818
818
  class SkyrampPageAssertions {
819
- constructor(playwrightExpectation, actualObject, testInfo) {
819
+ constructor(playwrightExpectation, actualObject, testInfo, pageOrLocator) {
820
820
  this._playwrightExpectation = playwrightExpectation;
821
821
  this._actualObject = actualObject;
822
822
  this._testInfo = testInfo;
823
+ this._pageOrLocator = pageOrLocator || actualObject;
823
824
  this._autoBaseline = process.env.SKYRAMP_AUTO_BASELINE !== 'false';
824
825
 
825
826
  // Proxy to forward all methods except toHaveScreenshot
@@ -842,7 +843,7 @@ class SkyrampPageAssertions {
842
843
  */
843
844
  async toHaveScreenshot(nameOrOptions, options) {
844
845
  // wait for some time before taking snapshot
845
- this._actualObject.waitForTimeout(2000);
846
+ await this._pageOrLocator.waitForTimeout(2000);
846
847
 
847
848
  // If auto-baseline disabled or no testInfo, use standard Playwright behavior
848
849
  if (!this._autoBaseline || !this._testInfo) {
@@ -895,8 +896,13 @@ function expect(obj, testInfo) {
895
896
  let extractedTestInfo = testInfo;
896
897
 
897
898
  if (obj instanceof SkyrampPlaywrightLocator) {
898
- // locators do not have toHaveScreenshot
899
- return playwrightExpect(obj.unwrap());
899
+ actualObject = obj.unwrap();
900
+ // Get testInfo from the locator's parent page
901
+ if (!extractedTestInfo && obj._skyrampPage && obj._skyrampPage._testInfo) {
902
+ extractedTestInfo = obj._skyrampPage._testInfo;
903
+ }
904
+ const playwrightExpectation = playwrightExpect(actualObject);
905
+ return new SkyrampPageAssertions(playwrightExpectation, actualObject, extractedTestInfo, actualObject.page());
900
906
  }
901
907
  if (obj instanceof SkyrampPlaywrightPage) {
902
908
  actualObject = obj.unwrap();