S
S
studentLesson2021-09-13 13:15:23
JavaScript
studentLesson, 2021-09-13 13:15:23

How to solve puppeteer and typescript friendship problem?

Good afternoon! Maybe someone has come across a similar one: There are tests written in puppeteerand there is a certain binding module over the usual "typograf"one (npm and typograf), which is written in Typescript. I want to connect a typographer to the tests, but puppeteerin the console it swears at a function written in TS.
Function:

declare function T(strings: TemplateStringsArray, ...args: any[]): string;


If you use a typographer in any test, for example like this:
T`Проверьте имя`,
then I get an error
ReferenceError: T is not defined

Maybe someone added some additional config or set something extra? Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-09-14
@studentLesson

It seems that your babel is crooked.
Here is a description of the plugin used - it should remove the T-function after assembly, which obviously did not happen.

// Source string
T`Formatted "string".  `;

// Typografed string
// Tagged template with tag `T` is converted to a regular template literal
`Formatted “string”.`;

Dig the config so that when you run the tests, Babel first goes through them, and then the processed tests run.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question