codeceptjs / codeceptjs/CodeceptJS

Puppeteer: Error " Failed to read the 'localStorage' property" when restart is set to false

未关闭
#1,480 0 条评论 5 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
4.2k
派生
757
平均合并
2 天 9 小时
30 天内合并 PR
16

描述

#### What are you trying to achieve?

The following test triggers an error message in the after each hook and incorrectly reports two failed tests when in fact there is only one test.

Feature('Bug')
/**
* Given I have the following config with the Puppeteer helper
*
* Puppeteer: {
* ...
* restart: false
* ...
* }
*
* When the test throws an error before interacting with the browser
* Then I get this error message
*
* 2) Bug
* "after each" hook: finalize codeceptjs for "Throw error before interacting with the browser":
* Evaluation failed: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
* at __puppeteer_evaluation_script__:1:1
*
*/
Scenario('Throw error before interacting with the browser', (I) => {
throw new Error('Boom')
})

#### What do you get instead?

> CodeceptJS v2.0.4
> Using test root "C:\Users\stefan.huber\veve\codeceptjs-todomvc"
> Helpers: Puppeteer
> Plugins: screenshotOnFail
>
> Bug --
> [1] Starting recording promises
> Emitted | suite.before ([object Object])
> » [Session] Starting singleton browser session
> Throw error before interacting with the browser
> Emitted | test.before ([object Object])
> Emitted | test.start ([object Object])
> [1] Error | Error: Boom
> [1] Starting session
> Emitted | test.failed ([object Object])
> Emitted | test.finish ([object Object])
> [1] Stopping recording promises
> » Test failed, saving screenshot
> » Screenshot is saving to C:\Users\stefan.huber\veve\codeceptjs-todomvc\__out\Throw_error_before_interacting_with_the_browser.failed.png
> × FAILED in 1169ms
>
> [2] Starting recording promises
> Emitted | test.after ([object Object])
> » [Session] cleaning cookies and localStorage
> [2] Error | Error: Evaluation failed: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
> at __puppeteer_evaluation_script__:1:1
> Emitted | test.failed ([object Object])
> × "after each" hook: finalize codeceptjs for "Throw error before interacting with the browser" in 8ms
> [2] Error | Error: Evaluation failed: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
> at __puppeteer_evaluation_script__:1:1
> Error: Evaluation failed: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
> at __puppeteer_evaluation_script__:1:1
> Emitted | suite.after ([object Object])
>
> -- FAILURES:
>
> 1) Bug
> Throw error before interacting with the browser:
> Boom
> rror: Boom
> at Test.Scenario (tests\error-in-after.test.js:21:9)
> at Context.test.fn (node_modules\codeceptjs\lib\scenario.js:76:14)
>
> 2) Bug
> "after each" hook: finalize codeceptjs for "Throw error before interacting with the browser":
> Evaluation failed: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
> at __puppeteer_evaluation_script__:1:1
> rror: Evaluation failed: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
> at __puppeteer_evaluation_script__:1:1
> at ExecutionContext.evaluateHandle (node_modules\puppeteer\lib\ExecutionContext.js:80:15)
> at
> at process._tickCallback (internal/process/next_tick.js:188:7)
> -- ASYNC --
> at ExecutionContext. (node_modules\puppeteer\lib\helper.js:108:27)
> at ExecutionContext.evaluate (node_modules\puppeteer\lib\ExecutionContext.js:48:31)
> at ExecutionContext. (node_modules\puppeteer\lib\helper.js:109:23)
> at DOMWorld.evaluate (node_modules\puppeteer\lib\DOMWorld.js:105:20)
> at
> at process._tickCallback (internal/process/next_tick.js:188:7)
> -- ASYNC --
> at Frame. (node_modules\puppeteer\lib\helper.js:108:27)
> at Page.evaluate (node_modules\puppeteer\lib\Page.js:815:43)
> at Page. (node_modules\puppeteer\lib\helper.js:109:23)
> at Puppeteer.executeScript (node_modules\codeceptjs\lib\helper\Puppeteer.js:1197:29)
> at Puppeteer._after (node_modules\codeceptjs\lib\helper\Puppeteer.js:231:16)
> at
> at process._tickCallback (internal/process/next_tick.js:188:7)
>
>
> FAIL | 0 passed, 2 failed // 2s
> Emitted | global.result ([object Object])
> Emitted | global.after ([object Object])
>

```bash
# paste output here
```

> Provide test source code if related

```js
// paste test
```

### Details

* CodeceptJS version: 2.0.4
* NodeJS Version: > 8
* Operating System: Windows
* Puppeteer

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。