Skip to content
← Back to activity

Immutable solution version

[Regression]: Can't call test.use() inside a describe() suite of a different test

Version 1Sign in to save

Complete solution

A practical guide for Playwright. Playwright 1.42 turned mixing test instances into an error: 'Can't call test.use() inside a describe() suite of a different test type'. This was an intentional change (documented as a breaking change after the report).

The problem

Issue microsoft/playwright#29734 (closed, 58 comments): ### Last Good Version 1.41.2 ### First Bad Version 1.42.0 ### Steps to reproduce After updating to playwright 1.42, I get this message about one of my test files which was fine in 1.41.2: `` Can't call test.use() inside a describe() suite of a different test type. Make sure to use the same "test" function (created by the test.extend() call) for all declarations inside a suite.playwright `` To reproduce, just have describe blocks with extend/use inside of them.

The fix

Playwright 1.42 turned mixing test instances into an error: 'Can't call test.use() inside a describe() suite of a different test type'. This was an intentional change (documented as a breaking change after the report). Fix: use the same test function created by your test.extend() call for everything inside a suite, instead of nesting different test instances in one describe block.

Notes

Thread: https://github.com/microsoft/playwright/issues/29734. Verified against the closed issue and the maintainer/accepted answer there.

Evidence

In https://github.com/microsoft/playwright/issues/29734, the reporter asked: Issue microsoft/playwright#29734 (closed, 58 comments): ### Last Good Version 1.41.2 ### First Bad Version 1.42.0 ### Steps to reproduce After updating to playwright 1.42, I get this message about one of my test files which was fine in 1.41.2: `` Can't call test.use() inside a describe() suite of a different test type. Make sure to use the same "test" function (created by the test.extend() call) for all declarations inside a suite.playwright `` To reproduce, just have describe blocks with extend/use inside of them. The verified answer: Playwright 1.42 turned mixing test instances into an error: 'Can't call test.use() inside a describe() suite of a different test type'. This was an intentional change (documented as a breaking change after the report). Fix: use the same test function created by your test.extend() call for everything inside a suite, instead of nesting different test instances in one describe block. Source thread: https://github.com/microsoft/playwright/issues/29734

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_OXAEJcHnUq9lZjyRHAQLbA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">[Regression]: Can&#39;t call test.use() inside a describe() suite of a different test <span>— Vectle</span></a>