【问题标题】:Playwright: TypeError: Cannot read property 'retry' of undefined剧作家:TypeError:无法读取未定义的属性“重试”
【发布时间】:2022-07-15 21:44:46
【问题描述】:

我目前正在 Playwright 中编写测试。

我注意到控制台中有一个奇怪的输出:

TypeError: Cannot read property 'retry' of undefined

即使所有测试都通过了,我还是得到了这个,这会导致丑陋的额外输出:

这里是debug.log的内容:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/josua/.nvm/versions/node/v12.18.4/bin/node',
1 verbose cli   '/Users/josua/.nvm/versions/node/v12.18.4/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test:run'
1 verbose cli ]
2 info using npm@6.14.6
3 info using node@v12.18.4
4 verbose run-script [ 'pretest:run', 'test:run', 'posttest:run' ]
5 info lifecycle adg-components@0.0.0~pretest:run: adg-components@0.0.0
6 info lifecycle adg-components@0.0.0~test:run: adg-components@0.0.0
7 verbose lifecycle adg-components@0.0.0~test:run: unsafe-perm in lifecycle true
8 verbose lifecycle adg-components@0.0.0~test:run: PATH: /Users/josua/.nvm/versions/node/v12.18.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/josua/Projects/adg-components-ramon/node_modules/.bin:/Users/josua/.rvm/gems/ruby-2.4.10/bin:/Users/josua/.rvm/gems/ruby-2.4.10@global/bin:/Users/josua/.rvm/rubies/ruby-2.4.10/bin:/Users/josua/.nvm/versions/node/v12.18.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Users/josua/.rvm/bin
9 verbose lifecycle adg-components@0.0.0~test:run: CWD: /Users/josua/Projects/adg-components-ramon
10 silly lifecycle adg-components@0.0.0~test:run: Args: [ '-c', 'playwright test' ]
11 silly lifecycle adg-components@0.0.0~test:run: Returned: code: 1  signal: null
12 info lifecycle adg-components@0.0.0~test:run: Failed to exec test:run script
13 verbose stack Error: adg-components@0.0.0 test:run: `playwright test`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/Users/josua/.nvm/versions/node/v12.18.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (/Users/josua/.nvm/versions/node/v12.18.4/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid adg-components@0.0.0
15 verbose cwd /Users/josua/Projects/adg-components-ramon
16 verbose Darwin 21.2.0
17 verbose argv "/Users/josua/.nvm/versions/node/v12.18.4/bin/node" "/Users/josua/.nvm/versions/node/v12.18.4/bin/npm" "run" "test:run"
18 verbose node v12.18.4
19 verbose npm  v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error adg-components@0.0.0 test:run: `playwright test`
22 error Exit status 1
23 error Failed at the adg-components@0.0.0 test:run script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

但在其中找不到对retry 的任何引用。而在我的整个项目中,寻找retry,我只找到了这个:

最让我困惑的是,它只发生在几个测试中:当我将.only 附加到test 时,对某些人来说会发生,对某些人来说不会。但是无法找到这些测试之间的区别:我什至将某些测试的内容从非失败测试复制并粘贴到失败测试(替换失败测试),但它仍然失败。很奇怪。

【问题讨论】:

  • 也许和这个有关,但你不定义我们就不知道了。在 playwright 配置中,您可以选择重试:“重试:”每次测试的最大重试尝试次数。另一方面不确定这是强制性配置。见playwright.dev/docs/test-configuration#testing-options
  • 与此同时,问题奇迹般地消失了。不知道确切的时间和原因。如果它返回,会及时通知您。

标签: playwright


【解决方案1】:

当其中一个设置为 test.only 时,有两个同名的测试可能会导致这种情况

剧作家似乎对此有一个问题。 https://github.com/microsoft/playwright/issues/14034

【讨论】:

    猜你喜欢
    • 2022-01-11
    • 1970-01-01
    • 2021-03-18
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多