diff --git a/.all-contributorsrc b/.all-contributorsrc
index be8f4582..bc6ef6b4 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -1544,6 +1544,15 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "Lirlev48",
+ "name": "Lirlev48",
+ "avatar_url": "https://avatars.githubusercontent.com/u/58209233?v=4",
+ "profile": "https://github.com/Lirlev48",
+ "contributions": [
+ "code"
+ ]
}
],
"repoHost": "https://github.com/"
diff --git a/README.md b/README.md
index 950c7941..377ff7d5 100644
--- a/README.md
+++ b/README.md
@@ -334,6 +334,7 @@ Thanks goes to these people ([emoji key][emojis]):
 Jackson Hardaker ⚠️ |
 Robin Drexler 💻 |
 Omer Dolev 💻 |
+  Lirlev48 💻 |
diff --git a/src/__tests__/screen.js b/src/__tests__/screen.js
index 2fbe0970..7c57de4a 100644
--- a/src/__tests__/screen.js
+++ b/src/__tests__/screen.js
@@ -64,6 +64,15 @@ test('logs Playground URL that are passed as element', () => {
`)
})
+test('returns Playground URL that are passed as element', () => {
+ const playGroundUrl = screen.logTestingPlaygroundURL(
+ render(`Sign up
`).container,
+ )
+ expect(playGroundUrl).toMatchInlineSnapshot(
+ 'https://testing-playground.com/#markup=DwCwjAfAyglg5gOwATAKYFsIFcAOwD0GEB4EQA',
+ )
+})
+
test('exposes debug method', () => {
renderIntoDocument(
`multi-testmulti-test
`,
diff --git a/src/screen.ts b/src/screen.ts
index caae921d..0b3cc8c8 100644
--- a/src/screen.ts
+++ b/src/screen.ts
@@ -39,9 +39,9 @@ const logTestingPlaygroundURL = (element = getDocument().body) => {
console.log(`The provided element doesn't have any children.`)
return
}
- console.log(
- `Open this URL in your browser\n\n${getPlaygroundUrl(element.innerHTML)}`,
- )
+ const playgroundUrl = getPlaygroundUrl(element.innerHTML)
+ console.log(`Open this URL in your browser\n\n${playgroundUrl}`)
+ return playgroundUrl
}
const initialValue = {debug, logTestingPlaygroundURL}
diff --git a/types/screen.d.ts b/types/screen.d.ts
index 4013af4a..c2f1b02e 100644
--- a/types/screen.d.ts
+++ b/types/screen.d.ts
@@ -13,10 +13,10 @@ export type Screen = BoundFunctions & {
options?: OptionsReceived,
) => void
/**
- * Convenience function for `Testing Playground` which logs URL that
+ * Convenience function for `Testing Playground` which logs and returns the URL that
* can be opened in a browser
*/
- logTestingPlaygroundURL: (element?: Element | HTMLDocument) => void
+ logTestingPlaygroundURL: (element?: Element | HTMLDocument) => string
}
export const screen: Screen