Shadowing Practice: Playwright API Testing with TypeScript (from scratch in 10 minutes) - Learn English Speaking with Video

Kies een oefenmodus

Elke modus opent een volledig scherm oefenruimte.

135 zinnen
Als zinnen te kort of te lang zijn, klik op Bewerken om ze aan te passen.
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

App downloaden

Alles wat je nodig hebt om vloeiend te spreken

AI UitspraakScoor elke zin
IPA OefeningBeheers elk geluid
WoordenschatBouw je woordenschat op
WoordenspelLeren terwijl je speelt
FOR YOU

Aanbevolen Video

Woordenschat en spreektips bij deze les

Deze spreekles is gebaseerd op de video “Playwright API Testing with TypeScript”. Deze woorden komen het vaakst terug: request, test, response, object, example. Deze video bevat 135 zinnen en 1552 woorden om na te spreken. Het gesproken deel duurt 9:54. De spreker praat in een natuurlijk tempo van ongeveer 157 woorden per minuut, dicht bij een alledaags gesprek. 83% van de woorden hoort bij de 3.000 meest gebruikte Engelse woorden; de rest kun je beter vooraf bekijken.

Belangrijke woorden in deze video

15 woorden uit de video die het leren waard zijn, met uitspraak en betekenis:

WoordUitspraakBetekenis
assertion zelfstandig naamwoord/əˈsɜɹʃən/stellige bewering
tag zelfstandig naamwoord/tæɡ/etiket
authorization zelfstandig naamwoord/ˌɔːθəɹaɪˈzeɪʃən/machtiging, volmacht
header zelfstandig naamwoord/ˈhɛdɚ/kop
successfully bijwoord/səkˈsɛs.fə.li/met succes
custom zelfstandig naamwoord/ˈkʌstəm/manieren, gebruiken
pasta zelfstandig naamwoord/ˈpɑ.stə/deegwaren, pasta
folder zelfstandig naamwoord/ˈfoʊldɚ/hechtmap, map
scenario zelfstandig naamwoord/sɪˈnɛəɹioʊ/scenario
install werkwoord/ɪnˈstɔl/installeren, aansluiten
token zelfstandig naamwoord/ˈtoʊkən/teken
validation zelfstandig naamwoord/ˌvæl.əˈdeɪ.ʃən/validering
framework zelfstandig naamwoord/ˈfɹeɪm.wɜːk/geraamte
delete werkwoord/dɪˈliːt/verwijderen
sophisticated bijvoeglijk naamwoordwereldwijs

Phrasal verbs die je zult horen

WoordBetekenis
go back werkwoordteruggaan
come back werkwoordterugkomen

Uitspraak om op te letten

De spreker gebruikt 10 samentrekkingen en verkorte vormen, zoals don't, I'm, I'll. Spreek ze kort uit, zoals je ze hoort.

  • De “th”-klanken: authorization /ˌɔːθəɹaɪˈzeɪʃən/, authorize /ˈɔθəɹaɪz/
  • De klanken “sh” en “zh”: assertion /əˈsɜɹʃən/, authorization /ˌɔːθəɹaɪˈzeɪʃən/, validation /ˌvæl.əˈdeɪ.ʃən/, execution /ˌɛk.sɪˈkjuː.ʃən/, publish /ˈpʌblɪʃ/
  • Lange woorden — let op de klemtoon: 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ɚ/

Klanken die Nederlandstaligen lastig vinden:

  • Stemhebbende eindmedeklinker — /b/, /d/, /g/, /z/, /v/ niet verscherpen: tag /tæɡ/, depend /dɪˈpɛnd/, subscribe /səbˈskɹaɪb/, organize /ˈɔɹɡənaɪz/, payload /ˈpeɪloʊd/
  • /æ/ — opener dan de Nederlandse “e”: tag /tæɡ/, validation /ˌvæl.əˈdeɪ.ʃən/, extract /ˈɛkstɹækt/, parameter /pəˈɹæm.ə.tɚ/, patch /pæt͡ʃ/
  • /g/ — een harde plofklank, geen Nederlandse “g”: tag /tæɡ/, organize /ˈɔɹɡənaɪz/, navigate /ˈnæv.ɪ.ɡeɪt/, configure /kənˈfɪɡə(ɹ)/, getter /ˈɡɛtə(ɹ)/

Zo oefen je met deze video

  1. Luister de hele video één keer zonder te spreken en noteer de woorden die je niet kent.
  2. Begin op 0,75× snelheid, spreek zin voor zin na en ga terug naar normale snelheid zodra het makkelijk gaat.
  3. Neem jezelf op en vergelijk met het origineel; let daarbij op woorden als assertion, tag, authorization.

Wat is de Shadowing-techniek?

Shadowing is een wetenschappelijk onderbouwde taalleermethode die oorspronkelijk is ontwikkeld voor professionele tolkentraining en gepopulariseerd door polyglot Dr. Alexander Arguelles. De methode is eenvoudig maar krachtig: je luistert naar native Engelse audio en herhaalt het onmiddellijk hardop — als een schaduw die de spreker volgt met slechts 1–2 seconden vertraging. In tegenstelling tot passief luisteren of grammaticadrills, dwingt shadowing je hersenen en mondspieren om echte spraakpatronen tegelijkertijd te verwerken en te reproduceren. Onderzoek toont aan dat het de uitspraaknauwkeurigheid, intonatie, ritme, verbonden spraak, luisterbegrip en spreekvaardigheid aanzienlijk verbetert — waardoor het een van de meest effectieve methoden is voor IELTS Speaking-voorbereiding en echte Engelse communicatie.

Shadowing-techniek: lees de volledige stap-voor-stap-gids →