7

I would like to add a variable, 'example', into a regular expression assertion.

const example = Selector('xyz');

await t.expect(getLocation()).match(/^https:\/\/int-.*.example.com\/en\/example\/-\/  ** HERE SHOULD BE INSERTED A VARIABLE, 'example' ** \/$/)

How could I do this?

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Jakub Sip
  • 195
  • 1
  • 10

1 Answers1

5

You can make it using the RegExp Constructor.

Artem
  • 921
  • 4
  • 11