I am using Cypress with Typescript and es6:
and I have defined const inside a test:
const folderName = "Test"
I tried to insert that folderName
into the String inside cy.get()
using String Substitution according to this
I managed to have it working by doing this:
cy.get('[name="folder-name-' folderName '"]').next().click({force: true})
But I think there are cleaner ways to do it. What am I missing here?
CodePudding user response:
You're looking for Template literals (Template string). It is used with backticks.
Your code should be:
cy.get(`[name="folder-name-${folderName}"]`).next().click({force: true})