Pratica di Shadowing: Playwright API Testing with TypeScript (from scratch in 10 minutes) - Impara a parlare inglese con i video

Scegli una modalità di pratica

Ogni modalità apre una sala di pratica a schermo intero.

135 frasi
Se le frasi sono troppo corte o troppo lunghe, clicca su Edit per modificarle.
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

Scarica l'app

Tutto ciò che serve per parlare fluentemente

Pronuncia con IAVoto per ogni frase
Pratica IPAPadroneggia ogni suono
VocabolarioCostruisci il tuo lessico
Gioco di vocabolarioImpara giocando
FOR YOU

Video consigliato

Vocabolario e note di pronuncia per questa lezione

Questa lezione di conversazione si basa sul video “Playwright API Testing with TypeScript”. Le parole che ritornano più spesso: request, test, response, object, example. Questo video contiene 135 frasi e 1552 parole da ripetere con lo shadowing. Il parlato dura 9:54. Chi parla ha un ritmo naturale di circa 157 parole al minuto, vicino a una conversazione quotidiana. Il 83% delle parole rientra nelle 3.000 più comuni dell’inglese; conviene studiare le altre prima di iniziare.

Vocaboli chiave di questo video

15 parole del video che vale la pena imparare, con pronuncia e significato:

ParolaPronunciaSignificato
assertion sostantivo/əˈsɜɹʃən/asserzione, affermazione
tag sostantivo/tæɡ/etichetta
authorization sostantivo/ˌɔːθəɹaɪˈzeɪʃən/autorizzazione
header sostantivo/ˈhɛdɚ/intestazione
successfully avverbio/səkˈsɛs.fə.li/con successo
custom sostantivo/ˈkʌstəm/usanza, costume
pasta sostantivo/ˈpɑ.stə/pasta, impasto
folder sostantivo/ˈfoʊldɚ/cartella, fascicolo
scenario sostantivo/sɪˈnɛəɹioʊ/scenario, panorama
install verbo/ɪnˈstɔl/installare
token sostantivo/ˈtoʊkən/simbolo, segno
validation sostantivo/ˌvæl.əˈdeɪ.ʃən/validazione
terminal sostantivo/ˈtɚmɪnəl/terminal, terminale
framework sostantivo/ˈfɹeɪm.wɜːk/struttura portante
delete verbo/dɪˈliːt/cancellare, eliminare

I phrasal verb che sentirai

ParolaSignificato
go back verbotornare
come back verbotornare

Pronuncia a cui fare attenzione

Chi parla usa 10 contrazioni e forme ridotte, come don't, I'm, I'll. Pronunciale nella forma breve, così come le senti.

  • I suoni “th”: authorization /ˌɔːθəɹaɪˈzeɪʃən/, authorize /ˈɔθəɹaɪz/
  • I suoni “sh” e “zh”: assertion /əˈsɜɹʃən/, authorization /ˌɔːθəɹaɪˈzeɪʃən/, validation /ˌvæl.əˈdeɪ.ʃən/, execution /ˌɛk.sɪˈkjuː.ʃən/, publish /ˈpʌblɪʃ/
  • Parole lunghe — attenzione all’accento: 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ɚ/

I suoni difficili per chi parla italiano:

  • /h/ — va soffiata, non è muta: header /ˈhɛdɚ/, helpful /ˈhɛlp.fl̩/, handful /ˈhæn(d)fʊl/, handler /ˈhænd.lə/, placeholder /ˈpleɪsˌhoʊldɚ/
  • Consonante finale — senza aggiungere una vocale dopo: tag /tæɡ/, framework /ˈfɹeɪm.wɜːk/, delete /dɪˈliːt/, generate /ˈd͡ʒɛn.ə.ɹeɪt/, extract /ˈɛkstɹækt/
  • /æ/ — più aperta della “e”: tag /tæɡ/, validation /ˌvæl.əˈdeɪ.ʃən/, extract /ˈɛkstɹækt/, parameter /pəˈɹæm.ə.tɚ/, patch /pæt͡ʃ/

Come esercitarsi con questo video

  1. Ascolta tutto il video una volta senza parlare e annota le parole che non conosci.
  2. Inizia a velocità 0,75×, fai shadowing frase per frase e torna alla velocità normale quando diventa facile.
  3. Registrati e confronta con l’originale, facendo attenzione a parole come assertion, tag, authorization.

Cos'è la tecnica dello Shadowing?

Shadowing è una tecnica di apprendimento delle lingue supportata da studi scientifici, originariamente sviluppata per la formazione dei traduttori professionisti e resa popolare dal poliglotta Dr. Alexander Arguelles. Il metodo è semplice ma potente: ascolti un audio in inglese di madrelingua e lo ripeti immediatamente ad alta voce — come un'ombra che segue il parlante con un ritardo di solo 1–2 secondi. A differenza dell'ascolto passivo o degli esercizi di grammatica, lo shadowing costringe il tuo cervello e i muscoli della bocca a elaborare e riprodurre simultaneamente i modelli di discorso reale. La ricerca dimostra che migliora significativamente la precisione della pronuncia, l'intonazione, il ritmo, il discorso connesso, la comprensione dell'ascolto e la fluidità del parlato — rendendolo uno dei metodi più efficaci per la preparazione alla prova di speaking dell'IELTS e per la comunicazione reale in inglese.

Tecnica dello shadowing: leggi la guida completa passo dopo passo →