{"id":20039997,"url":"https://github.com/carmhack/vue-testing-101","last_synced_at":"2025-03-02T06:41:59.289Z","repository":{"id":224507692,"uuid":"763425618","full_name":"carmhack/vue-testing-101","owner":"carmhack","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-26T13:50:39.000Z","size":91,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T19:14:06.127Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carmhack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-26T09:17:33.000Z","updated_at":"2024-10-11T15:21:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"f5b119c1-e0e4-4d52-aad6-6c096bb2bb7a","html_url":"https://github.com/carmhack/vue-testing-101","commit_stats":null,"previous_names":["carmhack/vue-testing-101"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carmhack%2Fvue-testing-101","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carmhack%2Fvue-testing-101/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carmhack%2Fvue-testing-101/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carmhack%2Fvue-testing-101/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carmhack","download_url":"https://codeload.github.com/carmhack/vue-testing-101/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241470311,"owners_count":19968041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T10:40:01.036Z","updated_at":"2025-03-02T06:41:59.254Z","avatar_url":"https://github.com/carmhack.png","language":"JavaScript","readme":"# Vue Testing 101\n\nNella repository sono presenti:\n- Pinia (State Manager), insieme a pinia/testing\n- axios (API)\n- vitest (test runner)\n- jsdom (environment per vitest)\n- cypress (e2e test)\n\nNel package.json sono presenti i comandi per unit test (tramite Vitest UI), coverage ed e2e.\n\n## Unit Test\n### Hello\nUn componente semplice con due ref:\n- msg\n- inputMsg\n\nE' presente un h1 che stampa msg, un input con v-model su inputMsg e un pulsante. Al click sul pulsante msg viene valorizzato con inputMsg.\n\nTestiamo che:\n- il componente viene renderizzato correttamente\n- al click sul pulsante cambia il testo nell'h1\n\n### Advanced\nIl componente renderizza un array di oggetti che rappresentano delle pagine della nostra webapp (N.B. non è presente vue router).\n\nRiceve una prop isAuthenticated che, se true, renderizza un link aggiuntivo che porta sulla rotta /admin.\n\nTestiamo che:\n- viene renderizzato il link homepage\n- non viene renderizzato, di default, il link verso /admin\n- se isAuthenticated è true, viene renderizzato il link verso /admin\n\n### API\nIl componente APITest gestisce una chiamata verso PokeAPI. In particolare, gestisce l'offset che permette così di andare avanti e indietro con le pagine e visualizzare una lista di nomi di pokemon sempre diversa.\n\nE' presente un watch che al cambio dell'offset effettua una nuova chiamata API con il valore aggiornato.\n\nTestiamo che:\n- Al mount del componente viene chiamato axios 1 sola volta e con l'url corretto\n- La lista di pokemon ha 15 elementi e il primo contiene come testo \"bulbasaur\"\n\n### Store\nLo store gestisce un counter, un valore massimo e una percentuale di completamento.\nIn particolare, la percentuale è un computed basato su counter e max.\nLa funzione increment aggiunge 1 al counter.\n\nTestiamo che:\n- il counter in partenza è a 0\n- il counter cambia se chiamiamo increment()\n- la percentuale viene aggiornata correttamente\n\nTestiamo anche un componente che utilizza lo store (ProgressTest). In particolare il componente mostra la percentuale e ha un pulsante che chiama la funzione increment dello store.\n\nTestiamo che:\n- mostra la percentuale 0 all'avvio\n- al click sul pulsante viene chiamata la funzione increment dello store\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarmhack%2Fvue-testing-101","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarmhack%2Fvue-testing-101","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarmhack%2Fvue-testing-101/lists"}