Rayrun
← Back to Discord Forum

is there a way to pass a variable into `test.step('mystep', async () =>{})`

captainjetskiposted in #help-playwright
Open in Discord
captainjetski
captainjetski

I have a test where I want to pass a variable into a test step. How could I do this?

eg

test('my test', async () => {
    const foo = await api.getFoo();
    test.step('my step - do something with foo' , async () =>{
        // step that uses foo
    })
 
})

This thread is trying to answer question "How can a variable be passed into a test step?"

4 replies
tphillips8117

It should just be available inside the test.step according to JS/TS block scoping rules

tphillips8117

have you tried it?

captainjetski
captainjetski

... it is working now . I swear I tried this yesterday and something went wrong

captainjetski
captainjetski

thanks for the sanity check

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].