I am using jasmine for testing JavaScript code.
I would like to check the content of render function in this way:
expect(this.view.el.innerHTML).toContain('<a href="#link">'+ 'regexp(any text)' +'</a>');
would be possible to pass some parameter as a regular expression?
If yes, how?
I am using jasmine for testing JavaScript code.
I would like to check the content of render function in this way:
expect(this.view.el.innerHTML).toContain('<a href="#link">'+ 'regexp(any text)' +'</a>');
would be possible to pass some parameter as a regular expression?
If yes, how?
1 Answer
Reset to default 7I think you would need to use the toMatch
matcher which takes a regular expression (toContain
expects a string parameter) and build your regular expression by concatenating the fixed and variable strings something like this:
var searchString = ...
expect(innerHTML).toMatch(new RegExp('<a href="#link">' + searchString + '</a>'));