From 7e3288f4cf13a0d9f15bcfc01daa00f85de437ed Mon Sep 17 00:00:00 2001 From: Ben Scott <227292+BPScott@users.noreply.github.com> Date: Tue, 9 Sep 2025 20:22:31 -0700 Subject: [PATCH] Add extra playwright test functions (#17876) --- changelog_unreleased/javascript/17876.md | 57 +++++++++++++++++++ src/language-js/utils/index.js | 3 + .../__snapshots__/format.test.js.snap | 28 +++++++++ .../js/test-declarations/test_declarations.js | 6 ++ 4 files changed, 94 insertions(+) create mode 100644 changelog_unreleased/javascript/17876.md diff --git a/changelog_unreleased/javascript/17876.md b/changelog_unreleased/javascript/17876.md new file mode 100644 index 000000000..fb80c2c53 --- /dev/null +++ b/changelog_unreleased/javascript/17876.md @@ -0,0 +1,57 @@ +#### Add additional Playwright test functions (#17876 by @BPScott) + +Prettier already avoids changing indentation for test functions when you add `.skip` to +them. It now also treats the Playwright functions [`test.fixme`](https://playwright.dev/docs/api/class-test#test-fixme), [`test.describe.skip`](https://playwright.dev/docs/api/class-test#test-describe-skip) and [`test.describe.fixme`](https://playwright.dev/docs/api/class-test#test-describe-fixme) similar to `test.skip`. + + +```js +// Input +test.fixme("does something really long and complicated so I have to write a very long name for the test", () => { + // code +}); + +test.describe.skip("does something really long and complicated so I have to write a very long name for the test", () => { + // code +}); + +test.describe.fixme("does something really long and complicated so I have to write a very long name for the test", () => { + // code +}); + +// Prettier stable +test.fixme( + "does something really long and complicated so I have to write a very long name for the test", + () => { + // code + }, +); + +test.describe.skip( + "does something really long and complicated so I have to write a very long name for the test", + () => { + // code + }, +); + +test.describe.fixme( + "does something really long and complicated so I have to write a very long name for the test", + () => { + // code + }, +); + +// Prettier main +test.fixme("does something really long and complicated so I have to write a very long name for the test", () => { + // code +}); + +test.describe + .skip("does something really long and complicated so I have to write a very long name for the test", () => { + // code +}); + +test.describe + .fixme("does something really long and complicated so I have to write a very long name for the test", () => { + // code +}); +``` diff --git a/src/language-js/utils/index.js b/src/language-js/utils/index.js index 82df3365d..69853eb22 100644 --- a/src/language-js/utils/index.js +++ b/src/language-js/utils/index.js @@ -331,9 +331,12 @@ const testCallCalleePatterns = [ "test", "test.only", "test.skip", + "test.fixme", "test.step", "test.describe", "test.describe.only", + "test.describe.skip", + "test.describe.fixme", "test.describe.parallel", "test.describe.parallel.only", "test.describe.serial", diff --git a/tests/format/js/test-declarations/__snapshots__/format.test.js.snap b/tests/format/js/test-declarations/__snapshots__/format.test.js.snap index 6e41e9850..fd2757072 100644 --- a/tests/format/js/test-declarations/__snapshots__/format.test.js.snap +++ b/tests/format/js/test-declarations/__snapshots__/format.test.js.snap @@ -1031,6 +1031,8 @@ test.only(\`does something really long and complicated so I have to write a very test.skip(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); +test.fixme(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); + ftest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); xtest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); @@ -1049,6 +1051,10 @@ test.describe(\`does something really long and complicated so I have to write a test.describe.only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.skip("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.fixme("does something really long and complicated so I have to write a very long name for the test", () => {}); + test.describe.only(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); test.describe.parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); @@ -1195,6 +1201,8 @@ test.only(\`does something really long and complicated so I have to write a very test.skip(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); +test.fixme(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); + ftest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); xtest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); @@ -1214,6 +1222,12 @@ test.describe(\`does something really long and complicated so I have to write a test.describe .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe + .skip("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe + .fixme("does something really long and complicated so I have to write a very long name for the test", () => {}); + test.describe .only(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); @@ -1400,6 +1414,8 @@ test.only(\`does something really long and complicated so I have to write a very test.skip(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); +test.fixme(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); + ftest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); xtest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); @@ -1418,6 +1434,10 @@ test.describe(\`does something really long and complicated so I have to write a test.describe.only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.skip("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.fixme("does something really long and complicated so I have to write a very long name for the test", () => {}); + test.describe.only(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); test.describe.parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); @@ -1564,6 +1584,8 @@ test.only(\`does something really long and complicated so I have to write a very test.skip(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); +test.fixme(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); + ftest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); xtest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); @@ -1583,6 +1605,12 @@ test.describe(\`does something really long and complicated so I have to write a test.describe .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe + .skip("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe + .fixme("does something really long and complicated so I have to write a very long name for the test", () => {}); + test.describe .only(\`does something really long and complicated so I have to write a very long name for the test\`, () => {}); diff --git a/tests/format/js/test-declarations/test_declarations.js b/tests/format/js/test-declarations/test_declarations.js index 23dfd4234..5e02fc0cd 100644 --- a/tests/format/js/test-declarations/test_declarations.js +++ b/tests/format/js/test-declarations/test_declarations.js @@ -77,6 +77,8 @@ test.only(`does something really long and complicated so I have to write a very test.skip(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.fixme(`does something really long and complicated so I have to write a very long name for the test`, () => {}); + ftest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); xtest("does something really long and complicated so I have to write a very long name for the describe block", () => {}); @@ -95,6 +97,10 @@ test.describe(`does something really long and complicated so I have to write a v test.describe.only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.skip("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.fixme("does something really long and complicated so I have to write a very long name for the test", () => {}); + test.describe.only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); test.describe.parallel("does something really long and complicated so I have to write a very long name for the test", () => {});