From 033852cd169662095592c654747c9ef8ca1c0fd4 Mon Sep 17 00:00:00 2001 From: lironlevy Date: Mon, 4 Jul 2022 12:01:01 +0300 Subject: [PATCH 1/5] Liron --- src/__tests__/screen.js | 9 +++++++++ src/screen.ts | 1 + 2 files changed, 10 insertions(+) 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-test
multi-test
`, diff --git a/src/screen.ts b/src/screen.ts index caae921d..c526d2e8 100644 --- a/src/screen.ts +++ b/src/screen.ts @@ -42,6 +42,7 @@ const logTestingPlaygroundURL = (element = getDocument().body) => { console.log( `Open this URL in your browser\n\n${getPlaygroundUrl(element.innerHTML)}`, ) + return getPlaygroundUrl(element.innerHTML) } const initialValue = {debug, logTestingPlaygroundURL} From 95ccf0a9c85ffc95f869fc9107171512529203d1 Mon Sep 17 00:00:00 2001 From: lironlevy Date: Mon, 4 Jul 2022 12:03:47 +0300 Subject: [PATCH 2/5] Liron --- types/screen.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/screen.d.ts b/types/screen.d.ts index 4013af4a..79998c66 100644 --- a/types/screen.d.ts +++ b/types/screen.d.ts @@ -13,7 +13,7 @@ export type Screen = BoundFunctions & { options?: OptionsReceived, ) => void /** - * Convenience function for `Testing Playground` which logs URL that + * Convenience function for `Testing Playground` which logs & return URL that * can be opened in a browser */ logTestingPlaygroundURL: (element?: Element | HTMLDocument) => void From bbeb1556caf5e6702ca10ae2a566a39f91937eed Mon Sep 17 00:00:00 2001 From: Lirlev48 <58209233+Lirlev48@users.noreply.github.com> Date: Fri, 8 Jul 2022 17:03:49 +0300 Subject: [PATCH 3/5] Update types/screen.d.ts Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> --- types/screen.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/screen.d.ts b/types/screen.d.ts index 79998c66..1615ef35 100644 --- a/types/screen.d.ts +++ b/types/screen.d.ts @@ -13,7 +13,7 @@ export type Screen = BoundFunctions & { options?: OptionsReceived, ) => void /** - * Convenience function for `Testing Playground` which logs & return 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 From 08fba22855e2fc368e6fbfee1e1c87b1a74efbe1 Mon Sep 17 00:00:00 2001 From: Lirlev48 <58209233+Lirlev48@users.noreply.github.com> Date: Fri, 8 Jul 2022 17:04:06 +0300 Subject: [PATCH 4/5] Update types/screen.d.ts Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> --- types/screen.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/screen.d.ts b/types/screen.d.ts index 1615ef35..c2f1b02e 100644 --- a/types/screen.d.ts +++ b/types/screen.d.ts @@ -16,7 +16,7 @@ export type Screen = BoundFunctions & { * 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 From b65431d20ac07a71938371e3bc3445067e20cabe Mon Sep 17 00:00:00 2001 From: lironlevy Date: Sun, 10 Jul 2022 22:21:11 +0300 Subject: [PATCH 5/5] Liron --- src/screen.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/screen.ts b/src/screen.ts index c526d2e8..0b3cc8c8 100644 --- a/src/screen.ts +++ b/src/screen.ts @@ -39,10 +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)}`, - ) - return 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}