cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript template litterals don't seems to work

SOLVED
Highlighted
Occasional Contributor

Javascript template litterals don't seems to work

According to documentation, JavaScript language in TC is supporting the template litterals to format strings

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/format.html

 

But even the example shown in the documentation doesn't seems to work.

 

To ensure that I was not in JScript, I created a new project with JavaScript language selected.

 

Then, I created a script function with:

var str = "test";

Log.Message("This is a ${str}");

 

The output is:  This is a ${str}

 

TC version: 14.40.1658

Someone can confirm?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Occasional Contributor

Re: Javascript template litterals don't seems to work

Nevermind... I found the problem: need to replace " by ` for litterals to be taken into account.

 

So: Log.Message(`This is a ${str}`) is working.

 

Thanks a lot!

View solution in original post

2 REPLIES 2
Highlighted
Community Leader

Re: Javascript template litterals don't seems to work

On my TC it works well :

 

function test() {
  const htmlTag = String.raw`test`;
  Log.Message(`${htmlTag}`);
  const htmlTag2 = `test2`;
  Log.Message(`${htmlTag2}`);
  var htmlTag3 = `test3`;
  Log.Message(`${htmlTag3}`);
}

Un sourire et ça repart

Highlighted
Occasional Contributor

Re: Javascript template litterals don't seems to work

Nevermind... I found the problem: need to replace " by ` for litterals to be taken into account.

 

So: Log.Message(`This is a ${str}`) is working.

 

Thanks a lot!

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors