Prática de Shadowing: Playwright API Testing with TypeScript (from scratch in 10 minutes) - Aprenda a falar inglês com vídeo

Escolha um modo de prática

Cada modo abre uma sala de prática em tela cheia.

135 frases
Se as frases estiverem muito curtas ou longas, clique em Edit para ajustá-las.
1
You want to automate APIs with Playwright but don't know where to start?
2
So let me show you how to do that.
3
It's actually very simple.
4
So first of all, navigate to nodejs .org, you will need to install Node .js.
5
So click on install
6
Node .js, download it and install on your computer.
7
After that, create a new empty folder anywhere on your computer and open this folder in new terminal.
8
Then run this command in this terminal npm init playwright at latest.
9
After execution of this command just answer everything by default yes
10
so playwright will ask you do you want typescript yes do you want to use test folder yes
11
and so on and so forth just click enter enter enter
12
and after you've done this you will have a sample project generated by the playwright
13
that would look like this open it in visual studio code
14
and you pretty much ready to go
15
so under the test folder you will see example .spec .ts that's the sample test file
16
that you can start with test number one test number two
17
this is the body number one body number two
18
you can see this test is configured to run ui test playwright is using a thing called fixture page fixture
19
so this page fixture is responsible for opening a new browser page
20
and do whatever operations you need on this browser page
21
but for api automation we don't need page so for
22
that we have a different fixture which is called request fixture
23
and with the request fixture you can make api request
24
so using this example let's make a simple simple get request
25
and i will show you how to use this fixture so we don't need page fixture.
26
I just remove it and I remove all this stuff.
27
We don't need it.
28
I'm going to keep this test as our placeholder.
29
So where would you start?
30
Await request dot and then you have methods inside of the request.
31
So if you want to make get request, you call get method.
32
If you want to make post request, you make post method.
33
Patch, put, delete and so on.
34
So let's start with the get request
35
which example we will use for this demonstration here conduit bonder
36
academy let's look into the networking tab for this app
37
and take the very first api request for example for the tags endpoints this is a get request tags endpoint
38
so let's use it as our demo i take the tags
39
and inside of get request i just paste this url that i want to call and that's it
40
Look, if I run it, it's already working.
41
128 milliseconds took to run this single line.
42
So Playwright already sending requests.
43
Now we need to process the response.
44
Then you assign the result to some constant or variable, for example, response equals to.
45
And then from this response, I need to extract the JSON object.
46
So I type const response object equals to await response dot method json.
47
So with the method json, you can get the json object that is coming back.
48
And let's print it out to the console.
49
Console dot log.
50
And I print out the response object and running this test.
51
Running this test.
52
Here we go we have a response object that is printed out and after
53
that we can make the assertions to make assertions in the playwright you can use a built -in assertion library
54
which is expect and we can call our response object
55
that has property tags inside tags and this is the array
56
so i take the first value of array we see it should be a test
57
and i type to equal test and i run this test again
58
and test pass successfully and let's write one more validation for example expect
59
that our response object tags and the amount of text we have 10 values
60
so let's to have for example length of 10.
61
Like this and then running this test again and this test passed successfully.
62
If I mess with this test around and let's say I change to 9
63
and run this test and the test failed expectedly.
64
Look received length 10 but expected length 9.
65
So assertion working successfully and test working successfully.
66
So that's well that's the approach.
67
You basically have three steps in any API test.
68
First you make a request, second you make the extraction of the JSON object with the JSON method
69
and the third step is making the validations of your response.
70
That's basically
71
whole thing about api testing you send request validate response send request validate response that's it
72
and let me show you just one more example
73
this was the very simple get request let me show you how to make a post
74
or put request i copy this thing and for example sample post request
75
so the same thing here we need to change get to post
76
because it will be a post request
77
and let's find in our application example for the post request
78
so I will create a new article let me type any random values right click inspect network publish the article
79
and this is the request
80
for the post request so post request this is the url
81
and now i just simply copying the values inside of our request
82
so this is the post request for the post request we need a payload as well
83
and authorization header because this is authorized request
84
so i need to paste the headers into authorization
85
so where would you put
86
that stuff put the comma over here after the url then start a new object
87
and within this new object you can put different parameters
88
so such as headers this is another object
89
and we will use authorization no let's do this authorization
90
and the value for authorization will be going back this is the token paste the token
91
and then wow that's a huge token okay
92
and then we need to add uh request object
93
and in playwright it's called as data so i paste this object
94
and let me find this payload over here
95
so this is my payload i'm copying it here going back
96
and pasting it right here so i guess that's it so url authorization header,
97
payload that I'm sending to the API and we can send the request.
98
Let me send like test, test will be title for the article, response object.
99
I will remove the assertions because response will be different and we will see the response object that should,
100
at least we should see the response object sending the request and the request was successful.
101
You can see the new article was created.
102
If I go back to the test application, click over here.
103
Here we go.
104
Test test article using API was created.
105
Well guys and that's pretty much it.
106
This is how easy you create your API test in Playwright.
107
You call get, post, put or delete methods depending on operation that you want to do.
108
For the get request it's very very simple.
109
Just send request, validate response, make the assertions for the post request you need maybe headers
110
and data that you send as your payload in the same way.
111
You extract the JSON and then validate the response.
112
You can also chain the commands. For example, we send the post request and then after
113
that we can send get request to validate that the article that was created before is there.
114
But that's more about the scenarios, right?
115
That's not about the scripting anymore.
116
It's more about scenarios.
117
So yeah, it's very, very simple.
118
So if have just a handful of tests to automate, just go with this route, automate those scenarios and you are done.
119
If you need to automate more than that and your application is more sophisticated, you need to generate some test data,
120
make a schema validation and all that fun stuff, you can build some other test frameworks around the Playwright using this approach.
121
And for example, I built my own approach to API testing using Playwright using this approach.
122
For example, you provide path, you provide parameters that way, you make a get request with a custom getter and all that stuff.
123
And then your test would look nicely organized.
124
I have a custom should match schema method to validate the schema
125
and the test looks nicely and more compact and for example random data generator and all that stuff.
126
And here are my custom utils such as schema validator, request handler, custom expect assertion data generator and so on.
127
But again if you need to run just something very simple.
128
Just use built -in tools that isn't playwright.
129
If you need to automate something more complex, you may need to build something more sophisticated like this.
130
If you want to learn how to build the framework like this, check the link in the description below.
131
I have a course where I teach how exactly step -by -step to build this stuff like this.
132
It is a very good training to get an advanced programming skills.
133
All right, so I hope it was helpful.
134
If you have any questions write them down below put the likes
135
and subscribe and I'll see you in the next one

Baixar aplicativo

Tudo o que você precisa para falar fluentemente

Pronúncia com IANota em cada frase
Prática de IPADomine cada som
VocabulárioMonte seu banco de palavras
Jogo de vocabulárioAprenda brincando
FOR YOU

Vídeo recomendado

Vocabulário e dicas de fala para esta lição

Esta aula de conversação usa o vídeo “Playwright API Testing with TypeScript”. As palavras que mais se repetem: request, test, response, object, example. Este vídeo tem 135 frases e 1552 palavras para praticar shadowing. A fala dura 9:54. O falante fala em ritmo natural, cerca de 157 palavras por minuto, próximo de uma conversa do dia a dia. 83% das palavras estão entre as 3.000 mais comuns do inglês; vale a pena estudar o restante antes de começar.

Vocabulário principal deste vídeo

15 palavras do vídeo que vale a pena aprender, com pronúncia e significado:

PalavraPronúnciaSignificado
fixture substantivo/ˈfɪks.t͡ʃə/presença habitual
assertion substantivo/əˈsɜɹʃən/asserção, assertiva
tag substantivo/tæɡ/etiqueta
authorization substantivo/ˌɔːθəɹaɪˈzeɪʃən/autorização
header substantivo/ˈhɛdɚ/cabeçalho
successfully advérbio/səkˈsɛs.fə.li/com sucesso
custom substantivo/ˈkʌstəm/costume, hábito
pasta substantivo/ˈpɑ.stə/massa, macarrão
folder substantivo/ˈfoʊldɚ/pasta
scenario substantivo/sɪˈnɛəɹioʊ/cenário
install verbo/ɪnˈstɔl/instalar
token substantivo/ˈtoʊkən/símbolo, sinal
validation substantivo/ˌvæl.əˈdeɪ.ʃən/validação
terminal substantivo/ˈtɚmɪnəl/terminal
framework substantivo/ˈfɹeɪm.wɜːk/esqueleto, estrutura

Phrasal verbs que você vai ouvir

PalavraSignificado
go back verbovoltar
come back verbovoltar

Pronúncia para ficar de olho

O falante usa 10 contrações e formas reduzidas, como don't, I'm, I'll. Diga-as na forma curta, do jeito que você ouve.

  • Os sons de “th”: authorization /ˌɔːθəɹaɪˈzeɪʃən/, authorize /ˈɔθəɹaɪz/
  • Os sons de “sh” e “zh”: assertion /əˈsɜɹʃən/, authorization /ˌɔːθəɹaɪˈzeɪʃən/, validation /ˌvæl.əˈdeɪ.ʃən/, execution /ˌɛk.sɪˈkjuː.ʃən/, publish /ˈpʌblɪʃ/
  • Palavras longas — acerte a sílaba tônica: authorization /ˌɔːθəɹaɪˈzeɪʃən/, successfully /səkˈsɛs.fə.li/, validation /ˌvæl.əˈdeɪ.ʃən/, generator /ˈdʒɛnəɹeɪtə(ɹ)/, parameter /pəˈɹæm.ə.tɚ/

Sons difíceis para falantes de português:

  • Consoante final — sem acrescentar um “i” depois: tag /tæɡ/, framework /ˈfɹeɪm.wɜːk/, delete /dɪˈliːt/, generate /ˈd͡ʒɛn.ə.ɹeɪt/, extract /ˈɛkstɹækt/
  • /l/ final — a língua toca o céu da boca, não vira “u”: install /ɪnˈstɔl/, terminal /ˈtɚmɪnəl/, console /ˈkɑn.soʊl/, skill /skɪl/, handful /ˈhæn(d)fʊl/
  • /h/ — um sopro suave, diferente do “r”: header /ˈhɛdɚ/, helpful /ˈhɛlp.fl̩/, handful /ˈhæn(d)fʊl/, handler /ˈhænd.lə/, placeholder /ˈpleɪsˌhoʊldɚ/

Como praticar com este vídeo

  1. Ouça o vídeo inteiro uma vez sem falar e anote as palavras que você não conhece.
  2. Comece na velocidade 0,75×, faça shadowing frase por frase e volte à velocidade normal quando ficar fácil.
  3. Grave a sua voz e compare com o original, prestando atenção a palavras como fixture, assertion, tag.

O que é a Técnica de Shadowing?

Shadowing é uma técnica de aprendizado de idiomas com base científica, originalmente desenvolvida para o treinamento de intérpretes profissionais. O método é simples, mas poderoso: você ouve áudio em inglês nativo e repete imediatamente em voz alta — como uma sombra seguindo o falante com 1-2 segundos de atraso. Pesquisas mostram melhora significativa na precisão da pronúncia, entonação, ritmo, sons conectados, compreensão auditiva e fluência na fala.

Técnica de shadowing: leia o guia completo passo a passo →