Puppeteer fails subsequent tests if beforeunload popup shown
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- testing
Research direction
Reproduce the restart:false scenario from the provided HTML and JavaScript snippets, then inspect lib/helper/Puppeteer.js around the dialog handling reported at line 483 and lib/listener/steps.js around line 55. Verify that a beforeunload popup does not break the following test or cause duplicate completion errors, and confirm the run reports the correct failure status.
Written by the indexing model from the issue text.
Description
What are you trying to achieve?
When testing a page which shows a popup on unload (beforeunload event), CodeceptJS fails if restart: false is set.
The issue is not present when restart: true is set.
Additionally, process exits with code 0, indicating a success.
I couldn't successfully accept the popup, and I tried at the end of the first test, at the beginning on the second test, and in _before handler.
Example project: https://github.com/dejanceltra/codeceptjs-popup-issue
CodeceptJS run: https://github.com/dejanceltra/codeceptjs-popup-issue/runs/3836071868
What do you get instead?
npx codeceptjs run
shell: /usr/bin/bash -e {0}
creating output directory: /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/output
CodeceptJS v3.1.3
Using test root "/home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue"
test --
✔ test something in 133ms
Popup already exists and was not closed. Popups must always be closed by calling either I.acceptPopup() or I.cancelPopup()
✖ test something 2 in 109ms
Error processing test.passed event:
TypeError: Cannot convert undefined or null to object
at EventEmitter.<anonymous> (/home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/listener/steps.js:55:5)
at EventEmitter.emit (node:events:402:35)
at Object.emit (/home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/event.js:145:28)
at /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/scenario.js:96:15
✖ test something 2 in 109ms
-- FAILURES:
1) test
test something 2:
Uncaught Cannot accept dialog which is already handled!
at Object.assert (node_modules/puppeteer/lib/cjs/puppeteer/common/assert.js:26:15)
at Dialog.accept (node_modules/puppeteer/lib/cjs/puppeteer/common/Dialog.js:79:21)
at /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/helper/Puppeteer.js:483:25
Scenario Steps:
- I.amOnPage("https://example.com") at Test.<anonymous> (./test_test.js:9:7)
2) test
test something 2:
Error: done() called multiple times in test <test: test something 2> of file /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/test_test.js
at /home/runner/work/codeceptjs-popup-issue/codeceptjs-popup-issue/node_modules/codeceptjs/lib/scenario.js:99:41
FAIL | 1 passed, 2 failed // 1s
Run with --verbose flag to see complete NodeJS stacktrace
Provide test source code if related
<script>
window.addEventListener("beforeunload", function(event) {
event.returnValue = "message";
});
</script>
Feature('test');
Scenario('test something', ({ I }) => {
I.amOnPage(`file://${process.cwd()}/test.html`);
});
Scenario('test something 2', ({ I }) => {
I.amOnPage('https://example.com');
});
Details
- CodeceptJS version: 3.1.2
- NodeJS Version: v16.9.1
- Operating System: macOS | Linux
- puppeteer: 10.4.0
- Configuration file:
const { setHeadlessWhen } = require('@codeceptjs/configure');
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
Puppeteer: {
restart: false,
url: 'http://localhost',
show: false,
windowSize: '1200x900'
}
},
bootstrap: null,
mocha: {},
name: 'puppeteer-test',
plugins: {
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
tryTo: {
enabled: true
},
screenshotOnFail: {
enabled: true
}
}
}
- Dominant language
- JavaScript
- Stars
- 4.2k
- Forks
- 756
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 16
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from codeceptjs/CodeceptJS
-
stale
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
codeceptjs/CodeceptJS#5420 · 1 comment ·
-
stale
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
codeceptjs/CodeceptJS#5358 · 1 comment ·
-
stale
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
codeceptjs/CodeceptJS#4958 · 10 comments · 2 reactions ·
-
stale
Difficulty 1/5 Under an hour Newbie friendliness 72/100
codeceptjs/CodeceptJS#4778 · 3 comments ·
-
stale
Difficulty 4/5 3-5 days Newbie friendliness 38/100
codeceptjs/CodeceptJS#5618 · 1 comment ·
All issues in codeceptjs/CodeceptJS
Similar issues
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Automattic/safe-publish#594 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
NousResearch/hermes-agent#121143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100