Closed
Description
What are you trying to achieve?
If I open a new session during the session, Playwright does not respect the device emulation setting.

Here's the repository to reproduce the issue: https://github.com/tsuemura/codeceptjs-playwright-device-bug-reproduction
What do you get instead?
Provide console output if related. Use
--verbose
mode for more details.
$ npm install
$ npx codeceptjs run
CodeceptJS v3.5.11 #StandWithUkraine
Using test root "/Users/takuyasuemura/ghq/github.com/tsuemura/codeceptjs-playwright-device-bug-reproduction"
Repro --
sessionScreen is {"width":1280,"height":720}
✖ Reproduce issue in 2433ms
-- FAILURES:
1) Repro
Reproduce issue:
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
assert(sessionScreen.width === 375)
+ expected - actual
-false
+true
Artifacts:
- screenshot: /Users/takuyasuemura/ghq/github.com/tsuemura/codeceptjs-playwright-device-bug-reproduction/output/Reproduce_issue.failed.png
FAIL | 0 passed, 1 failed // 3s
Run with --verbose flag to see complete NodeJS stacktrace
Provide test source code if related
Test code
const assert = require('assert/strict')
Feature('Repro')
Scenario('Reproduce issue', async ({ I }) => {
I.amOnPage('https://example.com')
session('user1', async () => {
I.amOnPage('https://www.google.com')
const sessionScreen = await I.executeScript(() => {
return { width: window.screen.width, height: window.screen.height };
})
console.log(`sessionScreen is ${JSON.stringify(sessionScreen)}`)
// iPhone 6 is 375x667
assert(sessionScreen.width === 375)
assert(sessionScreen.height === 667)
})
})
Details
- CodeceptJS version: "3.5.11"
- NodeJS Version: v18.15.0
- Operating System: MacOS Ventura 13.3.1
- puppeteer || webdriverio || testcafe version (if related): Playwright 1.40.1
- Configuration file:
codecept.conf.js
const { setHeadlessWhen, setCommonPlugins } = require("@codeceptjs/configure");
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();
const { devices } = require("playwright");
/** @type {CodeceptJS.MainConfig} */
exports.config = {
tests: "./*_test.js",
output: "./output",
helpers: {
Playwright: {
browser: "chromium",
url: "http://localhost",
show: true,
emulate: devices["iPhone 6"],
},
},
include: {
I: "./steps_file.js",
},
name: "codeceptjs-playwright-device-bug-reproduction",
};