Skip to content

fix(plugin): retryTo issue #4117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Playwright Tests with Plugins

on:
push:
branches:
- 3.x
pull_request:
branches:
- '**'

env:
CI: true
# Force terminal colors. @see https://www.npmjs.com/package/colors
FORCE_COLOR: 1

jobs:
build:

runs-on: ubuntu-22.04

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- name: npm install
run: |
npm install --legacy-peer-deps
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: Install browsers and deps
run: npx playwright install && npx playwright install-deps
- name: start a server
run: "php -S 127.0.0.1:8000 -t test/data/app &"
- name: run plugin tests
run: "./bin/codecept.js run -c test/acceptance/codecept.Playwright.retryTo.js --grep @plugin --verbose"
4 changes: 2 additions & 2 deletions lib/plugin/retryTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ module.exports = function (config) {
let err = null;

return new Promise((done) => {
const tryBlock = () => {
const tryBlock = async () => {
recorder.session.start(`retryTo ${tries}`);
callback(tries);
await callback(tries);
recorder.add(() => {
recorder.session.restore(`retryTo ${tries}`);
done(null);
Expand Down
3 changes: 3 additions & 0 deletions test/acceptance/codecept.Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ module.exports.config = {
screenshotOnFail: {
enabled: true,
},
retryTo: {
enabled: true,
},
},
name: 'acceptance',
gherkin: {
Expand Down
44 changes: 44 additions & 0 deletions test/acceptance/codecept.Playwright.retryTo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const TestHelper = require('../support/TestHelper');

module.exports.config = {
tests: './*_test.js',
timeout: 10000,
output: './output',
grep: '@Playwright',
helpers: {
Playwright: {
url: TestHelper.siteUrl(),
show: false,
restart: process.env.BROWSER_RESTART || false,
browser: process.env.BROWSER || 'chromium',
ignoreHTTPSErrors: true,
webkit: {
ignoreHTTPSErrors: true,
},
},
JSONResponse: {
requestHelper: 'Playwright',
},
ScreenshotSessionHelper: {
require: '../support/ScreenshotSessionHelper.js',
outputPath: 'test/acceptance/output',
},
Expect: {},
},
include: {},
bootstrap: false,
mocha: {},
plugins: {
screenshotOnFail: {
enabled: true,
},
retryTo: {
enabled: true,
},
},
name: 'acceptance',
gherkin: {
features: './gherkin/*.feature',
steps: ['./gherkin/steps.js'],
},
};
10 changes: 10 additions & 0 deletions test/acceptance/retryTo_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { I } = inject();

Feature('Plugins');

Scenario('retryTo works with await steps @plugin', async ({ I }) => {
await retryTo(async (tryNum) => {
const foo = await I.grabCurrentUrl();
if (tryNum < 3) I.waitForVisible('.nothing', 1);
}, 4);
});