codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS
http://codecept.io
MIT License
4.1k stars 723 forks source link

Playwright: Video and trace can't be assigned to artifacts when error happens in Before #3032

Closed jancorvus closed 3 years ago

jancorvus commented 3 years ago

What are you trying to achieve?

Using Playwright helper and having enabled video and trace recording, I want the respective video and trace be recorded and assigned to test.artifacts in case of error/s in Before

What do you get instead?

TypeError: Cannot set property 'video' of undefined
TypeError: Cannot set property 'trace' of undefined

Details

codeceptVersion:  "3.1.2"
nodeInfo:  14.15.3
osInfo:  macOS 11.4
cpuInfo:  (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
chromeInfo:  92.0.4515.159
edgeInfo:  Not Found
firefoxInfo:  Not Found
safariInfo:  14.1.1
helpers:  {
 "Playwright": {
  "url": "http://localhost",
  "browser": "chromium",
  "show": true,
  "fullPageScreenshots": true,
  "restart": true,
  "keepBrowserState": false,
  "keepCookies": false,
  "waitForAction": 1000,
  "waitForTimeout": 1000,
  "manualStart": false,
  "waitForNavigation": "load",
  "pressKeyDelay": 1,
  "video": true,
  "keepVideoForPassedTests": true,
  "recordVideo": {},
  "trace": true,
  "keepTraceForPassedTests": false,
 },
 "ChaiWrapper": {
  "require": "codeceptjs-chai"
 },
 "FileSystem": {},
}
plugins:  {
 "screenshotOnFail": {
  "enabled": true
 },
 "wdio": {
  "enabled": false,
  "services": [
   "selenium-standalone"
  ],
  "seleniumArgs": {
   "drivers": {
    "chrome": {
     "version": "93.0.4577.15"
    },
    "firefox": {
     "version": "0.29.0"
    }
   }
  },
  "seleniumInstallArgs": {
   "baseURL": "https://selenium-release.storage.googleapis.com",
   "drivers": {
    "chrome": {
     "version": "93.0.4577.15"
    },
    "firefox": {
     "version": "0.29.0"
    }
   }
  }
 },
 "retryFailedStep": {
  "enabled": true
 },
 "pauseOnFail": {
  "enabled": false
 },
 "stepByStepReport": {
  "enabled": false,
  "screenshotsForAllureReport": true,
  "ignoreSteps": [
   "wait*"
  ]
 },
 "allure": {
  "enabled": true,
  "outputDir": "allureResults"
 },
 "selenoid": {
  "require": "./plugins/selenoid",
  "enabled": false,
  "deletePassed": true,
  "autoCreate": false,
  "autoStart": false,
  "sessionTimeout": "10m",
  "enableVideo": true,
  "enableLog": true,
  "enableVnc": false,
  "videoScreenSize": "1460x920"
 },
 "autoDelay": {
  "enabled": true
 },
 "tryTo": {
  "enabled": true
 },
 "finalResult": {
  "require": "./plugins/final-result",
  "enabled": true
 },
 "logger": {
  "require": "./plugins/logger",
  "enabled": false
 }
}
DavertMik commented 3 years ago

why do you expect it in Before? video and trace assigned in the end of a test

jancorvus commented 3 years ago

@DavertMik when a browser starts in Before video and trace recording has already started, then when a failure happens, e.g. logging in fails, _failed gets executed and test object does not have artifacts at that moment, so assigning test.artifacts.video and test.artifacts.trace fail