You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The testing libraries used in part 5 were changed 3rd March 2024. In frontend Vite replaced Jest. For End to end-tests Playwright is the new preferred library.
50
+
</p>
48
51
<p>
49
-
The testing library used in part 4 was changed 13th February 2024 from Jest to Node:test.
50
-
If you have started with Jest, you may continue. The relevant material is still available, see the "Legacy: testing with Jest"
52
+
If you have started with Jest or Cypress, you may continue. The relevant material is still available, for Jest, the link is at the top of part 5c and for the Cypress, the link is at the menu at the left.
Copy file name to clipboardExpand all lines: src/content/5/en/part5e.md
+3-12Lines changed: 3 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ E2E library [Cypress](https://www.cypress.io/) has become popular within the las
17
17
18
18
Let's make some end-to-end tests for our note application.
19
19
20
-
We begin by installing Cypress to <i>the frontend</i> as a development dependency
20
+
Unlike the backend tests or unit tests done on the React front-end, End to End tests do not need to be located in the same npm project where the code is. Let's make a completely separate project for the E2E tests with the _npm init_ command. Then install Cypress to <i>the new project</i> as a development dependency
21
21
22
22
```js
23
23
npm install --save-dev cypress
@@ -29,12 +29,6 @@ and by adding an npm-script to run it:
@@ -532,8 +526,6 @@ The first command searches for a component containing the text <i>another note c
532
526
533
527
The second command checks that the text on the button has changed to <i>make important</i>.
534
528
535
-
The tests and the current frontend code can be found on the [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-9) branch <i>part5-9</i>.
536
-
537
529
### Failed login test
538
530
539
531
Let's make a test to ensure that a login attempt fails if the password is wrong.
@@ -1056,8 +1048,7 @@ You can see the HTTP requests done by the tests on the Network tab, and the cons
1056
1048
1057
1049

1058
1050
1059
-
So far we have run our Cypress tests using the graphical test runner.
1060
-
It is also possible to run them [from the command line](https://docs.cypress.io/guides/guides/command-line.html). We just have to add an npm script for it:
1051
+
So far we have run our Cypress tests using the graphical test runner. It is also possible to run them [from the command line](https://docs.cypress.io/guides/guides/command-line.html). We just have to add an npm script for it:
1061
1052
1062
1053
```js
1063
1054
"scripts": {
@@ -1072,7 +1063,7 @@ Now we can run our tests from the command line with the command <i>npm run test:
1072
1063
1073
1064
Note that videos of the test execution will be saved to <i>cypress/videos/</i>, so you should probably git ignore this directory. It is also possible to [turn off](https://docs.cypress.io/guides/guides/screenshots-and-videos#Videos) the making of videos.
1074
1065
1075
-
Tests are found in [GitHubissa](https://github.com/fullstack-hy2020/notes-e2e-cypress/).
1066
+
Tests are found in [GitHub](https://github.com/fullstack-hy2020/notes-e2e-cypress/).
1076
1067
1077
1068
Final version of the frontend code can be found on the [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-9) branch <i>part5-9</i>.
Copy file name to clipboardExpand all lines: src/content/5/fi/osa5d.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,27 +7,27 @@ lang: fi
7
7
8
8
<divclass="content">
9
9
10
-
We have done integration tests for the backend that test it as a whole at the app level, and unit tests for the frontend that test individual components.
10
+
Olemme tehneet backendille sitä apin tasolla kokonaisuutena testaavia integraatiotestejä ja frontendille yksittäisiä komponentteja testaavia yksikkötestejä.
11
11
12
-
Now let's look at one way of doing <i>End to End (E2E) tests</i> on [the system as a whole](https://en.wikipedia.org/wiki/System_testing).
12
+
Katsotaan nyt erästä tapaa tehdä [järjestelmää kokonaisuutena](https://en.wikipedia.org/wiki/System_testing) tutkivia <i>End to End (E2E) ‑testejä</i>.
13
13
14
-
E2E testing of web applications takes place using a browser with the help of a library. There are several solutions available, for example [Selenium](http://www.seleniumhq.org/), which enables the automation of tests with almost any browser. Another option is to use the so-called [headless browser](https://en.wikipedia.org/wiki/Headless_browser)i.e. a browser that has no graphical user interface at all. For example, it is possible to run Chrome in Headless mode.
14
+
Web-sovellusten E2E-testaus tapahtuu käyttäen selainta jonkin kirjaston avulla. Ratkaisuja on tarjolla useita, esimerkiksi [Selenium](http://www.seleniumhq.org/), joka mahdollistaa testien automatisoinnin lähes millä tahansa selaimella. Toinen vaihtoehto on käyttää ns. [headless browseria](https://en.wikipedia.org/wiki/Headless_browser)eli selainta, jolla ei ole ollenkaan graafista käyttöliittymää. Esim. Chromea on mahdollista suorittaa Headless-moodissa.
15
15
16
-
E2E tests are potentially the most useful test category, as they examine the system through the same interface as real users.
16
+
E2E testit ovat potentiaalisesti kaikkein hyödyllisin testikategoria, sillä ne tutkivat järjestelmää saman rajapinnan kautta kuin todelliset käyttäjät.
17
17
18
-
There are also unpleasant aspects to E2E tests. They are more challenging to configure than unit and integration tests. E2E tests are also typically quite slow, and in larger software their execution time can easily reach minutes or even hours. This is unfortunate for application development, because when coding an application it is very useful to be able to run tests as often as possible for [regressions](https://en.wikipedia.org/wiki/Regression_testing)in the code.
18
+
E2E-testeihin liittyy myös ikäviä puolia. Niiden konfigurointi on haastavampaa kuin yksikkö- ja integraatiotestien. E2E-testit ovat tyypillisesti myös melko hitaita ja isommassa ohjelmistossa niiden suoritusaika voi helposti nousta minuutteihin, tai jopa tunteihin. Tämä on ikävää sovelluskehityksen kannalta, sillä sovellusta koodatessa on erittäin hyödyllistä pystyä suorittamaan testejä mahdollisimman usein koodin [regressioiden](https://en.wikipedia.org/wiki/Regression_testing)varalta.
19
19
20
-
The problem is also that the tests performed via the user interface may be unreliable, i.e. in English [flaky](https://hackernoon.com/flaky-tests-a-war-that-never-ends-9aa32fdef359), some of the tests sometimes pass and sometimes not, even if nothing changes in the code.
20
+
Ongelmana on usein myös se, että käyttöliittymän kautta tehtävät testit saattavat olla epäluotettavia eli englanniksi [flaky](https://hackernoon.com/flaky-tests-a-war-that-never-ends-9aa32fdef359), osa testeistä menee välillä läpi ja välillä ei, vaikka koodissa ei muuttuisi mikään.
21
21
22
-
At the moment, perhaps the two easiest to use libraries for End to End testing are[Cypress](https://www.cypress.io/)and[Playwright](https://playwright.dev/).
22
+
Tämän hetken kaksi ehkä helppokäyttöisintä kirjastoa End to End -testaukseen ovat[Cypress](https://www.cypress.io/)ja[Playwright](https://playwright.dev/).
23
23
24
-
From the statistics on the page [npmtrends.com](https://npmtrends.com/cypress-vs-playwright), we see that Cypress, which dominated the market for the last five years, is still the clear number one, but Playwright has started a rapid rise in the second half of 2023:
24
+
Sivun [npmtrends.com](https://npmtrends.com/cypress-vs-playwright) statistiikasta näemme, että viimeiset viisi vuotta markkinaa hallinnut Cypress on edelleen selvä ykkönen, mutta Playwright on lähtenyt nopeaan nousuun vuoden 2023 toisella puolikkaalla:
25
25
26
26

27
27
28
-
Cypres has been used on this course for years. Now Playwright is also included as a new addition. You can choose whether to complete the E2E testing part of the course with Cypress or Playrwight. The operating principles of both libraries are very similar, so your choice is not very important. However, Playwright is now the primary recommended E2E library for the course.
28
+
Tällä kurssilla on jo vuosia käytetty Cypresiä. Nyt mukana on uutena myös Playwright. Saat itse valita suoritatko kurssin E2E-testausta käsittelevän osan Cypressillä vai Playrwightillä. Molempien kirjastojen toimintaperiaatteet ovat hyvin samankaltaisia, joten kovin suurta merkitystä valinnallasi ei ole. Playwright on kuitenkin nyt kurssin ensisijaisesti suosittelema E2E-kirjasto.
29
29
30
-
If your choice is Playwright, go ahead. If you end up using Cypress, go [here](/osa5/end_to_end_testaus_cypress).
30
+
Jos valintasi on Playwright, jatka eteenpäin. Jos päädyt käyttämään Cypressiä, mene [tänne](/osa5/end_to_end_testaus_cypress).
Toisin kuin React-frontille tehdyt yksikkötestit tai backendin testit, nyt tehtävien End to End -testien ei tarvitse sijaita samassa npm-projektissa missä koodi on. Tehdään E2E-testeille kokonaan oma projekti komennolla _npm init_.
17
+
18
+
Asennetaan sitten Cypress suorittamalla uuden projektin kehitysaikaiseksi riippuvuudeksi
17
19
18
20
```js
19
21
npm install --save-dev cypress
@@ -25,20 +27,12 @@ ja määritellään npm-skripti käynnistämistä varten, ja tehdään myös pie
Toisin kuin esim. frontendin yksikkötestit, Cypress-testit voidaan sijoittaa joko frontendin tai backendin repositorioon, tai vaikka kokonaan omaan repositorioonsa.
41
-
42
36
Cypress-testit olettavat että testattava järjestelmä on käynnissä kun testit suoritetaan, eli toisin kuin esim. backendin integraatiotestit, Cypress-testit <i>eivät käynnistä</i> testattavaa järjestelmää testauksen yhteydessä.
43
37
44
38
Tehdään <i>backendille</i> npm-skripti, jonka avulla se saadaan käynnistettyä testausmoodissa, eli siten, että <i>NODE\_ENV</i> saa arvon <i>test</i>.
@@ -1013,15 +1007,10 @@ Developer-konsoli on monin tavoin hyödyllinen testejä debugatessa. Network-tab
Olemme toistaiseksi suorittaneet Cypress-testejä ainoastaan graafisen test runnerin kautta. Testit on luonnollisesti mahdollista suorittaa myös [komentoriviltä](https://docs.cypress.io/guides/guides/command-line.html). Lisätään vielä sovellukselle npm-skripti tätä tarkoitusta varten
1010
+
Olemme toistaiseksi suorittaneet Cypress-testejä ainoastaan graafisen test runnerin kautta. Testit on luonnollisesti mahdollista suorittaa myös [komentoriviltä](https://docs.cypress.io/guides/guides/command-line.html). Lisätään vielä projektiin npm-skripti tätä tarkoitusta varten
0 commit comments