[{"data":1,"prerenderedAt":4743},["ShallowReactive",2],{"series-\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fensure-blog-quality-with-playwright-automated-testing":3,"series-context-\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch":3504,"article-link-en-a4721c3e-e9c6-4025-ae82-9c44edd68d75":3812},{"id":4,"title":5,"body":6,"contentId":3489,"date":3490,"description":3491,"extension":3492,"github":3493,"meetTheInstructor":3495,"meta":3496,"navigation":226,"part":329,"path":3497,"rawbody":3498,"robots":3495,"schemaOrg":3495,"seo":3499,"seriesSlug":3500,"sitemap":3501,"stem":3502,"subtitle":3495,"topics":3495,"__hash__":3503},"series\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fensure-blog-quality-with-playwright-automated-testing.md","Ensure Blog Quality with Playwright Automated Testing",{"type":7,"value":8,"toc":3474},"minimark",[9,30,37,44,48,55,60,80,83,110,127,131,138,177,192,198,501,508,573,580,586,592,600,610,804,813,822,825,1120,1123,1141,1144,1147,1156,1314,1321,1324,1328,1337,1522,1529,1532,1535,1538,1877,1881,1891,1894,1897,3070,3077,3081,3088,3439,3450,3454,3470],[10,11,12,13,17,18,21,22,25,26,29],"p",{},"While we have built a blog using ",[14,15,16],"strong",{},"VitePress"," and ",[14,19,20],{},"Vue.js",", it is vital to confirm that it performs as expected. ",[14,23,24],{},"Testing"," is an essential component of ",[14,27,28],{},"software development",", ensuring our blog operates correctly and efficiently.",[10,31,32,33,36],{},"Testing each feature manually would be a labor-intensive and error-prone process. As we continue to refine our blog to meet ever-evolving requirements, ",[14,34,35],{},"automated testing"," becomes indispensable. It allows us to verify quickly that our blog functions as intended, even when modifications are made. This practice helps maintain quality, prevent regressions, and accelerate the development workflow.",[10,38,39,40,43],{},"The straightforward nature of this blog makes it an ideal candidate for beginners to implement ",[14,41,42],{},"end-to-end testing",". This type of testing validates software functionality from a user's perspective, ensuring all integrated components work harmoniously.",[45,46],"callout-read-more",{"id":47},"a4721c3e-e9c6-4025-ae82-9c44edd68d75",[10,49,50,51,54],{},"In this article, we will explore automated testing utilizing ",[14,52,53],{},"Playwright",".",[56,57,59],"h2",{"id":58},"installing-playwright","Installing Playwright",[10,61,62,64,65,68,69,72,73,76,77,54],{},[14,63,53],{}," is a ",[14,66,67],{},"Node.js library"," designed to automate browsers, enabling us to script interactions with web pages such as clicking buttons, completing forms, and navigating between pages. Playwright is compatible with multiple browsers, including ",[14,70,71],{},"Chromium",", ",[14,74,75],{},"Firefox",", and ",[14,78,79],{},"WebKit",[10,81,82],{},"To install Playwright, execute the following command:",[84,85,91],"pre",{"className":86,"code":87,"filename":88,"language":89,"meta":90,"style":90},"language-bash shiki shiki-themes github-light github-light github-dark","pnpm create playwright\n","terminal","bash","",[92,93,94],"code",{"__ignoreMap":90},[95,96,99,103,107],"span",{"class":97,"line":98},"line",1,[95,100,102],{"class":101},"snPdu","pnpm",[95,104,106],{"class":105},"sIIMD"," create",[95,108,109],{"class":105}," playwright\n",[10,111,112,113,116,117,120,121,124,125,54],{},"This command prompts the creation of a tests folder in the root directory. We will accept the default folder name ",[92,114,115],{},"tests",". It further queries whether we require a ",[14,118,119],{},"GitHub Action"," workflow file. We will select ",[92,122,123],{},"Yes",". Lastly, it inquires if we wish to install the Playwright browsers. We will opt for ",[92,126,123],{},[56,128,130],{"id":129},"configuring-playwright","Configuring Playwright",[10,132,133,134,137],{},"Upon installing Playwright, several files are generated, including ",[92,135,136],{},"playwright.config.ts",", where we must make necessary adjustments to suit our needs.",[10,139,140,141,144,145,148,149,152,153,156,157,160,161,164,165,168,169,172,173,176],{},"Initially, we will modify the ",[92,142,143],{},"timeout"," property to ",[92,146,147],{},"4_000"," milliseconds. Given the simplicity of our tests, a shorter timeout suffices, potentially accelerating test execution should they fail. The ",[92,150,151],{},"workers"," property will be set to ",[92,154,155],{},"100%",", allowing Playwright to utilize all available CPU cores for parallel test execution. This configuration works because our tests are independent; we are creating a static site. Within the ",[92,158,159],{},"use"," property, define the ",[92,162,163],{},"baseURL"," as ",[92,166,167],{},"http:\u002F\u002Flocalhost:4173",". This is VitePress's default port for the preview server, omitting the need for redundant URL specifications in each test. In the ",[92,170,171],{},"projects"," property, we will select only the ",[14,174,175],{},"Google Chrome"," browser, although additional browsers can be included at your discretion.",[10,178,179,180,183,184,187,188,191],{},"Finally, adjust the ",[92,181,182],{},"webServer"," property to automatically build and preview our blog before test execution, ensuring it is updated. As VitePress behaves differently in ",[14,185,186],{},"development"," versus ",[14,189,190],{},"production",", testing against the production build is preferable.",[10,193,194,195,197],{},"Ultimately, our ",[92,196,136],{}," file should resemble the following:",[84,199,203],{"className":200,"code":201,"filename":136,"language":202,"meta":90,"style":90},"language-ts shiki shiki-themes github-light github-light github-dark","import { defineConfig, devices } from '@playwright\u002Ftest'\n\nexport default defineConfig({\n  testDir: '.\u002Ftests',\n  fullyParallel: true,\n  forbidOnly: !!process.env.CI,\n  retries: process.env.CI ? 2 : 0,\n  timeout: 4_000,\n  workers: '100%',\n  reporter: 'html',\n  use: {\n    baseURL: 'http:\u002F\u002Flocalhost:4173',\n    trace: 'on-first-retry',\n  },\n\n  projects: [\n    {\n      name: 'Google Chrome',\n      use: { ...devices['Desktop Chrome'], channel: 'chrome' },\n    },\n  ],\n\n  webServer: {\n    command: 'npm run build && npm run preview',\n    url: 'http:\u002F\u002Flocalhost:4173',\n    reuseExistingServer: false,\n    timeout: 60_000,\n  },\n})\n","ts",[92,204,205,221,228,243,255,267,284,306,316,327,338,344,355,366,372,377,383,389,400,424,430,436,441,447,458,468,479,490,495],{"__ignoreMap":90},[95,206,207,211,215,218],{"class":97,"line":98},[95,208,210],{"class":209},"s8jYJ","import",[95,212,214],{"class":213},"sxrX7"," { defineConfig, devices } ",[95,216,217],{"class":209},"from",[95,219,220],{"class":105}," '@playwright\u002Ftest'\n",[95,222,224],{"class":97,"line":223},2,[95,225,227],{"emptyLinePlaceholder":226},true,"\n",[95,229,231,234,237,240],{"class":97,"line":230},3,[95,232,233],{"class":209},"export",[95,235,236],{"class":209}," default",[95,238,239],{"class":101}," defineConfig",[95,241,242],{"class":213},"({\n",[95,244,246,249,252],{"class":97,"line":245},4,[95,247,248],{"class":213},"  testDir: ",[95,250,251],{"class":105},"'.\u002Ftests'",[95,253,254],{"class":213},",\n",[95,256,258,261,265],{"class":97,"line":257},5,[95,259,260],{"class":213},"  fullyParallel: ",[95,262,264],{"class":263},"sBjJW","true",[95,266,254],{"class":213},[95,268,270,273,276,279,282],{"class":97,"line":269},6,[95,271,272],{"class":213},"  forbidOnly: ",[95,274,275],{"class":209},"!!",[95,277,278],{"class":213},"process.env.",[95,280,281],{"class":263},"CI",[95,283,254],{"class":213},[95,285,287,290,292,295,298,301,304],{"class":97,"line":286},7,[95,288,289],{"class":213},"  retries: process.env.",[95,291,281],{"class":263},[95,293,294],{"class":209}," ?",[95,296,297],{"class":263}," 2",[95,299,300],{"class":209}," :",[95,302,303],{"class":263}," 0",[95,305,254],{"class":213},[95,307,309,312,314],{"class":97,"line":308},8,[95,310,311],{"class":213},"  timeout: ",[95,313,147],{"class":263},[95,315,254],{"class":213},[95,317,319,322,325],{"class":97,"line":318},9,[95,320,321],{"class":213},"  workers: ",[95,323,324],{"class":105},"'100%'",[95,326,254],{"class":213},[95,328,330,333,336],{"class":97,"line":329},10,[95,331,332],{"class":213},"  reporter: ",[95,334,335],{"class":105},"'html'",[95,337,254],{"class":213},[95,339,341],{"class":97,"line":340},11,[95,342,343],{"class":213},"  use: {\n",[95,345,347,350,353],{"class":97,"line":346},12,[95,348,349],{"class":213},"    baseURL: ",[95,351,352],{"class":105},"'http:\u002F\u002Flocalhost:4173'",[95,354,254],{"class":213},[95,356,358,361,364],{"class":97,"line":357},13,[95,359,360],{"class":213},"    trace: ",[95,362,363],{"class":105},"'on-first-retry'",[95,365,254],{"class":213},[95,367,369],{"class":97,"line":368},14,[95,370,371],{"class":213},"  },\n",[95,373,375],{"class":97,"line":374},15,[95,376,227],{"emptyLinePlaceholder":226},[95,378,380],{"class":97,"line":379},16,[95,381,382],{"class":213},"  projects: [\n",[95,384,386],{"class":97,"line":385},17,[95,387,388],{"class":213},"    {\n",[95,390,392,395,398],{"class":97,"line":391},18,[95,393,394],{"class":213},"      name: ",[95,396,397],{"class":105},"'Google Chrome'",[95,399,254],{"class":213},[95,401,403,406,409,412,415,418,421],{"class":97,"line":402},19,[95,404,405],{"class":213},"      use: { ",[95,407,408],{"class":209},"...",[95,410,411],{"class":213},"devices[",[95,413,414],{"class":105},"'Desktop Chrome'",[95,416,417],{"class":213},"], channel: ",[95,419,420],{"class":105},"'chrome'",[95,422,423],{"class":213}," },\n",[95,425,427],{"class":97,"line":426},20,[95,428,429],{"class":213},"    },\n",[95,431,433],{"class":97,"line":432},21,[95,434,435],{"class":213},"  ],\n",[95,437,439],{"class":97,"line":438},22,[95,440,227],{"emptyLinePlaceholder":226},[95,442,444],{"class":97,"line":443},23,[95,445,446],{"class":213},"  webServer: {\n",[95,448,450,453,456],{"class":97,"line":449},24,[95,451,452],{"class":213},"    command: ",[95,454,455],{"class":105},"'npm run build && npm run preview'",[95,457,254],{"class":213},[95,459,461,464,466],{"class":97,"line":460},25,[95,462,463],{"class":213},"    url: ",[95,465,352],{"class":105},[95,467,254],{"class":213},[95,469,471,474,477],{"class":97,"line":470},26,[95,472,473],{"class":213},"    reuseExistingServer: ",[95,475,476],{"class":263},"false",[95,478,254],{"class":213},[95,480,482,485,488],{"class":97,"line":481},27,[95,483,484],{"class":213},"    timeout: ",[95,486,487],{"class":263},"60_000",[95,489,254],{"class":213},[95,491,493],{"class":97,"line":492},28,[95,494,371],{"class":213},[95,496,498],{"class":97,"line":497},29,[95,499,500],{"class":213},"})\n",[10,502,503,504,507],{},"In our ",[92,505,506],{},"package.json"," file, include the following scripts:",[84,509,513],{"className":510,"code":511,"filename":506,"language":512,"meta":90,"style":90},"language-json shiki shiki-themes github-light github-light github-dark","{\n  \"scripts\": {\n    \"test\": \"npm run test:e2e\",\n    \"test:e2e\": \"playwright test\",\n    \"test:e2e:ui\": \"playwright test --ui\"\n  }\n}\n","json",[92,514,515,520,528,541,553,563,568],{"__ignoreMap":90},[95,516,517],{"class":97,"line":98},[95,518,519],{"class":213},"{\n",[95,521,522,525],{"class":97,"line":223},[95,523,524],{"class":263},"  \"scripts\"",[95,526,527],{"class":213},": {\n",[95,529,530,533,536,539],{"class":97,"line":230},[95,531,532],{"class":263},"    \"test\"",[95,534,535],{"class":213},": ",[95,537,538],{"class":105},"\"npm run test:e2e\"",[95,540,254],{"class":213},[95,542,543,546,548,551],{"class":97,"line":245},[95,544,545],{"class":263},"    \"test:e2e\"",[95,547,535],{"class":213},[95,549,550],{"class":105},"\"playwright test\"",[95,552,254],{"class":213},[95,554,555,558,560],{"class":97,"line":257},[95,556,557],{"class":263},"    \"test:e2e:ui\"",[95,559,535],{"class":213},[95,561,562],{"class":105},"\"playwright test --ui\"\n",[95,564,565],{"class":97,"line":269},[95,566,567],{"class":213},"  }\n",[95,569,570],{"class":97,"line":286},[95,571,572],{"class":213},"}\n",[10,574,575,576,579],{},"The first script executes all tests, both unit and ",[14,577,578],{},"end-to-end",". The second script specifically runs end-to-end tests. The third script allows running end-to-end tests with a graphical interface, useful during test development as it visualizes browser activity.",[56,581,583,584],{"id":582},"writing-tests","Writing ",[14,585,115],{},[10,587,588,589,591],{},"With ",[14,590,53],{}," now configured, we can proceed to write our tests. Let's commence with a simple test before progressing to more intricate ones.",[593,594,596,597],"h3",{"id":595},"header-test","Header ",[14,598,599],{},"test",[10,601,602,603,606,607,609],{},"Begin by creating a ",[92,604,605],{},"header.test.ts"," file within the ",[92,608,115],{}," folder. These tests will confirm the correct display of our blog header with the anticipated links, ensuring header consistency post-refactoring.",[84,611,613],{"className":200,"code":612,"filename":605,"language":202,"meta":90,"style":90},"import { expect, test } from '@playwright\u002Ftest'\n\ntest('should have a link to the homepage', async ({ page }) => {\n  \u002F\u002F Arrange\n\n  \u002F\u002F Act\n  await page.goto('\u002F')\n\n  \u002F\u002F Assert\n  const headerHomeLink = page\n    .getByRole('banner')\n    .getByRole('link', { name: 'Garabit', exact: true })\n\n  await expect(headerHomeLink).toBeVisible()\n  await expect(headerHomeLink).toHaveAttribute('href', '\u002F')\n})\n",[92,614,615,626,630,661,667,671,676,695,699,704,718,733,758,762,778,800],{"__ignoreMap":90},[95,616,617,619,622,624],{"class":97,"line":98},[95,618,210],{"class":209},[95,620,621],{"class":213}," { expect, test } ",[95,623,217],{"class":209},[95,625,220],{"class":105},[95,627,628],{"class":97,"line":223},[95,629,227],{"emptyLinePlaceholder":226},[95,631,632,634,637,640,642,645,648,652,655,658],{"class":97,"line":230},[95,633,599],{"class":101},[95,635,636],{"class":213},"(",[95,638,639],{"class":105},"'should have a link to the homepage'",[95,641,72],{"class":213},[95,643,644],{"class":209},"async",[95,646,647],{"class":213}," ({ ",[95,649,651],{"class":650},"sP4rz","page",[95,653,654],{"class":213}," }) ",[95,656,657],{"class":209},"=>",[95,659,660],{"class":213}," {\n",[95,662,663],{"class":97,"line":245},[95,664,666],{"class":665},"sCsY4","  \u002F\u002F Arrange\n",[95,668,669],{"class":97,"line":257},[95,670,227],{"emptyLinePlaceholder":226},[95,672,673],{"class":97,"line":269},[95,674,675],{"class":665},"  \u002F\u002F Act\n",[95,677,678,681,684,687,689,692],{"class":97,"line":286},[95,679,680],{"class":209},"  await",[95,682,683],{"class":213}," page.",[95,685,686],{"class":101},"goto",[95,688,636],{"class":213},[95,690,691],{"class":105},"'\u002F'",[95,693,694],{"class":213},")\n",[95,696,697],{"class":97,"line":308},[95,698,227],{"emptyLinePlaceholder":226},[95,700,701],{"class":97,"line":318},[95,702,703],{"class":665},"  \u002F\u002F Assert\n",[95,705,706,709,712,715],{"class":97,"line":329},[95,707,708],{"class":209},"  const",[95,710,711],{"class":263}," headerHomeLink",[95,713,714],{"class":209}," =",[95,716,717],{"class":213}," page\n",[95,719,720,723,726,728,731],{"class":97,"line":340},[95,721,722],{"class":213},"    .",[95,724,725],{"class":101},"getByRole",[95,727,636],{"class":213},[95,729,730],{"class":105},"'banner'",[95,732,694],{"class":213},[95,734,735,737,739,741,744,747,750,753,755],{"class":97,"line":346},[95,736,722],{"class":213},[95,738,725],{"class":101},[95,740,636],{"class":213},[95,742,743],{"class":105},"'link'",[95,745,746],{"class":213},", { name: ",[95,748,749],{"class":105},"'Garabit'",[95,751,752],{"class":213},", exact: ",[95,754,264],{"class":263},[95,756,757],{"class":213}," })\n",[95,759,760],{"class":97,"line":357},[95,761,227],{"emptyLinePlaceholder":226},[95,763,764,766,769,772,775],{"class":97,"line":368},[95,765,680],{"class":209},[95,767,768],{"class":101}," expect",[95,770,771],{"class":213},"(headerHomeLink).",[95,773,774],{"class":101},"toBeVisible",[95,776,777],{"class":213},"()\n",[95,779,780,782,784,786,789,791,794,796,798],{"class":97,"line":374},[95,781,680],{"class":209},[95,783,768],{"class":101},[95,785,771],{"class":213},[95,787,788],{"class":101},"toHaveAttribute",[95,790,636],{"class":213},[95,792,793],{"class":105},"'href'",[95,795,72],{"class":213},[95,797,691],{"class":105},[95,799,694],{"class":213},[95,801,802],{"class":97,"line":379},[95,803,500],{"class":213},[10,805,806,807,809,810,812],{},"Let me elucidate this initial test. We utilize Playwright's ",[92,808,599],{}," function to craft a test. The first argument describes the test, while the second is an asynchronous function receiving an object containing the ",[92,811,651],{}," property. This object represents the Playwright page object, which interacts with the browser.",[10,814,815,816,818,819,821],{},"In our test, we firstly navigate to the homepage. We can use a relative URL due to the ",[92,817,163],{}," configuration in ",[92,820,136],{},". Subsequently, we obtain the header element by its role, verifying its visibility and correct link. Employing role-based element selection ensures tests remain resilient amidst HTML structure changes and guarantees element accessibility.",[10,823,824],{},"We can conduct two additional tests to verify the presence of links to the blog and GitHub projects, similar to the first, but targeting different elements.",[84,826,828],{"className":200,"code":827,"filename":136,"language":202,"meta":90,"style":90},"test('should have a link to the blog', async ({ page }) => {\n  \u002F\u002F Arrange\n\n  \u002F\u002F Act\n  await page.goto('\u002F')\n\n  \u002F\u002F Assert\n  const headerBlogLink = page\n    .getByRole('banner')\n    .getByRole('link', { name: 'Blog', exact: true })\n\n  await expect(headerBlogLink).toBeVisible()\n  await expect(headerBlogLink).toHaveAttribute('href', '\u002Fblog')\n})\n\ntest('should have a link to the projects', async ({ page }) => {\n  \u002F\u002F Arrange\n\n  \u002F\u002F Act\n  await page.goto('\u002F')\n\n  \u002F\u002F Assert\n  const headerProjectsLink = page\n    .getByRole('banner')\n    .getByRole('link', { name: 'Projects', exact: true })\n\n  await expect(headerProjectsLink).toBeVisible()\n  await expect(headerProjectsLink).toHaveAttribute('href', '\u002Fprojects')\n})\n",[92,829,830,853,857,861,865,879,883,887,898,910,931,935,948,969,973,977,1000,1004,1008,1012,1026,1030,1034,1045,1057,1078,1082,1095,1116],{"__ignoreMap":90},[95,831,832,834,836,839,841,843,845,847,849,851],{"class":97,"line":98},[95,833,599],{"class":101},[95,835,636],{"class":213},[95,837,838],{"class":105},"'should have a link to the blog'",[95,840,72],{"class":213},[95,842,644],{"class":209},[95,844,647],{"class":213},[95,846,651],{"class":650},[95,848,654],{"class":213},[95,850,657],{"class":209},[95,852,660],{"class":213},[95,854,855],{"class":97,"line":223},[95,856,666],{"class":665},[95,858,859],{"class":97,"line":230},[95,860,227],{"emptyLinePlaceholder":226},[95,862,863],{"class":97,"line":245},[95,864,675],{"class":665},[95,866,867,869,871,873,875,877],{"class":97,"line":257},[95,868,680],{"class":209},[95,870,683],{"class":213},[95,872,686],{"class":101},[95,874,636],{"class":213},[95,876,691],{"class":105},[95,878,694],{"class":213},[95,880,881],{"class":97,"line":269},[95,882,227],{"emptyLinePlaceholder":226},[95,884,885],{"class":97,"line":286},[95,886,703],{"class":665},[95,888,889,891,894,896],{"class":97,"line":308},[95,890,708],{"class":209},[95,892,893],{"class":263}," headerBlogLink",[95,895,714],{"class":209},[95,897,717],{"class":213},[95,899,900,902,904,906,908],{"class":97,"line":318},[95,901,722],{"class":213},[95,903,725],{"class":101},[95,905,636],{"class":213},[95,907,730],{"class":105},[95,909,694],{"class":213},[95,911,912,914,916,918,920,922,925,927,929],{"class":97,"line":329},[95,913,722],{"class":213},[95,915,725],{"class":101},[95,917,636],{"class":213},[95,919,743],{"class":105},[95,921,746],{"class":213},[95,923,924],{"class":105},"'Blog'",[95,926,752],{"class":213},[95,928,264],{"class":263},[95,930,757],{"class":213},[95,932,933],{"class":97,"line":340},[95,934,227],{"emptyLinePlaceholder":226},[95,936,937,939,941,944,946],{"class":97,"line":346},[95,938,680],{"class":209},[95,940,768],{"class":101},[95,942,943],{"class":213},"(headerBlogLink).",[95,945,774],{"class":101},[95,947,777],{"class":213},[95,949,950,952,954,956,958,960,962,964,967],{"class":97,"line":357},[95,951,680],{"class":209},[95,953,768],{"class":101},[95,955,943],{"class":213},[95,957,788],{"class":101},[95,959,636],{"class":213},[95,961,793],{"class":105},[95,963,72],{"class":213},[95,965,966],{"class":105},"'\u002Fblog'",[95,968,694],{"class":213},[95,970,971],{"class":97,"line":368},[95,972,500],{"class":213},[95,974,975],{"class":97,"line":374},[95,976,227],{"emptyLinePlaceholder":226},[95,978,979,981,983,986,988,990,992,994,996,998],{"class":97,"line":379},[95,980,599],{"class":101},[95,982,636],{"class":213},[95,984,985],{"class":105},"'should have a link to the projects'",[95,987,72],{"class":213},[95,989,644],{"class":209},[95,991,647],{"class":213},[95,993,651],{"class":650},[95,995,654],{"class":213},[95,997,657],{"class":209},[95,999,660],{"class":213},[95,1001,1002],{"class":97,"line":385},[95,1003,666],{"class":665},[95,1005,1006],{"class":97,"line":391},[95,1007,227],{"emptyLinePlaceholder":226},[95,1009,1010],{"class":97,"line":402},[95,1011,675],{"class":665},[95,1013,1014,1016,1018,1020,1022,1024],{"class":97,"line":426},[95,1015,680],{"class":209},[95,1017,683],{"class":213},[95,1019,686],{"class":101},[95,1021,636],{"class":213},[95,1023,691],{"class":105},[95,1025,694],{"class":213},[95,1027,1028],{"class":97,"line":432},[95,1029,227],{"emptyLinePlaceholder":226},[95,1031,1032],{"class":97,"line":438},[95,1033,703],{"class":665},[95,1035,1036,1038,1041,1043],{"class":97,"line":443},[95,1037,708],{"class":209},[95,1039,1040],{"class":263}," headerProjectsLink",[95,1042,714],{"class":209},[95,1044,717],{"class":213},[95,1046,1047,1049,1051,1053,1055],{"class":97,"line":449},[95,1048,722],{"class":213},[95,1050,725],{"class":101},[95,1052,636],{"class":213},[95,1054,730],{"class":105},[95,1056,694],{"class":213},[95,1058,1059,1061,1063,1065,1067,1069,1072,1074,1076],{"class":97,"line":460},[95,1060,722],{"class":213},[95,1062,725],{"class":101},[95,1064,636],{"class":213},[95,1066,743],{"class":105},[95,1068,746],{"class":213},[95,1070,1071],{"class":105},"'Projects'",[95,1073,752],{"class":213},[95,1075,264],{"class":263},[95,1077,757],{"class":213},[95,1079,1080],{"class":97,"line":470},[95,1081,227],{"emptyLinePlaceholder":226},[95,1083,1084,1086,1088,1091,1093],{"class":97,"line":481},[95,1085,680],{"class":209},[95,1087,768],{"class":101},[95,1089,1090],{"class":213},"(headerProjectsLink).",[95,1092,774],{"class":101},[95,1094,777],{"class":213},[95,1096,1097,1099,1101,1103,1105,1107,1109,1111,1114],{"class":97,"line":492},[95,1098,680],{"class":209},[95,1100,768],{"class":101},[95,1102,1090],{"class":213},[95,1104,788],{"class":101},[95,1106,636],{"class":213},[95,1108,793],{"class":105},[95,1110,72],{"class":213},[95,1112,1113],{"class":105},"'\u002Fprojects'",[95,1115,694],{"class":213},[95,1117,1118],{"class":97,"line":497},[95,1119,500],{"class":213},[10,1121,1122],{},"Execute the tests using the command:",[84,1124,1126],{"className":86,"code":1125,"filename":88,"language":89,"meta":90,"style":90},"pnpm run test:e2e:ui # or pnpm run test:e2e\n",[92,1127,1128],{"__ignoreMap":90},[95,1129,1130,1132,1135,1138],{"class":97,"line":98},[95,1131,102],{"class":101},[95,1133,1134],{"class":105}," run",[95,1136,1137],{"class":105}," test:e2e:ui",[95,1139,1140],{"class":665}," # or pnpm run test:e2e\n",[10,1142,1143],{},"This command will open a browser and execute the tests. A passing test will display a green checkmark beside it, whereas a failing test will show a red cross. Clicking on a test provides the error message details.",[593,1145,1146],{"id":171},"Projects",[10,1148,1149,1150,606,1153,1155],{},"Next, we can validate that users can navigate from the projects page back to the homepage using the \"Back to Home\" button. Create a ",[92,1151,1152],{},"projects.test.ts",[92,1154,115],{}," folder with the following content:",[84,1157,1159],{"className":200,"code":1158,"filename":1152,"language":202,"meta":90,"style":90},"import { expect, test } from '@playwright\u002Ftest'\n\ntest('should have a link to the homepage', async ({ page }) => {\n  \u002F\u002F Arrange\n\n  \u002F\u002F Act\n  await page.goto('\u002Fprojects')\n\n  \u002F\u002F Assert\n  const headerHomeLink = page.getByRole('link', {\n    name: 'Back to Home',\n    exact: true,\n  })\n\n  await expect(headerHomeLink).toBeVisible()\n  await expect(headerHomeLink).toHaveAttribute('href', '\u002F')\n})\n",[92,1160,1161,1171,1175,1197,1201,1205,1209,1223,1227,1231,1250,1260,1269,1274,1278,1290,1310],{"__ignoreMap":90},[95,1162,1163,1165,1167,1169],{"class":97,"line":98},[95,1164,210],{"class":209},[95,1166,621],{"class":213},[95,1168,217],{"class":209},[95,1170,220],{"class":105},[95,1172,1173],{"class":97,"line":223},[95,1174,227],{"emptyLinePlaceholder":226},[95,1176,1177,1179,1181,1183,1185,1187,1189,1191,1193,1195],{"class":97,"line":230},[95,1178,599],{"class":101},[95,1180,636],{"class":213},[95,1182,639],{"class":105},[95,1184,72],{"class":213},[95,1186,644],{"class":209},[95,1188,647],{"class":213},[95,1190,651],{"class":650},[95,1192,654],{"class":213},[95,1194,657],{"class":209},[95,1196,660],{"class":213},[95,1198,1199],{"class":97,"line":245},[95,1200,666],{"class":665},[95,1202,1203],{"class":97,"line":257},[95,1204,227],{"emptyLinePlaceholder":226},[95,1206,1207],{"class":97,"line":269},[95,1208,675],{"class":665},[95,1210,1211,1213,1215,1217,1219,1221],{"class":97,"line":286},[95,1212,680],{"class":209},[95,1214,683],{"class":213},[95,1216,686],{"class":101},[95,1218,636],{"class":213},[95,1220,1113],{"class":105},[95,1222,694],{"class":213},[95,1224,1225],{"class":97,"line":308},[95,1226,227],{"emptyLinePlaceholder":226},[95,1228,1229],{"class":97,"line":318},[95,1230,703],{"class":665},[95,1232,1233,1235,1237,1239,1241,1243,1245,1247],{"class":97,"line":329},[95,1234,708],{"class":209},[95,1236,711],{"class":263},[95,1238,714],{"class":209},[95,1240,683],{"class":213},[95,1242,725],{"class":101},[95,1244,636],{"class":213},[95,1246,743],{"class":105},[95,1248,1249],{"class":213},", {\n",[95,1251,1252,1255,1258],{"class":97,"line":340},[95,1253,1254],{"class":213},"    name: ",[95,1256,1257],{"class":105},"'Back to Home'",[95,1259,254],{"class":213},[95,1261,1262,1265,1267],{"class":97,"line":346},[95,1263,1264],{"class":213},"    exact: ",[95,1266,264],{"class":263},[95,1268,254],{"class":213},[95,1270,1271],{"class":97,"line":357},[95,1272,1273],{"class":213},"  })\n",[95,1275,1276],{"class":97,"line":368},[95,1277,227],{"emptyLinePlaceholder":226},[95,1279,1280,1282,1284,1286,1288],{"class":97,"line":374},[95,1281,680],{"class":209},[95,1283,768],{"class":101},[95,1285,771],{"class":213},[95,1287,774],{"class":101},[95,1289,777],{"class":213},[95,1291,1292,1294,1296,1298,1300,1302,1304,1306,1308],{"class":97,"line":379},[95,1293,680],{"class":209},[95,1295,768],{"class":101},[95,1297,771],{"class":213},[95,1299,788],{"class":101},[95,1301,636],{"class":213},[95,1303,793],{"class":105},[95,1305,72],{"class":213},[95,1307,691],{"class":105},[95,1309,694],{"class":213},[95,1311,1312],{"class":97,"line":385},[95,1313,500],{"class":213},[10,1315,1316,1317,1320],{},"Utilizing the ",[92,1318,1319],{},"pnpm run test:e2e:ui"," command will allow you to observe tests as they are created. As you develop them, you can re-run tests using the green play button to confirm they pass.",[10,1322,1323],{},"In this file, you may also consider evaluating the page title and ensuring the list of projects reflects the projects intended for display. Initially, prioritize testing non-visible elements like links as done previously, and incorporate tests when issues arise or code refactoring occurs.",[593,1325,1327],{"id":1326},"blog","Blog",[10,1329,1330,1331,606,1334,1336],{},"Following the procedure for the projects page, create a ",[92,1332,1333],{},"blog.test.ts",[92,1335,115],{}," folder. Let's test the \"Back to Home\" button.",[84,1338,1340],{"className":200,"code":1339,"filename":1333,"language":202,"meta":90,"style":90},"import { expect, test } from '@playwright\u002Ftest'\n\ntest.describe('index', () => {\n  test('should have a link to the homepage', async ({ page }) => {\n    \u002F\u002F Arrange\n\n    \u002F\u002F Act\n    await page.goto('\u002Fblog')\n\n    \u002F\u002F Assert\n    const headerHomeLink = page.getByRole('link', {\n      name: 'Back to Home',\n      exact: true,\n    })\n\n    await expect(headerHomeLink).toBeVisible()\n    await expect(headerHomeLink).toHaveAttribute('href', '\u002F')\n  })\n})\n",[92,1341,1342,1352,1356,1376,1399,1404,1408,1413,1428,1432,1437,1456,1464,1473,1478,1482,1494,1514,1518],{"__ignoreMap":90},[95,1343,1344,1346,1348,1350],{"class":97,"line":98},[95,1345,210],{"class":209},[95,1347,621],{"class":213},[95,1349,217],{"class":209},[95,1351,220],{"class":105},[95,1353,1354],{"class":97,"line":223},[95,1355,227],{"emptyLinePlaceholder":226},[95,1357,1358,1361,1364,1366,1369,1372,1374],{"class":97,"line":230},[95,1359,1360],{"class":213},"test.",[95,1362,1363],{"class":101},"describe",[95,1365,636],{"class":213},[95,1367,1368],{"class":105},"'index'",[95,1370,1371],{"class":213},", () ",[95,1373,657],{"class":209},[95,1375,660],{"class":213},[95,1377,1378,1381,1383,1385,1387,1389,1391,1393,1395,1397],{"class":97,"line":245},[95,1379,1380],{"class":101},"  test",[95,1382,636],{"class":213},[95,1384,639],{"class":105},[95,1386,72],{"class":213},[95,1388,644],{"class":209},[95,1390,647],{"class":213},[95,1392,651],{"class":650},[95,1394,654],{"class":213},[95,1396,657],{"class":209},[95,1398,660],{"class":213},[95,1400,1401],{"class":97,"line":257},[95,1402,1403],{"class":665},"    \u002F\u002F Arrange\n",[95,1405,1406],{"class":97,"line":269},[95,1407,227],{"emptyLinePlaceholder":226},[95,1409,1410],{"class":97,"line":286},[95,1411,1412],{"class":665},"    \u002F\u002F Act\n",[95,1414,1415,1418,1420,1422,1424,1426],{"class":97,"line":308},[95,1416,1417],{"class":209},"    await",[95,1419,683],{"class":213},[95,1421,686],{"class":101},[95,1423,636],{"class":213},[95,1425,966],{"class":105},[95,1427,694],{"class":213},[95,1429,1430],{"class":97,"line":318},[95,1431,227],{"emptyLinePlaceholder":226},[95,1433,1434],{"class":97,"line":329},[95,1435,1436],{"class":665},"    \u002F\u002F Assert\n",[95,1438,1439,1442,1444,1446,1448,1450,1452,1454],{"class":97,"line":340},[95,1440,1441],{"class":209},"    const",[95,1443,711],{"class":263},[95,1445,714],{"class":209},[95,1447,683],{"class":213},[95,1449,725],{"class":101},[95,1451,636],{"class":213},[95,1453,743],{"class":105},[95,1455,1249],{"class":213},[95,1457,1458,1460,1462],{"class":97,"line":346},[95,1459,394],{"class":213},[95,1461,1257],{"class":105},[95,1463,254],{"class":213},[95,1465,1466,1469,1471],{"class":97,"line":357},[95,1467,1468],{"class":213},"      exact: ",[95,1470,264],{"class":263},[95,1472,254],{"class":213},[95,1474,1475],{"class":97,"line":368},[95,1476,1477],{"class":213},"    })\n",[95,1479,1480],{"class":97,"line":374},[95,1481,227],{"emptyLinePlaceholder":226},[95,1483,1484,1486,1488,1490,1492],{"class":97,"line":379},[95,1485,1417],{"class":209},[95,1487,768],{"class":101},[95,1489,771],{"class":213},[95,1491,774],{"class":101},[95,1493,777],{"class":213},[95,1495,1496,1498,1500,1502,1504,1506,1508,1510,1512],{"class":97,"line":385},[95,1497,1417],{"class":209},[95,1499,768],{"class":101},[95,1501,771],{"class":213},[95,1503,788],{"class":101},[95,1505,636],{"class":213},[95,1507,793],{"class":105},[95,1509,72],{"class":213},[95,1511,691],{"class":105},[95,1513,694],{"class":213},[95,1515,1516],{"class":97,"line":391},[95,1517,1273],{"class":213},[95,1519,1520],{"class":97,"line":402},[95,1521,500],{"class":213},[10,1523,1524,1525,1528],{},"We use a ",[92,1526,1527],{},"test.describe"," block to group similar tests, which is advantageous when handling multiple tests on the same page. In this file, we will write tests for both the blog index page and individual blog posts.",[10,1530,1531],{},"Regarding the blog post page, we could examine whether each post contains a \"Back to Blog\" button. Should we attempt testing a single post, or should we try for all? How can we navigate to the blog post?",[10,1533,1534],{},"One approach is crafting a test that navigates to \u002Fblog and clicks on the first post, subsequently verifying the visibility and link accuracy of the \"Back to Blog\" button. This test effectively validates inter-page navigation but is not our current focus. Alternatively, we could select all posts and iterate through them, confirming consistent functionality.",[10,1536,1537],{},"However, since VitePress generates the URL based on filename, we can exploit this aspect by using a glob pattern to retrieve all post filenames and iterate through them to check functionality. This efficient method accelerates testing.",[84,1539,1542],{"className":200,"code":1540,"filename":1541,"language":202,"meta":90,"style":90},"import { expect, test } from '@playwright\u002Ftest'\nimport { glob } from 'tinyglobby'\n\nconst posts = await glob('src\u002Fblog\u002F*.md')\n\ntest.describe('index', () => {\n  \u002F\u002F ...\n})\n\ntest.describe('show', () => {\n  posts.forEach((post) => {\n    const link = post.replace('src', '').replace('.md', '').replace('.md', '')\n\n    test(`should have a link to the blog index (${post})`, async ({ page }) => {\n      \u002F\u002F Arrange\n\n      \u002F\u002F Act\n      await page.goto(link)\n\n      \u002F\u002F Assert\n      const headerBlogLink = page.getByRole('link', {\n        name: 'Back to Blog',\n        exact: true,\n      })\n\n      await expect(headerBlogLink).toBeVisible()\n      await expect(headerBlogLink).toHaveAttribute('href', '\u002Fblog')\n    })\n  })\n})\n","Example",[92,1543,1544,1554,1566,1570,1593,1597,1613,1618,1622,1626,1643,1664,1717,1721,1750,1755,1759,1764,1776,1780,1785,1804,1814,1823,1828,1832,1844,1864,1868,1872],{"__ignoreMap":90},[95,1545,1546,1548,1550,1552],{"class":97,"line":98},[95,1547,210],{"class":209},[95,1549,621],{"class":213},[95,1551,217],{"class":209},[95,1553,220],{"class":105},[95,1555,1556,1558,1561,1563],{"class":97,"line":223},[95,1557,210],{"class":209},[95,1559,1560],{"class":213}," { glob } ",[95,1562,217],{"class":209},[95,1564,1565],{"class":105}," 'tinyglobby'\n",[95,1567,1568],{"class":97,"line":230},[95,1569,227],{"emptyLinePlaceholder":226},[95,1571,1572,1575,1578,1580,1583,1586,1588,1591],{"class":97,"line":245},[95,1573,1574],{"class":209},"const",[95,1576,1577],{"class":263}," posts",[95,1579,714],{"class":209},[95,1581,1582],{"class":209}," await",[95,1584,1585],{"class":101}," glob",[95,1587,636],{"class":213},[95,1589,1590],{"class":105},"'src\u002Fblog\u002F*.md'",[95,1592,694],{"class":213},[95,1594,1595],{"class":97,"line":257},[95,1596,227],{"emptyLinePlaceholder":226},[95,1598,1599,1601,1603,1605,1607,1609,1611],{"class":97,"line":269},[95,1600,1360],{"class":213},[95,1602,1363],{"class":101},[95,1604,636],{"class":213},[95,1606,1368],{"class":105},[95,1608,1371],{"class":213},[95,1610,657],{"class":209},[95,1612,660],{"class":213},[95,1614,1615],{"class":97,"line":286},[95,1616,1617],{"class":665},"  \u002F\u002F ...\n",[95,1619,1620],{"class":97,"line":308},[95,1621,500],{"class":213},[95,1623,1624],{"class":97,"line":318},[95,1625,227],{"emptyLinePlaceholder":226},[95,1627,1628,1630,1632,1634,1637,1639,1641],{"class":97,"line":329},[95,1629,1360],{"class":213},[95,1631,1363],{"class":101},[95,1633,636],{"class":213},[95,1635,1636],{"class":105},"'show'",[95,1638,1371],{"class":213},[95,1640,657],{"class":209},[95,1642,660],{"class":213},[95,1644,1645,1648,1651,1654,1657,1660,1662],{"class":97,"line":340},[95,1646,1647],{"class":213},"  posts.",[95,1649,1650],{"class":101},"forEach",[95,1652,1653],{"class":213},"((",[95,1655,1656],{"class":650},"post",[95,1658,1659],{"class":213},") ",[95,1661,657],{"class":209},[95,1663,660],{"class":213},[95,1665,1666,1668,1671,1673,1676,1679,1681,1684,1686,1689,1692,1694,1696,1699,1701,1703,1705,1707,1709,1711,1713,1715],{"class":97,"line":346},[95,1667,1441],{"class":209},[95,1669,1670],{"class":263}," link",[95,1672,714],{"class":209},[95,1674,1675],{"class":213}," post.",[95,1677,1678],{"class":101},"replace",[95,1680,636],{"class":213},[95,1682,1683],{"class":105},"'src'",[95,1685,72],{"class":213},[95,1687,1688],{"class":105},"''",[95,1690,1691],{"class":213},").",[95,1693,1678],{"class":101},[95,1695,636],{"class":213},[95,1697,1698],{"class":105},"'.md'",[95,1700,72],{"class":213},[95,1702,1688],{"class":105},[95,1704,1691],{"class":213},[95,1706,1678],{"class":101},[95,1708,636],{"class":213},[95,1710,1698],{"class":105},[95,1712,72],{"class":213},[95,1714,1688],{"class":105},[95,1716,694],{"class":213},[95,1718,1719],{"class":97,"line":357},[95,1720,227],{"emptyLinePlaceholder":226},[95,1722,1723,1726,1728,1731,1733,1736,1738,1740,1742,1744,1746,1748],{"class":97,"line":368},[95,1724,1725],{"class":101},"    test",[95,1727,636],{"class":213},[95,1729,1730],{"class":105},"`should have a link to the blog index (${",[95,1732,1656],{"class":213},[95,1734,1735],{"class":105},"})`",[95,1737,72],{"class":213},[95,1739,644],{"class":209},[95,1741,647],{"class":213},[95,1743,651],{"class":650},[95,1745,654],{"class":213},[95,1747,657],{"class":209},[95,1749,660],{"class":213},[95,1751,1752],{"class":97,"line":374},[95,1753,1754],{"class":665},"      \u002F\u002F Arrange\n",[95,1756,1757],{"class":97,"line":379},[95,1758,227],{"emptyLinePlaceholder":226},[95,1760,1761],{"class":97,"line":385},[95,1762,1763],{"class":665},"      \u002F\u002F Act\n",[95,1765,1766,1769,1771,1773],{"class":97,"line":391},[95,1767,1768],{"class":209},"      await",[95,1770,683],{"class":213},[95,1772,686],{"class":101},[95,1774,1775],{"class":213},"(link)\n",[95,1777,1778],{"class":97,"line":402},[95,1779,227],{"emptyLinePlaceholder":226},[95,1781,1782],{"class":97,"line":426},[95,1783,1784],{"class":665},"      \u002F\u002F Assert\n",[95,1786,1787,1790,1792,1794,1796,1798,1800,1802],{"class":97,"line":432},[95,1788,1789],{"class":209},"      const",[95,1791,893],{"class":263},[95,1793,714],{"class":209},[95,1795,683],{"class":213},[95,1797,725],{"class":101},[95,1799,636],{"class":213},[95,1801,743],{"class":105},[95,1803,1249],{"class":213},[95,1805,1806,1809,1812],{"class":97,"line":438},[95,1807,1808],{"class":213},"        name: ",[95,1810,1811],{"class":105},"'Back to Blog'",[95,1813,254],{"class":213},[95,1815,1816,1819,1821],{"class":97,"line":443},[95,1817,1818],{"class":213},"        exact: ",[95,1820,264],{"class":263},[95,1822,254],{"class":213},[95,1824,1825],{"class":97,"line":449},[95,1826,1827],{"class":213},"      })\n",[95,1829,1830],{"class":97,"line":460},[95,1831,227],{"emptyLinePlaceholder":226},[95,1833,1834,1836,1838,1840,1842],{"class":97,"line":470},[95,1835,1768],{"class":209},[95,1837,768],{"class":101},[95,1839,943],{"class":213},[95,1841,774],{"class":101},[95,1843,777],{"class":213},[95,1845,1846,1848,1850,1852,1854,1856,1858,1860,1862],{"class":97,"line":481},[95,1847,1768],{"class":209},[95,1849,768],{"class":101},[95,1851,943],{"class":213},[95,1853,788],{"class":101},[95,1855,636],{"class":213},[95,1857,793],{"class":105},[95,1859,72],{"class":213},[95,1861,966],{"class":105},[95,1863,694],{"class":213},[95,1865,1866],{"class":97,"line":492},[95,1867,1477],{"class":213},[95,1869,1870],{"class":97,"line":497},[95,1871,1273],{"class":213},[95,1873,1875],{"class":97,"line":1874},30,[95,1876,500],{"class":213},[593,1878,1880],{"id":1879},"seo","SEO",[10,1882,1883,1884,1887,1888,54],{},"Using end-to-end testing for a static blog proves highly beneficial for verifying ",[14,1885,1886],{},"SEO metadata",". We can check the title, description, and image accuracy of each page, ensuring optimal ",[14,1889,1890],{},"SEO-friendliness",[10,1892,1893],{},"Manually checking each page's DOM for the correct tags is labor-intensive, but Playwright simplifies DOM manipulation, including hidden elements.",[10,1895,1896],{},"By applying the same techniques as on the blog post page, we can use a glob pattern to iterate through all pages, verifying the SEO metadata.",[84,1898,1900],{"className":200,"code":1899,"filename":1541,"language":202,"meta":90,"style":90},"import test, { expect } from '@playwright\u002Ftest'\nimport { glob } from 'tinyglobby'\nimport { joinURL, withoutTrailingSlash } from 'ufo'\n\nconst pages = await glob('src\u002F**\u002F*.md')\n\npages.forEach((page) => {\n  const link = page.replace('src', '').replace('.md', '').replace('index', '')\n\n  test(`should have metadata (${page})`, async ({ page, request }) => {\n    \u002F\u002F Arrange\n\n    \u002F\u002F Act\n    await page.goto(link)\n\n    \u002F\u002F Assert\n    const title = await page.title()\n    expect(title).toBeTruthy()\n    expect(title.endsWith(' | Garabit')).toBeTruthy()\n\n    const ogTitle = await page\n      .locator('meta[property=\"og:title\"]')\n      .getAttribute('content')\n    expect(ogTitle).toBeTruthy()\n    const twitterTitle = await page\n      .locator('meta[name=\"twitter:title\"]')\n      .getAttribute('content')\n    expect(twitterTitle).toBeTruthy()\n\n    expect(title.startsWith(ogTitle!)).toBeTruthy()\n    expect(ogTitle).toBe(twitterTitle)\n\n    const description = await page\n      .locator('meta[name=\"description\"]')\n      .getAttribute('content')\n    expect(description).toBeTruthy()\n    const ogDescription = await page\n      .locator('meta[property=\"og:description\"]')\n      .getAttribute('content')\n    expect(ogDescription).toBeTruthy()\n    const twitterDescription = await page\n      .locator('meta[name=\"twitter:description\"]')\n      .getAttribute('content')\n    expect(twitterDescription).toBeTruthy()\n\n    expect(description).toBe(ogDescription)\n    expect(description).toBe(twitterDescription)\n\n    const twitterSite = await page\n      .locator('meta[name=\"twitter:site\"]')\n      .getAttribute('content')\n    expect(twitterSite).toBe('@soubiran_')\n    const twitterCard = await page\n      .locator('meta[name=\"twitter:card\"]')\n      .getAttribute('content')\n    expect(twitterCard).toBe('summary_large_image')\n\n    const canonical = await page\n      .locator('link[rel=\"canonical\"]')\n      .getAttribute('href')\n    expect(canonical).toBe(\n      withoutTrailingSlash(joinURL('https:\u002F\u002Fgarabit.barbapapazes.dev', link)),\n    )\n\n    const ogMetaTags = [\n      { name: 'og:image:width', value: '1200' },\n      { name: 'og:image:height', value: '630' },\n      { name: 'og:image:type', value: 'image\u002Fpng' },\n      { name: 'og:site_name', value: 'Garabit' },\n      { name: 'og:type', value: 'website' },\n      { name: 'og:url', value: 'https:\u002F\u002Fgarabit.barbapapazes.dev' },\n    ]\n\n    for (const { name, value } of ogMetaTags) {\n      const metaTag = await page\n        .locator(`meta[property=\"${name}\"]`)\n        .getAttribute('content')\n      expect(metaTag).toBe(value)\n    }\n\n    const url = await page\n      .locator('meta[property=\"og:image\"]')\n      .getAttribute('content')\n    expect(url).toBeTruthy()\n\n    const image = await request.get(\n      url!.replace('https:\u002F\u002Fgarabit.barbapapazes.dev', 'http:\u002F\u002Flocalhost:4173'),\n    )\n    expect(image.ok()).toBeTruthy()\n    expect(image.headers()['content-type']).toBe('image\u002Fpng')\n  })\n})\n",[92,1901,1902,1913,1923,1935,1939,1959,1963,1980,2026,2030,2062,2066,2070,2074,2084,2088,2092,2110,2123,2145,2149,2162,2177,2191,2202,2215,2228,2240,2251,2255,2276,2289,2294,2308,2322,2335,2347,2361,2375,2388,2400,2414,2428,2441,2453,2458,2470,2482,2487,2501,2515,2528,2545,2559,2573,2586,2603,2608,2622,2636,2649,2662,2681,2687,2692,2705,2722,2737,2752,2766,2781,2795,2801,2806,2837,2851,2871,2884,2898,2904,2909,2923,2937,2950,2962,2967,2987,3010,3015,3033,3060,3065],{"__ignoreMap":90},[95,1903,1904,1906,1909,1911],{"class":97,"line":98},[95,1905,210],{"class":209},[95,1907,1908],{"class":213}," test, { expect } ",[95,1910,217],{"class":209},[95,1912,220],{"class":105},[95,1914,1915,1917,1919,1921],{"class":97,"line":223},[95,1916,210],{"class":209},[95,1918,1560],{"class":213},[95,1920,217],{"class":209},[95,1922,1565],{"class":105},[95,1924,1925,1927,1930,1932],{"class":97,"line":230},[95,1926,210],{"class":209},[95,1928,1929],{"class":213}," { joinURL, withoutTrailingSlash } ",[95,1931,217],{"class":209},[95,1933,1934],{"class":105}," 'ufo'\n",[95,1936,1937],{"class":97,"line":245},[95,1938,227],{"emptyLinePlaceholder":226},[95,1940,1941,1943,1946,1948,1950,1952,1954,1957],{"class":97,"line":257},[95,1942,1574],{"class":209},[95,1944,1945],{"class":263}," pages",[95,1947,714],{"class":209},[95,1949,1582],{"class":209},[95,1951,1585],{"class":101},[95,1953,636],{"class":213},[95,1955,1956],{"class":105},"'src\u002F**\u002F*.md'",[95,1958,694],{"class":213},[95,1960,1961],{"class":97,"line":269},[95,1962,227],{"emptyLinePlaceholder":226},[95,1964,1965,1968,1970,1972,1974,1976,1978],{"class":97,"line":286},[95,1966,1967],{"class":213},"pages.",[95,1969,1650],{"class":101},[95,1971,1653],{"class":213},[95,1973,651],{"class":650},[95,1975,1659],{"class":213},[95,1977,657],{"class":209},[95,1979,660],{"class":213},[95,1981,1982,1984,1986,1988,1990,1992,1994,1996,1998,2000,2002,2004,2006,2008,2010,2012,2014,2016,2018,2020,2022,2024],{"class":97,"line":308},[95,1983,708],{"class":209},[95,1985,1670],{"class":263},[95,1987,714],{"class":209},[95,1989,683],{"class":213},[95,1991,1678],{"class":101},[95,1993,636],{"class":213},[95,1995,1683],{"class":105},[95,1997,72],{"class":213},[95,1999,1688],{"class":105},[95,2001,1691],{"class":213},[95,2003,1678],{"class":101},[95,2005,636],{"class":213},[95,2007,1698],{"class":105},[95,2009,72],{"class":213},[95,2011,1688],{"class":105},[95,2013,1691],{"class":213},[95,2015,1678],{"class":101},[95,2017,636],{"class":213},[95,2019,1368],{"class":105},[95,2021,72],{"class":213},[95,2023,1688],{"class":105},[95,2025,694],{"class":213},[95,2027,2028],{"class":97,"line":318},[95,2029,227],{"emptyLinePlaceholder":226},[95,2031,2032,2034,2036,2039,2041,2043,2045,2047,2049,2051,2053,2056,2058,2060],{"class":97,"line":329},[95,2033,1380],{"class":101},[95,2035,636],{"class":213},[95,2037,2038],{"class":105},"`should have metadata (${",[95,2040,651],{"class":213},[95,2042,1735],{"class":105},[95,2044,72],{"class":213},[95,2046,644],{"class":209},[95,2048,647],{"class":213},[95,2050,651],{"class":650},[95,2052,72],{"class":213},[95,2054,2055],{"class":650},"request",[95,2057,654],{"class":213},[95,2059,657],{"class":209},[95,2061,660],{"class":213},[95,2063,2064],{"class":97,"line":340},[95,2065,1403],{"class":665},[95,2067,2068],{"class":97,"line":346},[95,2069,227],{"emptyLinePlaceholder":226},[95,2071,2072],{"class":97,"line":357},[95,2073,1412],{"class":665},[95,2075,2076,2078,2080,2082],{"class":97,"line":368},[95,2077,1417],{"class":209},[95,2079,683],{"class":213},[95,2081,686],{"class":101},[95,2083,1775],{"class":213},[95,2085,2086],{"class":97,"line":374},[95,2087,227],{"emptyLinePlaceholder":226},[95,2089,2090],{"class":97,"line":379},[95,2091,1436],{"class":665},[95,2093,2094,2096,2099,2101,2103,2105,2108],{"class":97,"line":385},[95,2095,1441],{"class":209},[95,2097,2098],{"class":263}," title",[95,2100,714],{"class":209},[95,2102,1582],{"class":209},[95,2104,683],{"class":213},[95,2106,2107],{"class":101},"title",[95,2109,777],{"class":213},[95,2111,2112,2115,2118,2121],{"class":97,"line":391},[95,2113,2114],{"class":101},"    expect",[95,2116,2117],{"class":213},"(title).",[95,2119,2120],{"class":101},"toBeTruthy",[95,2122,777],{"class":213},[95,2124,2125,2127,2130,2133,2135,2138,2141,2143],{"class":97,"line":402},[95,2126,2114],{"class":101},[95,2128,2129],{"class":213},"(title.",[95,2131,2132],{"class":101},"endsWith",[95,2134,636],{"class":213},[95,2136,2137],{"class":105},"' | Garabit'",[95,2139,2140],{"class":213},")).",[95,2142,2120],{"class":101},[95,2144,777],{"class":213},[95,2146,2147],{"class":97,"line":426},[95,2148,227],{"emptyLinePlaceholder":226},[95,2150,2151,2153,2156,2158,2160],{"class":97,"line":432},[95,2152,1441],{"class":209},[95,2154,2155],{"class":263}," ogTitle",[95,2157,714],{"class":209},[95,2159,1582],{"class":209},[95,2161,717],{"class":213},[95,2163,2164,2167,2170,2172,2175],{"class":97,"line":438},[95,2165,2166],{"class":213},"      .",[95,2168,2169],{"class":101},"locator",[95,2171,636],{"class":213},[95,2173,2174],{"class":105},"'meta[property=\"og:title\"]'",[95,2176,694],{"class":213},[95,2178,2179,2181,2184,2186,2189],{"class":97,"line":443},[95,2180,2166],{"class":213},[95,2182,2183],{"class":101},"getAttribute",[95,2185,636],{"class":213},[95,2187,2188],{"class":105},"'content'",[95,2190,694],{"class":213},[95,2192,2193,2195,2198,2200],{"class":97,"line":449},[95,2194,2114],{"class":101},[95,2196,2197],{"class":213},"(ogTitle).",[95,2199,2120],{"class":101},[95,2201,777],{"class":213},[95,2203,2204,2206,2209,2211,2213],{"class":97,"line":460},[95,2205,1441],{"class":209},[95,2207,2208],{"class":263}," twitterTitle",[95,2210,714],{"class":209},[95,2212,1582],{"class":209},[95,2214,717],{"class":213},[95,2216,2217,2219,2221,2223,2226],{"class":97,"line":470},[95,2218,2166],{"class":213},[95,2220,2169],{"class":101},[95,2222,636],{"class":213},[95,2224,2225],{"class":105},"'meta[name=\"twitter:title\"]'",[95,2227,694],{"class":213},[95,2229,2230,2232,2234,2236,2238],{"class":97,"line":481},[95,2231,2166],{"class":213},[95,2233,2183],{"class":101},[95,2235,636],{"class":213},[95,2237,2188],{"class":105},[95,2239,694],{"class":213},[95,2241,2242,2244,2247,2249],{"class":97,"line":492},[95,2243,2114],{"class":101},[95,2245,2246],{"class":213},"(twitterTitle).",[95,2248,2120],{"class":101},[95,2250,777],{"class":213},[95,2252,2253],{"class":97,"line":497},[95,2254,227],{"emptyLinePlaceholder":226},[95,2256,2257,2259,2261,2264,2267,2270,2272,2274],{"class":97,"line":1874},[95,2258,2114],{"class":101},[95,2260,2129],{"class":213},[95,2262,2263],{"class":101},"startsWith",[95,2265,2266],{"class":213},"(ogTitle",[95,2268,2269],{"class":209},"!",[95,2271,2140],{"class":213},[95,2273,2120],{"class":101},[95,2275,777],{"class":213},[95,2277,2279,2281,2283,2286],{"class":97,"line":2278},31,[95,2280,2114],{"class":101},[95,2282,2197],{"class":213},[95,2284,2285],{"class":101},"toBe",[95,2287,2288],{"class":213},"(twitterTitle)\n",[95,2290,2292],{"class":97,"line":2291},32,[95,2293,227],{"emptyLinePlaceholder":226},[95,2295,2297,2299,2302,2304,2306],{"class":97,"line":2296},33,[95,2298,1441],{"class":209},[95,2300,2301],{"class":263}," description",[95,2303,714],{"class":209},[95,2305,1582],{"class":209},[95,2307,717],{"class":213},[95,2309,2311,2313,2315,2317,2320],{"class":97,"line":2310},34,[95,2312,2166],{"class":213},[95,2314,2169],{"class":101},[95,2316,636],{"class":213},[95,2318,2319],{"class":105},"'meta[name=\"description\"]'",[95,2321,694],{"class":213},[95,2323,2325,2327,2329,2331,2333],{"class":97,"line":2324},35,[95,2326,2166],{"class":213},[95,2328,2183],{"class":101},[95,2330,636],{"class":213},[95,2332,2188],{"class":105},[95,2334,694],{"class":213},[95,2336,2338,2340,2343,2345],{"class":97,"line":2337},36,[95,2339,2114],{"class":101},[95,2341,2342],{"class":213},"(description).",[95,2344,2120],{"class":101},[95,2346,777],{"class":213},[95,2348,2350,2352,2355,2357,2359],{"class":97,"line":2349},37,[95,2351,1441],{"class":209},[95,2353,2354],{"class":263}," ogDescription",[95,2356,714],{"class":209},[95,2358,1582],{"class":209},[95,2360,717],{"class":213},[95,2362,2364,2366,2368,2370,2373],{"class":97,"line":2363},38,[95,2365,2166],{"class":213},[95,2367,2169],{"class":101},[95,2369,636],{"class":213},[95,2371,2372],{"class":105},"'meta[property=\"og:description\"]'",[95,2374,694],{"class":213},[95,2376,2378,2380,2382,2384,2386],{"class":97,"line":2377},39,[95,2379,2166],{"class":213},[95,2381,2183],{"class":101},[95,2383,636],{"class":213},[95,2385,2188],{"class":105},[95,2387,694],{"class":213},[95,2389,2391,2393,2396,2398],{"class":97,"line":2390},40,[95,2392,2114],{"class":101},[95,2394,2395],{"class":213},"(ogDescription).",[95,2397,2120],{"class":101},[95,2399,777],{"class":213},[95,2401,2403,2405,2408,2410,2412],{"class":97,"line":2402},41,[95,2404,1441],{"class":209},[95,2406,2407],{"class":263}," twitterDescription",[95,2409,714],{"class":209},[95,2411,1582],{"class":209},[95,2413,717],{"class":213},[95,2415,2417,2419,2421,2423,2426],{"class":97,"line":2416},42,[95,2418,2166],{"class":213},[95,2420,2169],{"class":101},[95,2422,636],{"class":213},[95,2424,2425],{"class":105},"'meta[name=\"twitter:description\"]'",[95,2427,694],{"class":213},[95,2429,2431,2433,2435,2437,2439],{"class":97,"line":2430},43,[95,2432,2166],{"class":213},[95,2434,2183],{"class":101},[95,2436,636],{"class":213},[95,2438,2188],{"class":105},[95,2440,694],{"class":213},[95,2442,2444,2446,2449,2451],{"class":97,"line":2443},44,[95,2445,2114],{"class":101},[95,2447,2448],{"class":213},"(twitterDescription).",[95,2450,2120],{"class":101},[95,2452,777],{"class":213},[95,2454,2456],{"class":97,"line":2455},45,[95,2457,227],{"emptyLinePlaceholder":226},[95,2459,2461,2463,2465,2467],{"class":97,"line":2460},46,[95,2462,2114],{"class":101},[95,2464,2342],{"class":213},[95,2466,2285],{"class":101},[95,2468,2469],{"class":213},"(ogDescription)\n",[95,2471,2473,2475,2477,2479],{"class":97,"line":2472},47,[95,2474,2114],{"class":101},[95,2476,2342],{"class":213},[95,2478,2285],{"class":101},[95,2480,2481],{"class":213},"(twitterDescription)\n",[95,2483,2485],{"class":97,"line":2484},48,[95,2486,227],{"emptyLinePlaceholder":226},[95,2488,2490,2492,2495,2497,2499],{"class":97,"line":2489},49,[95,2491,1441],{"class":209},[95,2493,2494],{"class":263}," twitterSite",[95,2496,714],{"class":209},[95,2498,1582],{"class":209},[95,2500,717],{"class":213},[95,2502,2504,2506,2508,2510,2513],{"class":97,"line":2503},50,[95,2505,2166],{"class":213},[95,2507,2169],{"class":101},[95,2509,636],{"class":213},[95,2511,2512],{"class":105},"'meta[name=\"twitter:site\"]'",[95,2514,694],{"class":213},[95,2516,2518,2520,2522,2524,2526],{"class":97,"line":2517},51,[95,2519,2166],{"class":213},[95,2521,2183],{"class":101},[95,2523,636],{"class":213},[95,2525,2188],{"class":105},[95,2527,694],{"class":213},[95,2529,2531,2533,2536,2538,2540,2543],{"class":97,"line":2530},52,[95,2532,2114],{"class":101},[95,2534,2535],{"class":213},"(twitterSite).",[95,2537,2285],{"class":101},[95,2539,636],{"class":213},[95,2541,2542],{"class":105},"'@soubiran_'",[95,2544,694],{"class":213},[95,2546,2548,2550,2553,2555,2557],{"class":97,"line":2547},53,[95,2549,1441],{"class":209},[95,2551,2552],{"class":263}," twitterCard",[95,2554,714],{"class":209},[95,2556,1582],{"class":209},[95,2558,717],{"class":213},[95,2560,2562,2564,2566,2568,2571],{"class":97,"line":2561},54,[95,2563,2166],{"class":213},[95,2565,2169],{"class":101},[95,2567,636],{"class":213},[95,2569,2570],{"class":105},"'meta[name=\"twitter:card\"]'",[95,2572,694],{"class":213},[95,2574,2576,2578,2580,2582,2584],{"class":97,"line":2575},55,[95,2577,2166],{"class":213},[95,2579,2183],{"class":101},[95,2581,636],{"class":213},[95,2583,2188],{"class":105},[95,2585,694],{"class":213},[95,2587,2589,2591,2594,2596,2598,2601],{"class":97,"line":2588},56,[95,2590,2114],{"class":101},[95,2592,2593],{"class":213},"(twitterCard).",[95,2595,2285],{"class":101},[95,2597,636],{"class":213},[95,2599,2600],{"class":105},"'summary_large_image'",[95,2602,694],{"class":213},[95,2604,2606],{"class":97,"line":2605},57,[95,2607,227],{"emptyLinePlaceholder":226},[95,2609,2611,2613,2616,2618,2620],{"class":97,"line":2610},58,[95,2612,1441],{"class":209},[95,2614,2615],{"class":263}," canonical",[95,2617,714],{"class":209},[95,2619,1582],{"class":209},[95,2621,717],{"class":213},[95,2623,2625,2627,2629,2631,2634],{"class":97,"line":2624},59,[95,2626,2166],{"class":213},[95,2628,2169],{"class":101},[95,2630,636],{"class":213},[95,2632,2633],{"class":105},"'link[rel=\"canonical\"]'",[95,2635,694],{"class":213},[95,2637,2639,2641,2643,2645,2647],{"class":97,"line":2638},60,[95,2640,2166],{"class":213},[95,2642,2183],{"class":101},[95,2644,636],{"class":213},[95,2646,793],{"class":105},[95,2648,694],{"class":213},[95,2650,2652,2654,2657,2659],{"class":97,"line":2651},61,[95,2653,2114],{"class":101},[95,2655,2656],{"class":213},"(canonical).",[95,2658,2285],{"class":101},[95,2660,2661],{"class":213},"(\n",[95,2663,2665,2668,2670,2673,2675,2678],{"class":97,"line":2664},62,[95,2666,2667],{"class":101},"      withoutTrailingSlash",[95,2669,636],{"class":213},[95,2671,2672],{"class":101},"joinURL",[95,2674,636],{"class":213},[95,2676,2677],{"class":105},"'https:\u002F\u002Fgarabit.barbapapazes.dev'",[95,2679,2680],{"class":213},", link)),\n",[95,2682,2684],{"class":97,"line":2683},63,[95,2685,2686],{"class":213},"    )\n",[95,2688,2690],{"class":97,"line":2689},64,[95,2691,227],{"emptyLinePlaceholder":226},[95,2693,2695,2697,2700,2702],{"class":97,"line":2694},65,[95,2696,1441],{"class":209},[95,2698,2699],{"class":263}," ogMetaTags",[95,2701,714],{"class":209},[95,2703,2704],{"class":213}," [\n",[95,2706,2708,2711,2714,2717,2720],{"class":97,"line":2707},66,[95,2709,2710],{"class":213},"      { name: ",[95,2712,2713],{"class":105},"'og:image:width'",[95,2715,2716],{"class":213},", value: ",[95,2718,2719],{"class":105},"'1200'",[95,2721,423],{"class":213},[95,2723,2725,2727,2730,2732,2735],{"class":97,"line":2724},67,[95,2726,2710],{"class":213},[95,2728,2729],{"class":105},"'og:image:height'",[95,2731,2716],{"class":213},[95,2733,2734],{"class":105},"'630'",[95,2736,423],{"class":213},[95,2738,2740,2742,2745,2747,2750],{"class":97,"line":2739},68,[95,2741,2710],{"class":213},[95,2743,2744],{"class":105},"'og:image:type'",[95,2746,2716],{"class":213},[95,2748,2749],{"class":105},"'image\u002Fpng'",[95,2751,423],{"class":213},[95,2753,2755,2757,2760,2762,2764],{"class":97,"line":2754},69,[95,2756,2710],{"class":213},[95,2758,2759],{"class":105},"'og:site_name'",[95,2761,2716],{"class":213},[95,2763,749],{"class":105},[95,2765,423],{"class":213},[95,2767,2769,2771,2774,2776,2779],{"class":97,"line":2768},70,[95,2770,2710],{"class":213},[95,2772,2773],{"class":105},"'og:type'",[95,2775,2716],{"class":213},[95,2777,2778],{"class":105},"'website'",[95,2780,423],{"class":213},[95,2782,2784,2786,2789,2791,2793],{"class":97,"line":2783},71,[95,2785,2710],{"class":213},[95,2787,2788],{"class":105},"'og:url'",[95,2790,2716],{"class":213},[95,2792,2677],{"class":105},[95,2794,423],{"class":213},[95,2796,2798],{"class":97,"line":2797},72,[95,2799,2800],{"class":213},"    ]\n",[95,2802,2804],{"class":97,"line":2803},73,[95,2805,227],{"emptyLinePlaceholder":226},[95,2807,2809,2812,2815,2817,2820,2823,2825,2828,2831,2834],{"class":97,"line":2808},74,[95,2810,2811],{"class":209},"    for",[95,2813,2814],{"class":213}," (",[95,2816,1574],{"class":209},[95,2818,2819],{"class":213}," { ",[95,2821,2822],{"class":263},"name",[95,2824,72],{"class":213},[95,2826,2827],{"class":263},"value",[95,2829,2830],{"class":213}," } ",[95,2832,2833],{"class":209},"of",[95,2835,2836],{"class":213}," ogMetaTags) {\n",[95,2838,2840,2842,2845,2847,2849],{"class":97,"line":2839},75,[95,2841,1789],{"class":209},[95,2843,2844],{"class":263}," metaTag",[95,2846,714],{"class":209},[95,2848,1582],{"class":209},[95,2850,717],{"class":213},[95,2852,2854,2857,2859,2861,2864,2866,2869],{"class":97,"line":2853},76,[95,2855,2856],{"class":213},"        .",[95,2858,2169],{"class":101},[95,2860,636],{"class":213},[95,2862,2863],{"class":105},"`meta[property=\"${",[95,2865,2822],{"class":213},[95,2867,2868],{"class":105},"}\"]`",[95,2870,694],{"class":213},[95,2872,2874,2876,2878,2880,2882],{"class":97,"line":2873},77,[95,2875,2856],{"class":213},[95,2877,2183],{"class":101},[95,2879,636],{"class":213},[95,2881,2188],{"class":105},[95,2883,694],{"class":213},[95,2885,2887,2890,2893,2895],{"class":97,"line":2886},78,[95,2888,2889],{"class":101},"      expect",[95,2891,2892],{"class":213},"(metaTag).",[95,2894,2285],{"class":101},[95,2896,2897],{"class":213},"(value)\n",[95,2899,2901],{"class":97,"line":2900},79,[95,2902,2903],{"class":213},"    }\n",[95,2905,2907],{"class":97,"line":2906},80,[95,2908,227],{"emptyLinePlaceholder":226},[95,2910,2912,2914,2917,2919,2921],{"class":97,"line":2911},81,[95,2913,1441],{"class":209},[95,2915,2916],{"class":263}," url",[95,2918,714],{"class":209},[95,2920,1582],{"class":209},[95,2922,717],{"class":213},[95,2924,2926,2928,2930,2932,2935],{"class":97,"line":2925},82,[95,2927,2166],{"class":213},[95,2929,2169],{"class":101},[95,2931,636],{"class":213},[95,2933,2934],{"class":105},"'meta[property=\"og:image\"]'",[95,2936,694],{"class":213},[95,2938,2940,2942,2944,2946,2948],{"class":97,"line":2939},83,[95,2941,2166],{"class":213},[95,2943,2183],{"class":101},[95,2945,636],{"class":213},[95,2947,2188],{"class":105},[95,2949,694],{"class":213},[95,2951,2953,2955,2958,2960],{"class":97,"line":2952},84,[95,2954,2114],{"class":101},[95,2956,2957],{"class":213},"(url).",[95,2959,2120],{"class":101},[95,2961,777],{"class":213},[95,2963,2965],{"class":97,"line":2964},85,[95,2966,227],{"emptyLinePlaceholder":226},[95,2968,2970,2972,2975,2977,2979,2982,2985],{"class":97,"line":2969},86,[95,2971,1441],{"class":209},[95,2973,2974],{"class":263}," image",[95,2976,714],{"class":209},[95,2978,1582],{"class":209},[95,2980,2981],{"class":213}," request.",[95,2983,2984],{"class":101},"get",[95,2986,2661],{"class":213},[95,2988,2990,2993,2995,2997,2999,3001,3003,3005,3007],{"class":97,"line":2989},87,[95,2991,2992],{"class":213},"      url",[95,2994,2269],{"class":209},[95,2996,54],{"class":213},[95,2998,1678],{"class":101},[95,3000,636],{"class":213},[95,3002,2677],{"class":105},[95,3004,72],{"class":213},[95,3006,352],{"class":105},[95,3008,3009],{"class":213},"),\n",[95,3011,3013],{"class":97,"line":3012},88,[95,3014,2686],{"class":213},[95,3016,3018,3020,3023,3026,3029,3031],{"class":97,"line":3017},89,[95,3019,2114],{"class":101},[95,3021,3022],{"class":213},"(image.",[95,3024,3025],{"class":101},"ok",[95,3027,3028],{"class":213},"()).",[95,3030,2120],{"class":101},[95,3032,777],{"class":213},[95,3034,3036,3038,3040,3043,3046,3049,3052,3054,3056,3058],{"class":97,"line":3035},90,[95,3037,2114],{"class":101},[95,3039,3022],{"class":213},[95,3041,3042],{"class":101},"headers",[95,3044,3045],{"class":213},"()[",[95,3047,3048],{"class":105},"'content-type'",[95,3050,3051],{"class":213},"]).",[95,3053,2285],{"class":101},[95,3055,636],{"class":213},[95,3057,2749],{"class":105},[95,3059,694],{"class":213},[95,3061,3063],{"class":97,"line":3062},91,[95,3064,1273],{"class":213},[95,3066,3068],{"class":97,"line":3067},92,[95,3069,500],{"class":213},[10,3071,3072,3073,3076],{},"This test even confirms the correct operation of automatic ",[14,3074,3075],{},"Open Graph image"," generation.",[56,3078,3080],{"id":3079},"continuous-integration","Continuous integration",[10,3082,3083,3084,3087],{},"To automate test execution upon code pushes, we employ ",[14,3085,3086],{},"GitHub Actions",". Playwright provides a GitHub Action workflow file, which we can modify to our specifications.",[84,3089,3093],{"className":3090,"code":3091,"filename":1541,"language":3092,"meta":90,"style":90},"language-yaml shiki shiki-themes github-light github-light github-dark has-highlighted","name: Playwright Tests\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  test:\n    timeout-minutes: 60\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4\n      - run: corepack enable\n      - uses: actions\u002Fsetup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4\n        with:\n          node-version: 20\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Install **Playwright Browsers**\n        run: pnpm exec **playwright install** --with-deps chrome # [!code highlight]\n\n      - name: Run **Playwright tests**\n        run: pnpm run **test:e2e** # [!code highlight]\n\n      - uses: actions\u002Fupload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4\n        if: always()\n        with:\n          name: playwright-report\n          path: playwright-report\u002F\n          retention-days: 30\n","yaml",[92,3094,3095,3105,3109,3117,3124,3131,3139,3146,3152,3158,3162,3169,3179,3189,3193,3200,3206,3216,3226,3233,3248,3260,3273,3280,3290,3300,3304,3315,3325,3329,3340,3351,3355,3366,3376,3380,3393,3403,3409,3419,3429],{"__ignoreMap":90},[95,3096,3097,3100,3102],{"class":97,"line":98},[95,3098,2822],{"class":3099},"sovSZ",[95,3101,535],{"class":213},[95,3103,3104],{"class":105},"Playwright Tests\n",[95,3106,3107],{"class":97,"line":223},[95,3108,227],{"emptyLinePlaceholder":226},[95,3110,3111,3114],{"class":97,"line":230},[95,3112,3113],{"class":263},"on",[95,3115,3116],{"class":213},":\n",[95,3118,3119,3122],{"class":97,"line":245},[95,3120,3121],{"class":3099},"  push",[95,3123,3116],{"class":213},[95,3125,3126,3129],{"class":97,"line":257},[95,3127,3128],{"class":3099},"    branches",[95,3130,3116],{"class":213},[95,3132,3133,3136],{"class":97,"line":269},[95,3134,3135],{"class":213},"      - ",[95,3137,3138],{"class":105},"main\n",[95,3140,3141,3144],{"class":97,"line":286},[95,3142,3143],{"class":3099},"  pull_request",[95,3145,3116],{"class":213},[95,3147,3148,3150],{"class":97,"line":308},[95,3149,3128],{"class":3099},[95,3151,3116],{"class":213},[95,3153,3154,3156],{"class":97,"line":318},[95,3155,3135],{"class":213},[95,3157,3138],{"class":105},[95,3159,3160],{"class":97,"line":329},[95,3161,227],{"emptyLinePlaceholder":226},[95,3163,3164,3167],{"class":97,"line":340},[95,3165,3166],{"class":3099},"concurrency",[95,3168,3116],{"class":213},[95,3170,3171,3174,3176],{"class":97,"line":346},[95,3172,3173],{"class":3099},"  group",[95,3175,535],{"class":213},[95,3177,3178],{"class":105},"${{ github.workflow }}-${{ github.ref }}\n",[95,3180,3181,3184,3186],{"class":97,"line":357},[95,3182,3183],{"class":3099},"  cancel-in-progress",[95,3185,535],{"class":213},[95,3187,3188],{"class":263},"true\n",[95,3190,3191],{"class":97,"line":368},[95,3192,227],{"emptyLinePlaceholder":226},[95,3194,3195,3198],{"class":97,"line":374},[95,3196,3197],{"class":3099},"jobs",[95,3199,3116],{"class":213},[95,3201,3202,3204],{"class":97,"line":379},[95,3203,1380],{"class":3099},[95,3205,3116],{"class":213},[95,3207,3208,3211,3213],{"class":97,"line":385},[95,3209,3210],{"class":3099},"    timeout-minutes",[95,3212,535],{"class":213},[95,3214,3215],{"class":263},"60\n",[95,3217,3218,3221,3223],{"class":97,"line":391},[95,3219,3220],{"class":3099},"    runs-on",[95,3222,535],{"class":213},[95,3224,3225],{"class":105},"ubuntu-latest\n",[95,3227,3228,3231],{"class":97,"line":402},[95,3229,3230],{"class":3099},"    steps",[95,3232,3116],{"class":213},[95,3234,3235,3237,3240,3242,3245],{"class":97,"line":426},[95,3236,3135],{"class":213},[95,3238,3239],{"class":3099},"uses",[95,3241,535],{"class":213},[95,3243,3244],{"class":105},"actions\u002Fcheckout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871",[95,3246,3247],{"class":665}," # v4\n",[95,3249,3250,3252,3255,3257],{"class":97,"line":432},[95,3251,3135],{"class":213},[95,3253,3254],{"class":3099},"run",[95,3256,535],{"class":213},[95,3258,3259],{"class":105},"corepack enable\n",[95,3261,3262,3264,3266,3268,3271],{"class":97,"line":438},[95,3263,3135],{"class":213},[95,3265,3239],{"class":3099},[95,3267,535],{"class":213},[95,3269,3270],{"class":105},"actions\u002Fsetup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6",[95,3272,3247],{"class":665},[95,3274,3275,3278],{"class":97,"line":443},[95,3276,3277],{"class":3099},"        with",[95,3279,3116],{"class":213},[95,3281,3282,3285,3287],{"class":97,"line":449},[95,3283,3284],{"class":3099},"          node-version",[95,3286,535],{"class":213},[95,3288,3289],{"class":263},"20\n",[95,3291,3292,3295,3297],{"class":97,"line":460},[95,3293,3294],{"class":3099},"          cache",[95,3296,535],{"class":213},[95,3298,3299],{"class":105},"pnpm\n",[95,3301,3302],{"class":97,"line":470},[95,3303,227],{"emptyLinePlaceholder":226},[95,3305,3306,3308,3310,3312],{"class":97,"line":481},[95,3307,3135],{"class":213},[95,3309,2822],{"class":3099},[95,3311,535],{"class":213},[95,3313,3314],{"class":105},"Install dependencies\n",[95,3316,3317,3320,3322],{"class":97,"line":492},[95,3318,3319],{"class":3099},"        run",[95,3321,535],{"class":213},[95,3323,3324],{"class":105},"pnpm install\n",[95,3326,3327],{"class":97,"line":497},[95,3328,227],{"emptyLinePlaceholder":226},[95,3330,3331,3333,3335,3337],{"class":97,"line":1874},[95,3332,3135],{"class":213},[95,3334,2822],{"class":3099},[95,3336,535],{"class":213},[95,3338,3339],{"class":105},"Install **Playwright Browsers**\n",[95,3341,3344,3346,3348],{"class":3342,"line":2278},[97,3343],"highlighted",[95,3345,3319],{"class":3099},[95,3347,535],{"class":213},[95,3349,3350],{"class":105},"pnpm exec **playwright install** --with-deps chrome",[95,3352,3353],{"class":97,"line":2291},[95,3354,227],{"emptyLinePlaceholder":226},[95,3356,3357,3359,3361,3363],{"class":97,"line":2296},[95,3358,3135],{"class":213},[95,3360,2822],{"class":3099},[95,3362,535],{"class":213},[95,3364,3365],{"class":105},"Run **Playwright tests**\n",[95,3367,3369,3371,3373],{"class":3368,"line":2310},[97,3343],[95,3370,3319],{"class":3099},[95,3372,535],{"class":213},[95,3374,3375],{"class":105},"pnpm run **test:e2e**",[95,3377,3378],{"class":97,"line":2324},[95,3379,227],{"emptyLinePlaceholder":226},[95,3381,3382,3384,3386,3388,3391],{"class":97,"line":2337},[95,3383,3135],{"class":213},[95,3385,3239],{"class":3099},[95,3387,535],{"class":213},[95,3389,3390],{"class":105},"actions\u002Fupload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882",[95,3392,3247],{"class":665},[95,3394,3395,3398,3400],{"class":97,"line":2349},[95,3396,3397],{"class":3099},"        if",[95,3399,535],{"class":213},[95,3401,3402],{"class":105},"always()\n",[95,3404,3405,3407],{"class":97,"line":2363},[95,3406,3277],{"class":3099},[95,3408,3116],{"class":213},[95,3410,3411,3414,3416],{"class":97,"line":2377},[95,3412,3413],{"class":3099},"          name",[95,3415,535],{"class":213},[95,3417,3418],{"class":105},"playwright-report\n",[95,3420,3421,3424,3426],{"class":97,"line":2390},[95,3422,3423],{"class":3099},"          path",[95,3425,535],{"class":213},[95,3427,3428],{"class":105},"playwright-report\u002F\n",[95,3430,3431,3434,3436],{"class":97,"line":2402},[95,3432,3433],{"class":3099},"          retention-days",[95,3435,535],{"class":213},[95,3437,3438],{"class":263},"30\n",[10,3440,3441,3442,3445,3446,3449],{},"We solely install the ",[14,3443,3444],{},"Chrome browser"," as it is the only one used in our tests, expediting the workflow. The command ",[92,3447,3448],{},"pnpm run test:e2e"," initiates the tests, and failing results are logged as artifacts for error analysis.",[593,3451,3453],{"id":3452},"conclusion","Conclusion",[10,3455,3456,3457,3459,3460,3463,3464,3466,3467,3469],{},"In this article, we've implemented automated testing for our blog using ",[14,3458,53],{},". We've configured Playwright for ",[14,3461,3462],{},"parallel test execution",", set up browsers, and run tests against production builds. We've crafted tests for headers, projects, blogs, and ",[14,3465,1886],{}," while establishing continuous integration with ",[14,3468,3086],{}," for automatic test execution. This approach maintains blog quality, prevents regressions, and streamlines the developmental process.",[3471,3472,3473],"style",{},"html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sIIMD, html code.shiki .sIIMD{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sP4rz, html code.shiki .sP4rz{--shiki-light:#E36209;--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sovSZ, html code.shiki .sovSZ{--shiki-light:#22863A;--shiki-default:#22863A;--shiki-dark:#85E89D}",{"title":90,"searchDepth":223,"depth":223,"links":3475},[3476,3477,3478,3486],{"id":58,"depth":223,"text":59},{"id":129,"depth":223,"text":130},{"id":582,"depth":223,"text":3479,"children":3480},"Writing tests",[3481,3483,3484,3485],{"id":595,"depth":230,"text":3482},"Header test",{"id":171,"depth":230,"text":1146},{"id":1326,"depth":230,"text":1327},{"id":1879,"depth":230,"text":1880},{"id":3079,"depth":223,"text":3080,"children":3487},[3488],{"id":3452,"depth":230,"text":3453},"aa5392e0-6287-4673-9365-34313f0af1fa","2024-11-12","Enhance web development with Playwright-induced automated testing. Elevate blog quality through comprehensive end-to-end and SEO tests.","md",{"branch":3494},"10.automate-testing",null,{},"\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fensure-blog-quality-with-playwright-automated-testing","---\ncontentId: aa5392e0-6287-4673-9365-34313f0af1fa\npart: 10\ntitle: Ensure Blog Quality with Playwright Automated Testing\ndescription: Enhance web development with Playwright-induced automated testing. Elevate blog quality through comprehensive end-to-end and SEO tests.\ngithub:\n  branch: 10.automate-testing\ndate: 2024-11-12\nseriesSlug: create-a-blog-with-vitepress-and-vue-js-from-scratch\n---\n\nWhile we have built a blog using **VitePress** and **Vue.js**, it is vital to confirm that it performs as expected. **Testing** is an essential component of **software development**, ensuring our blog operates correctly and efficiently.\n\nTesting each feature manually would be a labor-intensive and error-prone process. As we continue to refine our blog to meet ever-evolving requirements, **automated testing** becomes indispensable. It allows us to verify quickly that our blog functions as intended, even when modifications are made. This practice helps maintain quality, prevent regressions, and accelerate the development workflow.\n\nThe straightforward nature of this blog makes it an ideal candidate for beginners to implement **end-to-end testing**. This type of testing validates software functionality from a user's perspective, ensuring all integrated components work harmoniously.\n\n\u003CCalloutReadMore id=\"a4721c3e-e9c6-4025-ae82-9c44edd68d75\" \u002F>\n\nIn this article, we will explore automated testing utilizing **Playwright**.\n\n## Installing Playwright\n\n**Playwright** is a **Node.js library** designed to automate browsers, enabling us to script interactions with web pages such as clicking buttons, completing forms, and navigating between pages. Playwright is compatible with multiple browsers, including **Chromium**, **Firefox**, and **WebKit**.\n\nTo install Playwright, execute the following command:\n\n```bash [terminal]\npnpm create playwright\n```\n\nThis command prompts the creation of a tests folder in the root directory. We will accept the default folder name `tests`. It further queries whether we require a **GitHub Action** workflow file. We will select `Yes`. Lastly, it inquires if we wish to install the Playwright browsers. We will opt for `Yes`.\n\n## Configuring Playwright\n\nUpon installing Playwright, several files are generated, including `playwright.config.ts`, where we must make necessary adjustments to suit our needs.\n\nInitially, we will modify the `timeout` property to `4_000` milliseconds. Given the simplicity of our tests, a shorter timeout suffices, potentially accelerating test execution should they fail. The `workers` property will be set to `100%`, allowing Playwright to utilize all available CPU cores for parallel test execution. This configuration works because our tests are independent; we are creating a static site. Within the `use` property, define the `baseURL` as `http:\u002F\u002Flocalhost:4173`. This is VitePress's default port for the preview server, omitting the need for redundant URL specifications in each test. In the `projects` property, we will select only the **Google Chrome** browser, although additional browsers can be included at your discretion.\n\nFinally, adjust the `webServer` property to automatically build and preview our blog before test execution, ensuring it is updated. As VitePress behaves differently in **development** versus **production**, testing against the production build is preferable.\n\nUltimately, our `playwright.config.ts` file should resemble the following:\n\n```ts [playwright.config.ts]\nimport { defineConfig, devices } from '@playwright\u002Ftest'\n\nexport default defineConfig({\n  testDir: '.\u002Ftests',\n  fullyParallel: true,\n  forbidOnly: !!process.env.CI,\n  retries: process.env.CI ? 2 : 0,\n  timeout: 4_000,\n  workers: '100%',\n  reporter: 'html',\n  use: {\n    baseURL: 'http:\u002F\u002Flocalhost:4173',\n    trace: 'on-first-retry',\n  },\n\n  projects: [\n    {\n      name: 'Google Chrome',\n      use: { ...devices['Desktop Chrome'], channel: 'chrome' },\n    },\n  ],\n\n  webServer: {\n    command: 'npm run build && npm run preview',\n    url: 'http:\u002F\u002Flocalhost:4173',\n    reuseExistingServer: false,\n    timeout: 60_000,\n  },\n})\n```\n\nIn our `package.json` file, include the following scripts:\n\n```json [package.json]\n{\n  \"scripts\": {\n    \"test\": \"npm run test:e2e\",\n    \"test:e2e\": \"playwright test\",\n    \"test:e2e:ui\": \"playwright test --ui\"\n  }\n}\n```\n\nThe first script executes all tests, both unit and **end-to-end**. The second script specifically runs end-to-end tests. The third script allows running end-to-end tests with a graphical interface, useful during test development as it visualizes browser activity.\n\n## Writing **tests**\n\nWith **Playwright** now configured, we can proceed to write our tests. Let's commence with a simple test before progressing to more intricate ones.\n\n### Header **test**\n\nBegin by creating a `header.test.ts` file within the `tests` folder. These tests will confirm the correct display of our blog header with the anticipated links, ensuring header consistency post-refactoring.\n\n```ts [header.test.ts]\nimport { expect, test } from '@playwright\u002Ftest'\n\ntest('should have a link to the homepage', async ({ page }) => {\n  \u002F\u002F Arrange\n\n  \u002F\u002F Act\n  await page.goto('\u002F')\n\n  \u002F\u002F Assert\n  const headerHomeLink = page\n    .getByRole('banner')\n    .getByRole('link', { name: 'Garabit', exact: true })\n\n  await expect(headerHomeLink).toBeVisible()\n  await expect(headerHomeLink).toHaveAttribute('href', '\u002F')\n})\n```\n\nLet me elucidate this initial test. We utilize Playwright's `test` function to craft a test. The first argument describes the test, while the second is an asynchronous function receiving an object containing the `page` property. This object represents the Playwright page object, which interacts with the browser.\n\nIn our test, we firstly navigate to the homepage. We can use a relative URL due to the `baseURL` configuration in `playwright.config.ts`. Subsequently, we obtain the header element by its role, verifying its visibility and correct link. Employing role-based element selection ensures tests remain resilient amidst HTML structure changes and guarantees element accessibility.\n\nWe can conduct two additional tests to verify the presence of links to the blog and GitHub projects, similar to the first, but targeting different elements.\n\n```ts [playwright.config.ts]\ntest('should have a link to the blog', async ({ page }) => {\n  \u002F\u002F Arrange\n\n  \u002F\u002F Act\n  await page.goto('\u002F')\n\n  \u002F\u002F Assert\n  const headerBlogLink = page\n    .getByRole('banner')\n    .getByRole('link', { name: 'Blog', exact: true })\n\n  await expect(headerBlogLink).toBeVisible()\n  await expect(headerBlogLink).toHaveAttribute('href', '\u002Fblog')\n})\n\ntest('should have a link to the projects', async ({ page }) => {\n  \u002F\u002F Arrange\n\n  \u002F\u002F Act\n  await page.goto('\u002F')\n\n  \u002F\u002F Assert\n  const headerProjectsLink = page\n    .getByRole('banner')\n    .getByRole('link', { name: 'Projects', exact: true })\n\n  await expect(headerProjectsLink).toBeVisible()\n  await expect(headerProjectsLink).toHaveAttribute('href', '\u002Fprojects')\n})\n```\n\nExecute the tests using the command:\n\n```bash [terminal]\npnpm run test:e2e:ui # or pnpm run test:e2e\n```\n\nThis command will open a browser and execute the tests. A passing test will display a green checkmark beside it, whereas a failing test will show a red cross. Clicking on a test provides the error message details.\n\n### Projects\n\nNext, we can validate that users can navigate from the projects page back to the homepage using the \"Back to Home\" button. Create a `projects.test.ts` file within the `tests` folder with the following content:\n\n```ts [projects.test.ts]\nimport { expect, test } from '@playwright\u002Ftest'\n\ntest('should have a link to the homepage', async ({ page }) => {\n  \u002F\u002F Arrange\n\n  \u002F\u002F Act\n  await page.goto('\u002Fprojects')\n\n  \u002F\u002F Assert\n  const headerHomeLink = page.getByRole('link', {\n    name: 'Back to Home',\n    exact: true,\n  })\n\n  await expect(headerHomeLink).toBeVisible()\n  await expect(headerHomeLink).toHaveAttribute('href', '\u002F')\n})\n```\n\nUtilizing the `pnpm run test:e2e:ui` command will allow you to observe tests as they are created. As you develop them, you can re-run tests using the green play button to confirm they pass.\n\nIn this file, you may also consider evaluating the page title and ensuring the list of projects reflects the projects intended for display. Initially, prioritize testing non-visible elements like links as done previously, and incorporate tests when issues arise or code refactoring occurs.\n\n### Blog\n\nFollowing the procedure for the projects page, create a `blog.test.ts` file within the `tests` folder. Let's test the \"Back to Home\" button.\n\n```ts [blog.test.ts]\nimport { expect, test } from '@playwright\u002Ftest'\n\ntest.describe('index', () => {\n  test('should have a link to the homepage', async ({ page }) => {\n    \u002F\u002F Arrange\n\n    \u002F\u002F Act\n    await page.goto('\u002Fblog')\n\n    \u002F\u002F Assert\n    const headerHomeLink = page.getByRole('link', {\n      name: 'Back to Home',\n      exact: true,\n    })\n\n    await expect(headerHomeLink).toBeVisible()\n    await expect(headerHomeLink).toHaveAttribute('href', '\u002F')\n  })\n})\n```\n\nWe use a `test.describe` block to group similar tests, which is advantageous when handling multiple tests on the same page. In this file, we will write tests for both the blog index page and individual blog posts.\n\nRegarding the blog post page, we could examine whether each post contains a \"Back to Blog\" button. Should we attempt testing a single post, or should we try for all? How can we navigate to the blog post?\n\nOne approach is crafting a test that navigates to \u002Fblog and clicks on the first post, subsequently verifying the visibility and link accuracy of the \"Back to Blog\" button. This test effectively validates inter-page navigation but is not our current focus. Alternatively, we could select all posts and iterate through them, confirming consistent functionality.\n\nHowever, since VitePress generates the URL based on filename, we can exploit this aspect by using a glob pattern to retrieve all post filenames and iterate through them to check functionality. This efficient method accelerates testing.\n\n```ts [Example]\nimport { expect, test } from '@playwright\u002Ftest'\nimport { glob } from 'tinyglobby'\n\nconst posts = await glob('src\u002Fblog\u002F*.md')\n\ntest.describe('index', () => {\n  \u002F\u002F ...\n})\n\ntest.describe('show', () => {\n  posts.forEach((post) => {\n    const link = post.replace('src', '').replace('.md', '').replace('.md', '')\n\n    test(`should have a link to the blog index (${post})`, async ({ page }) => {\n      \u002F\u002F Arrange\n\n      \u002F\u002F Act\n      await page.goto(link)\n\n      \u002F\u002F Assert\n      const headerBlogLink = page.getByRole('link', {\n        name: 'Back to Blog',\n        exact: true,\n      })\n\n      await expect(headerBlogLink).toBeVisible()\n      await expect(headerBlogLink).toHaveAttribute('href', '\u002Fblog')\n    })\n  })\n})\n```\n\n### SEO\n\nUsing end-to-end testing for a static blog proves highly beneficial for verifying **SEO metadata**. We can check the title, description, and image accuracy of each page, ensuring optimal **SEO-friendliness**.\n\nManually checking each page's DOM for the correct tags is labor-intensive, but Playwright simplifies DOM manipulation, including hidden elements.\n\nBy applying the same techniques as on the blog post page, we can use a glob pattern to iterate through all pages, verifying the SEO metadata.\n\n```ts [Example]\nimport test, { expect } from '@playwright\u002Ftest'\nimport { glob } from 'tinyglobby'\nimport { joinURL, withoutTrailingSlash } from 'ufo'\n\nconst pages = await glob('src\u002F**\u002F*.md')\n\npages.forEach((page) => {\n  const link = page.replace('src', '').replace('.md', '').replace('index', '')\n\n  test(`should have metadata (${page})`, async ({ page, request }) => {\n    \u002F\u002F Arrange\n\n    \u002F\u002F Act\n    await page.goto(link)\n\n    \u002F\u002F Assert\n    const title = await page.title()\n    expect(title).toBeTruthy()\n    expect(title.endsWith(' | Garabit')).toBeTruthy()\n\n    const ogTitle = await page\n      .locator('meta[property=\"og:title\"]')\n      .getAttribute('content')\n    expect(ogTitle).toBeTruthy()\n    const twitterTitle = await page\n      .locator('meta[name=\"twitter:title\"]')\n      .getAttribute('content')\n    expect(twitterTitle).toBeTruthy()\n\n    expect(title.startsWith(ogTitle!)).toBeTruthy()\n    expect(ogTitle).toBe(twitterTitle)\n\n    const description = await page\n      .locator('meta[name=\"description\"]')\n      .getAttribute('content')\n    expect(description).toBeTruthy()\n    const ogDescription = await page\n      .locator('meta[property=\"og:description\"]')\n      .getAttribute('content')\n    expect(ogDescription).toBeTruthy()\n    const twitterDescription = await page\n      .locator('meta[name=\"twitter:description\"]')\n      .getAttribute('content')\n    expect(twitterDescription).toBeTruthy()\n\n    expect(description).toBe(ogDescription)\n    expect(description).toBe(twitterDescription)\n\n    const twitterSite = await page\n      .locator('meta[name=\"twitter:site\"]')\n      .getAttribute('content')\n    expect(twitterSite).toBe('@soubiran_')\n    const twitterCard = await page\n      .locator('meta[name=\"twitter:card\"]')\n      .getAttribute('content')\n    expect(twitterCard).toBe('summary_large_image')\n\n    const canonical = await page\n      .locator('link[rel=\"canonical\"]')\n      .getAttribute('href')\n    expect(canonical).toBe(\n      withoutTrailingSlash(joinURL('https:\u002F\u002Fgarabit.barbapapazes.dev', link)),\n    )\n\n    const ogMetaTags = [\n      { name: 'og:image:width', value: '1200' },\n      { name: 'og:image:height', value: '630' },\n      { name: 'og:image:type', value: 'image\u002Fpng' },\n      { name: 'og:site_name', value: 'Garabit' },\n      { name: 'og:type', value: 'website' },\n      { name: 'og:url', value: 'https:\u002F\u002Fgarabit.barbapapazes.dev' },\n    ]\n\n    for (const { name, value } of ogMetaTags) {\n      const metaTag = await page\n        .locator(`meta[property=\"${name}\"]`)\n        .getAttribute('content')\n      expect(metaTag).toBe(value)\n    }\n\n    const url = await page\n      .locator('meta[property=\"og:image\"]')\n      .getAttribute('content')\n    expect(url).toBeTruthy()\n\n    const image = await request.get(\n      url!.replace('https:\u002F\u002Fgarabit.barbapapazes.dev', 'http:\u002F\u002Flocalhost:4173'),\n    )\n    expect(image.ok()).toBeTruthy()\n    expect(image.headers()['content-type']).toBe('image\u002Fpng')\n  })\n})\n```\n\nThis test even confirms the correct operation of automatic **Open Graph image** generation.\n\n## Continuous integration\n\nTo automate test execution upon code pushes, we employ **GitHub Actions**. Playwright provides a GitHub Action workflow file, which we can modify to our specifications.\n\n```yaml [Example]\nname: Playwright Tests\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  test:\n    timeout-minutes: 60\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4\n      - run: corepack enable\n      - uses: actions\u002Fsetup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4\n        with:\n          node-version: 20\n          cache: pnpm\n\n      - name: Install dependencies\n        run: pnpm install\n\n      - name: Install **Playwright Browsers**\n        run: pnpm exec **playwright install** --with-deps chrome # [!code highlight]\n\n      - name: Run **Playwright tests**\n        run: pnpm run **test:e2e** # [!code highlight]\n\n      - uses: actions\u002Fupload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4\n        if: always()\n        with:\n          name: playwright-report\n          path: playwright-report\u002F\n          retention-days: 30\n```\n\nWe solely install the **Chrome browser** as it is the only one used in our tests, expediting the workflow. The command `pnpm run test:e2e` initiates the tests, and failing results are logged as artifacts for error analysis.\n\n### Conclusion\n\nIn this article, we've implemented automated testing for our blog using **Playwright**. We've configured Playwright for **parallel test execution**, set up browsers, and run tests against production builds. We've crafted tests for headers, projects, blogs, and **SEO metadata** while establishing continuous integration with **GitHub Actions** for automatic test execution. This approach maintains blog quality, prevents regressions, and streamlines the developmental process.\n",{"title":5,"description":3491},"create-a-blog-with-vitepress-and-vue-js-from-scratch",{"loc":3497},"series\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fensure-blog-quality-with-playwright-automated-testing","c6T96ihRsnPQkMtraVTsehqkqqWQ0Y63N5RrKeIP28c",{"overview":3505,"chapters":3741},{"id":3506,"title":3507,"body":3508,"contentId":3721,"date":3722,"description":3723,"extension":3492,"github":3724,"meetTheInstructor":3727,"meta":3728,"navigation":226,"part":3495,"path":3729,"rawbody":3730,"robots":3495,"schemaOrg":3495,"seo":3731,"seriesSlug":3500,"sitemap":3732,"stem":3735,"subtitle":3736,"topics":3737,"__hash__":3740},"series\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch.md","Create a Blog with VitePress and Vue.js from Scratch",{"type":7,"value":3509,"toc":3718},[3510,3513,3524,3540,3674,3684,3695,3702,3705,3708,3712],[10,3511,3512],{},"Hello and welcome! 👋",[10,3514,3515,3516,3518,3519,17,3521,3523],{},"You're about to embark on the \"Create a ",[14,3517,1327],{}," with ",[14,3520,16],{},[14,3522,20],{}," from Scratch\" series!",[10,3525,3526,3527,3535,3536,3539],{},"Throughout this journey, we will construct a practical blog from the ground up using ",[3528,3529,3533],"a",{"href":3530,"rel":3531},"https:\u002F\u002Fvitepress.dev\u002F",[3532],"nofollow",[14,3534,16],{},". We will explore a range of topics from initial configuration to deploying on ",[14,3537,3538],{},"Cloudflare Pages",", including:",[3541,3542,3543,3569,3579,3585,3598,3604,3613,3623,3633,3645,3659,3665],"ul",{},[3544,3545,3546,3549,3550,3553,3554,17,3561,3568],"li",{},[14,3547,3548],{},"Getting Started with VitePress: Project Setup and Essentials",": Learn to set up a fresh ",[14,3551,3552],{},"VitePress project"," by incorporating ",[3528,3555,3558],{"href":3556,"rel":3557},"https:\u002F\u002Ftailwindcss.com\u002F",[3532],[14,3559,3560],{},"Tailwind CSS",[3528,3562,3565],{"href":3563,"rel":3564},"https:\u002F\u002Fgithub.com\u002Funplugin\u002Funplugin-vue-components",[3532],[14,3566,3567],{},"unplugin-vue-components"," for an enhanced development process.",[3544,3570,3571,3574,3575],{},[14,3572,3573],{},"From Default to Custom: Building a VitePress Blog Theme",": We will entirely remove the default theme and create a personalized theme. ",[3576,3577,3578],"em",{},"You'll be surprised by its simplicity!",[3544,3580,3581,3584],{},[14,3582,3583],{},"Optimize Your VitePress Blog's Architecture Design",": Discover how to organize code and design your blog for scalability and maintainability.",[3544,3586,3587,3590,3591,54],{},[14,3588,3589],{},"Implementing Blog Index with VitePress and Tailwind CSS",": Create a list of blog posts. This will introduce ",[3528,3592,3595],{"href":3593,"rel":3594},"https:\u002F\u002Fvitepress.dev\u002Fguide\u002Fdata-loading",[3532],[14,3596,3597],{},"data loaders from VitePress",[3544,3599,3600,3603],{},[14,3601,3602],{},"Single Blog Rendering in VitePress with Tailwind Typography",": Create a page dedicated to reading each blog post.",[3544,3605,3606,3609,3610,3612],{},[14,3607,3608],{},"Deploy VitePress Blog Globally with Cloudflare Pages",": Integrate ",[14,3611,1886],{}," for improved search engine visibility, eliminating the need for manual updates.",[3544,3614,3615,3618,3619,3622],{},[14,3616,3617],{},"Showcase Your GitHub Projects on Your VitePress Blog",": Develop a page to display your ",[14,3620,3621],{},"GitHub"," endeavors, extending the use of data loaders and demonstrating their flexibility.",[3544,3624,3625,3628,3629,3632],{},[14,3626,3627],{},"Creating Open Graph Images Automatically for Each Blog Post",": Efficiently create ",[14,3630,3631],{},"Open Graph images"," for each post, saving time and enhancing appeal.",[3544,3634,3635,3637,3638,3644],{},[14,3636,3608],{},": Seamlessly deploy your blog to ",[3528,3639,3642],{"href":3640,"rel":3641},"https:\u002F\u002Fpages.cloudflare.com\u002F",[3532],[14,3643,3538],{},", achieving this in just a few clicks!",[3544,3646,3647,3649,3650,3518,3652,3658],{},[14,3648,5],{},": Implement ",[14,3651,42],{},[3528,3653,3656],{"href":3654,"rel":3655},"https:\u002F\u002Fplaywright.dev\u002F",[3532],[14,3657,53],{}," to ensure your blog functions as expected.",[3544,3660,3661,3664],{},[14,3662,3663],{},"An Internal Refactor for the Future Growth of our Blog",": Prepare your blog for future growth by refactoring the codebase, ensuring it remains maintainable and scalable.",[3544,3666,3667,3670,3671,3673],{},[14,3668,3669],{},"Migrating Our VitePress Blog to Tailwind CSS Version 4",": Upgrade our blog to the latest version of ",[14,3672,3560],{}," to leverage its new features and improvements.",[10,3675,3676,3677,3679,3680,3683],{},"By the conclusion, you will possess a fully operational and captivating ",[14,3678,1326],{},", allowing you to concentrate exclusively on producing ",[14,3681,3682],{},"content",", which is paramount. Simply write and publish, as the blog will autonomously manage the rest.",[3685,3686,3687,3692],"figure",{},[3688,3689],"img",{"alt":3690,"src":3691},"Home Page of our Blog","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fdeploy-vitepress-blog-globally-with-cloudflare-pages\u002Fvitepress-home.png",[3693,3694,3690],"figcaption",{},[10,3696,3697,3698,3701],{},"This series offers a detailed, step-by-step ",[14,3699,3700],{},"guide",". Rest assured, each aspect will be thoroughly elucidated, from selecting to implementing every feature. While each feature will be minimal and focused on the core, this does not mean we will forgo creating a visually pleasing and functional blog.",[10,3703,3704],{},"Should you have any inquiries, please feel free to engage in the comments section under each article.",[10,3706,3707],{},"I hope you find this series truly enjoyable! 🚀",[56,3709,3711],{"id":3710},"chapters","Chapters",[3713,3714],"series-chapters-list",{"className":3715},[3716,3717],"mx-auto","max-w-5xl",{"title":90,"searchDepth":223,"depth":223,"links":3719},[3720],{"id":3710,"depth":223,"text":3711},"43c95b33-041c-4108-ab98-0d21ef60ed7f","2024-10-10","Build a dynamic blog with VitePress and Vue.js from scratch. Learn setup, SEO, and deployment for a seamless blogging experience.",{"name":3725,"repository":3726},"garabit","barbapapazes\u002Fgarabit","I create this series because \u003Cstrong>VitePress\u003C\u002Fstrong> is way more powerful than it seems at the first glance. I was amazed by the \u003Cstrong>flexibility\u003C\u002Fstrong> and the \u003Cstrong>simplicity\u003C\u002Fstrong> of the tool while building my blog and wanted the community to know about it.",{},"\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch","---\ncontentId: 43c95b33-041c-4108-ab98-0d21ef60ed7f\ntitle: Create a Blog with VitePress and Vue.js from Scratch\nsubtitle: A new perspective on blogging with VitePress and Vue.js\ndescription: Build a dynamic blog with VitePress and Vue.js from scratch. Learn setup, SEO, and deployment for a seamless blogging experience.\ndate: 2024-10-10\ntopics:\n  - vuejs\n  - vitepress\n  - blog\ngithub:\n  name: garabit\n  repository: barbapapazes\u002Fgarabit\nmeetTheInstructor: I create this series because \u003Cstrong>VitePress\u003C\u002Fstrong> is way more powerful than it seems at the first glance. I was amazed by the \u003Cstrong>flexibility\u003C\u002Fstrong> and the \u003Cstrong>simplicity\u003C\u002Fstrong> of the tool while building my blog and wanted the community to know about it.\nseriesSlug: create-a-blog-with-vitepress-and-vue-js-from-scratch\n---\n\nHello and welcome! 👋\n\nYou're about to embark on the \"Create a **Blog** with **VitePress** and **Vue.js** from Scratch\" series!\n\nThroughout this journey, we will construct a practical blog from the ground up using [**VitePress**](https:\u002F\u002Fvitepress.dev\u002F). We will explore a range of topics from initial configuration to deploying on **Cloudflare Pages**, including:\n\n- **Getting Started with VitePress: Project Setup and Essentials**: Learn to set up a fresh **VitePress project** by incorporating [**Tailwind CSS**](https:\u002F\u002Ftailwindcss.com\u002F) and [**unplugin-vue-components**](https:\u002F\u002Fgithub.com\u002Funplugin\u002Funplugin-vue-components) for an enhanced development process.\n- **From Default to Custom: Building a VitePress Blog Theme**: We will entirely remove the default theme and create a personalized theme. _You'll be surprised by its simplicity!_\n- **Optimize Your VitePress Blog's Architecture Design**: Discover how to organize code and design your blog for scalability and maintainability.\n- **Implementing Blog Index with VitePress and Tailwind CSS**: Create a list of blog posts. This will introduce [**data loaders from VitePress**](https:\u002F\u002Fvitepress.dev\u002Fguide\u002Fdata-loading).\n- **Single Blog Rendering in VitePress with Tailwind Typography**: Create a page dedicated to reading each blog post.\n- **Deploy VitePress Blog Globally with Cloudflare Pages**: Integrate **SEO metadata** for improved search engine visibility, eliminating the need for manual updates.\n- **Showcase Your GitHub Projects on Your VitePress Blog**: Develop a page to display your **GitHub** endeavors, extending the use of data loaders and demonstrating their flexibility.\n- **Creating Open Graph Images Automatically for Each Blog Post**: Efficiently create **Open Graph images** for each post, saving time and enhancing appeal.\n- **Deploy VitePress Blog Globally with Cloudflare Pages**: Seamlessly deploy your blog to [**Cloudflare Pages**](https:\u002F\u002Fpages.cloudflare.com\u002F), achieving this in just a few clicks!\n- **Ensure Blog Quality with Playwright Automated Testing**: Implement **end-to-end testing** with [**Playwright**](https:\u002F\u002Fplaywright.dev\u002F) to ensure your blog functions as expected.\n- **An Internal Refactor for the Future Growth of our Blog**: Prepare your blog for future growth by refactoring the codebase, ensuring it remains maintainable and scalable.\n- **Migrating Our VitePress Blog to Tailwind CSS Version 4**: Upgrade our blog to the latest version of **Tailwind CSS** to leverage its new features and improvements.\n\nBy the conclusion, you will possess a fully operational and captivating **blog**, allowing you to concentrate exclusively on producing **content**, which is paramount. Simply write and publish, as the blog will autonomously manage the rest.\n\n![Home Page of our Blog](\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fdeploy-vitepress-blog-globally-with-cloudflare-pages\u002Fvitepress-home.png)\n\nThis series offers a detailed, step-by-step **guide**. Rest assured, each aspect will be thoroughly elucidated, from selecting to implementing every feature. While each feature will be minimal and focused on the core, this does not mean we will forgo creating a visually pleasing and functional blog.\n\nShould you have any inquiries, please feel free to engage in the comments section under each article.\n\nI hope you find this series truly enjoyable! 🚀\n\n## Chapters\n\n::series-chapters-list\n---\nclass: mx-auto max-w-5xl\n---\n::\n",{"title":3507,"description":3723},{"loc":3729,"images":3733},[3734],{"loc":3691},"series\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch","A new perspective on blogging with VitePress and Vue.js",[3738,3739,1326],"vuejs","vitepress","H9cubHgLKM0Siblzkwf7mDsFVYr2CLbh_ciFOpQrSVk",[3742,3748,3754,3760,3766,3772,3779,3785,3791,3797,3799,3806],{"contentId":3743,"title":3548,"description":3744,"path":3745,"part":98,"github":3746,"topics":3495},"b1b99d95-ac6d-4f25-a121-0851988102a2","From setup to styling with Tailwind CSS and automatic Vue imports, build your content-driven site effortlessly.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fgetting-started-with-vitepress-project-setup-and-essentials",{"branch":3747},"01.project-initialization",{"contentId":3749,"title":3573,"description":3750,"path":3751,"part":223,"github":3752,"topics":3495},"172f2a41-2f7c-44e9-855d-322adc536279","Step-by-step VitePress theme customization: guide to building a unique theme layout, adding Markdown content, and removing defaults.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Ffrom-default-to-custom-building-a-vitepress-blog-theme",{"branch":3753},"02.the-basics-for-a-custom-theme",{"contentId":3755,"title":3583,"description":3756,"path":3757,"part":230,"github":3758,"topics":3495},"900d11a5-ff68-4cc9-8ace-66a5cb1577fa","Discover how to optimize your VitePress blog's architecture design with scalable solutions and efficient Vite plugin integration.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Foptimize-your-vitepress-blog-architecture-design",{"branch":3759},"03.define-the-design-of-the-blog-architecture",{"contentId":3761,"title":3589,"description":3762,"path":3763,"part":245,"github":3764,"topics":3495},"4d93a3c5-f3ff-4ff6-a569-5234ef805850","Learn to create a list of blog articles using VitePress, a crucial feature for any content-centric website. Utilize data loaders to load articles.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fimplementing-blog-index-with-vitepress-and-tailwind-css",{"branch":3765},"04.comprehensive-guide-to-listing-blog-articles",{"contentId":3767,"title":3602,"description":3768,"path":3769,"part":257,"github":3770,"topics":3495},"15b9a49c-b9fb-4d76-a08d-2acaf55ff205","Enhance your VitePress blog with Tailwind Typography. Learn to render markdown beautifully with syntax highlights.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fsingle-blog-rendering-in-vitepress-with-tailwind-typography",{"branch":3771},"05.read-a-single-blog-article",{"contentId":3773,"title":3774,"description":3775,"path":3776,"part":269,"github":3777,"topics":3495},"66af9aaf-d6d3-4151-a51b-806835988340","Enhance Website Visibility: SEO Metadata and Sitemap","Enhance website traffic through strategic SEO metadata and sitemaps for improved indexing. Learn how to automate metadata generation for each page.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fenhance-website-visibility-seo-metadata-and-sitemap",{"branch":3778},"06.seo-metadata-and-sitemap",{"contentId":3780,"title":3617,"description":3781,"path":3782,"part":286,"github":3783,"topics":3495},"a4a933b8-07a5-4587-ad54-c3f9e30cbf45","Enhance your VitePress blog with GitHub projects. Learn API data retrieval and how to display your projects on your blog.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fshowcase-your-github-projects-on-your-vitepress-blog",{"branch":3784},"07.showcase-your-github-projects",{"contentId":3786,"title":3627,"description":3787,"path":3788,"part":308,"github":3789,"topics":3495},"c76a349e-a495-4890-ab05-3e8b6bb90add","Learn how to dynamically generate Open Graph images for each blog post, enhancing the visual appeal when sharing content on social media.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fcreating-open-graph-images-automatically-for-each-blog-post",{"branch":3790},"08.automatically-generated-open-graph-images",{"contentId":3792,"title":3608,"description":3793,"path":3794,"part":318,"github":3795,"topics":3495},"c05ae463-c5ae-4c43-872d-bb05263c7f74","Deploy the blog to Cloudflare Pages for global accessibility. Discover how to deploy the blog to Cloudflare Pages and share it worldwide with ease.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fdeploy-vitepress-blog-globally-with-cloudflare-pages",{"branch":3796},"09.share-the-blog-globally",{"contentId":3489,"title":5,"description":3491,"path":3497,"part":329,"github":3798,"topics":3495},{"branch":3494},{"contentId":3800,"title":3801,"description":3802,"path":3803,"part":340,"github":3804,"topics":3495},"5b1b6117-14f0-4f1d-ba13-5b3583f341bf","An Internal Refactor for the Future Growth of Our Blog","Prepare your blog for future growth by refactoring the codebase to ensure it remains maintainable and scalable.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fan-internal-refactor-for-the-future-growth-of-our-blog",{"branch":3805},"11.internal-refactor",{"contentId":3807,"title":3669,"description":3808,"path":3809,"part":346,"github":3810,"topics":3495},"3499bbd1-20a6-43f0-9bb7-be1da2bb6eac","A step-by-step guide on upgrading our VitePress blog to Tailwind CSS 4.0 to leverage its latest features and improvements.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fmigrating-our-vitepress-blog-to-tailwind-css-version-4",{"branch":3811},"12.migration-to-tailwind-css-4",{"id":3813,"title":3814,"body":3815,"contentId":47,"date":4730,"description":4731,"extension":3492,"meta":4732,"navigation":226,"path":4733,"rawbody":4734,"readingTime":329,"robots":3495,"schemaOrg":3495,"seo":4735,"sitemap":4736,"stem":4741,"__hash__":4742},"posts\u002Fposts\u002Ftesting-is-more-larger-than-just-writing-some-tests.md","Testing is More Larger Than Just Writing Some Tests",{"type":7,"value":3816,"toc":4726},[3817,3825,3828,3831,3886,3893,3896,3900,3903,3909,3931,4270,4277,4439,4445,4451,4460,4463,4475,4483,4486,4500,4506,4512,4518,4526,4529,4536,4547,4550,4553,4556,4559,4562,4579,4592,4600,4606,4613,4617,4620,4623,4705,4711,4714,4723],[3818,3819,3822],"callout",{"icon":3820,"color":3821},"i-ph-info-duotone","info",[10,3823,3824],{},"I am not a testing expert. I am merely sharing my thoughts on testing as a developer, in an article I would have appreciated when I began coding.",[10,3826,3827],{},"I started coding six years ago. Since then, I've heard a lot about testing, but I have seen few real and practical examples.",[10,3829,3830],{},"In many articles I read, tests look like this:",[84,3832,3837],{"className":3833,"code":3834,"filename":3835,"language":3836,"meta":90,"style":90},"language-js shiki shiki-themes github-light github-light github-dark","it('should return 2 when 1 + 1', () => {\n  expect(1 + 1).toBe(2)\n})\n","A simple arithmetic test","js",[92,3838,3839,3855,3882],{"__ignoreMap":90},[95,3840,3841,3844,3846,3849,3851,3853],{"class":97,"line":98},[95,3842,3843],{"class":101},"it",[95,3845,636],{"class":213},[95,3847,3848],{"class":105},"'should return 2 when 1 + 1'",[95,3850,1371],{"class":213},[95,3852,657],{"class":209},[95,3854,660],{"class":213},[95,3856,3857,3860,3862,3865,3868,3871,3873,3875,3877,3880],{"class":97,"line":223},[95,3858,3859],{"class":101},"  expect",[95,3861,636],{"class":213},[95,3863,3864],{"class":263},"1",[95,3866,3867],{"class":209}," +",[95,3869,3870],{"class":263}," 1",[95,3872,1691],{"class":213},[95,3874,2285],{"class":101},[95,3876,636],{"class":213},[95,3878,3879],{"class":263},"2",[95,3881,694],{"class":213},[95,3883,3884],{"class":97,"line":230},[95,3885,500],{"class":213},[10,3887,3888,3889,3892],{},"This is ",[14,3890,3891],{},"far from real-world scenarios"," and does not help in understanding the true value of testing.",[10,3894,3895],{},"I have to admit, when I don't comprehend something, I avoid using it. Nevertheless, since I first encountered the concept of testing, it has lingered in my mind, prompting me to gather knowledge about it.",[56,3897,3899],{"id":3898},"a-long-journey","A long journey",[10,3901,3902],{},"I first heard about testing when I learned Vue 2 in 2019. In the tooling section, under the \"Single File Component\" page, I found a section dedicated to \"Testing.\"",[10,3904,3905,3906],{},"I think I read the beginning of the page but never went further. There were too many new concepts to grasp, too many tools to learn, and too many choices to make. ",[3576,3907,3908],{},"At that time, I understood that front-end testing is by far the most challenging part of testing.",[10,3910,3911,3912,3917,3918,3923,3924,3927,3928],{},"In 2020, with some friends, we developed a tutoring platform. The API server was built with ",[3528,3913,3916],{"href":3914,"rel":3915},"https:\u002F\u002Fcrow.docs.feathersjs.com\u002F",[3532],"Feathers.js 4",". At that time, I was still grappling with testing. I remember looking for ",[3528,3919,3922],{"href":3920,"rel":3921},"https:\u002F\u002Fcrow.docs.feathersjs.com\u002Fguides\u002Fbasics\u002Ftesting.html#writing-tests",[3532],"the testing page in the Feathers.js documentation"," and even reading it. Despite not fully understanding it, I wrote many tests. It was a real struggle because the distinction between unit tests and integration tests was unclear to me, and running them in a CI was very difficult. ",[3576,3925,3926],{},"I was using MongoDB and Azure CI. Looking back, I think I wanted to endure pain."," I also remember trying to achieve 100% coverage. ",[3576,3929,3930],{},"I was so naive.",[84,3932,3935],{"className":200,"code":3933,"filename":3934,"language":202,"meta":90,"style":90},"it('should patch', async () => {\n  expect.assertions(5)\n\n  const patchedResult: Department = await app\n    .service(serviceName)\n    .patch(result._id, anotherDepartment)\n\n  expect(patchedResult).toBeDefined()\n  expect(patchedResult).toHaveProperty('_id')\n  expect(patchedResult).toHaveProperty(\n    'name',\n    anotherDepartment.name.toLowerCase()\n  )\n  expect(patchedResult).toHaveProperty('createdAt')\n  expect(patchedResult).toHaveProperty('updatedAt')\n})\n\nit('should delete', async () => {\n  expect.assertions(5)\n\n  const deleteResult: Department = await app\n    .service(serviceName)\n    .remove(result._id)\n\n  expect(deleteResult).toBeDefined()\n  expect(deleteResult).toHaveProperty('_id')\n  expect(deleteResult).toHaveProperty('name', result.name.toLowerCase())\n  expect(deleteResult).toHaveProperty('createdAt')\n  expect(deleteResult).toHaveProperty('updatedAt')\n})\n","Department patch test",[92,3936,3937,3957,3972,3976,3996,4006,4016,4020,4032,4048,4058,4065,4075,4080,4095,4110,4114,4118,4137,4149,4153,4170,4178,4188,4192,4203,4217,4238,4252,4266],{"__ignoreMap":90},[95,3938,3939,3941,3943,3946,3948,3950,3953,3955],{"class":97,"line":98},[95,3940,3843],{"class":101},[95,3942,636],{"class":213},[95,3944,3945],{"class":105},"'should patch'",[95,3947,72],{"class":213},[95,3949,644],{"class":209},[95,3951,3952],{"class":213}," () ",[95,3954,657],{"class":209},[95,3956,660],{"class":213},[95,3958,3959,3962,3965,3967,3970],{"class":97,"line":223},[95,3960,3961],{"class":213},"  expect.",[95,3963,3964],{"class":101},"assertions",[95,3966,636],{"class":213},[95,3968,3969],{"class":263},"5",[95,3971,694],{"class":213},[95,3973,3974],{"class":97,"line":230},[95,3975,227],{"emptyLinePlaceholder":226},[95,3977,3978,3980,3983,3986,3989,3991,3993],{"class":97,"line":245},[95,3979,708],{"class":209},[95,3981,3982],{"class":263}," patchedResult",[95,3984,3985],{"class":209},":",[95,3987,3988],{"class":101}," Department",[95,3990,714],{"class":209},[95,3992,1582],{"class":209},[95,3994,3995],{"class":213}," app\n",[95,3997,3998,4000,4003],{"class":97,"line":257},[95,3999,722],{"class":213},[95,4001,4002],{"class":101},"service",[95,4004,4005],{"class":213},"(serviceName)\n",[95,4007,4008,4010,4013],{"class":97,"line":269},[95,4009,722],{"class":213},[95,4011,4012],{"class":101},"patch",[95,4014,4015],{"class":213},"(result._id, anotherDepartment)\n",[95,4017,4018],{"class":97,"line":286},[95,4019,227],{"emptyLinePlaceholder":226},[95,4021,4022,4024,4027,4030],{"class":97,"line":308},[95,4023,3859],{"class":101},[95,4025,4026],{"class":213},"(patchedResult).",[95,4028,4029],{"class":101},"toBeDefined",[95,4031,777],{"class":213},[95,4033,4034,4036,4038,4041,4043,4046],{"class":97,"line":318},[95,4035,3859],{"class":101},[95,4037,4026],{"class":213},[95,4039,4040],{"class":101},"toHaveProperty",[95,4042,636],{"class":213},[95,4044,4045],{"class":105},"'_id'",[95,4047,694],{"class":213},[95,4049,4050,4052,4054,4056],{"class":97,"line":329},[95,4051,3859],{"class":101},[95,4053,4026],{"class":213},[95,4055,4040],{"class":101},[95,4057,2661],{"class":213},[95,4059,4060,4063],{"class":97,"line":340},[95,4061,4062],{"class":105},"    'name'",[95,4064,254],{"class":213},[95,4066,4067,4070,4073],{"class":97,"line":346},[95,4068,4069],{"class":213},"    anotherDepartment.name.",[95,4071,4072],{"class":101},"toLowerCase",[95,4074,777],{"class":213},[95,4076,4077],{"class":97,"line":357},[95,4078,4079],{"class":213},"  )\n",[95,4081,4082,4084,4086,4088,4090,4093],{"class":97,"line":368},[95,4083,3859],{"class":101},[95,4085,4026],{"class":213},[95,4087,4040],{"class":101},[95,4089,636],{"class":213},[95,4091,4092],{"class":105},"'createdAt'",[95,4094,694],{"class":213},[95,4096,4097,4099,4101,4103,4105,4108],{"class":97,"line":374},[95,4098,3859],{"class":101},[95,4100,4026],{"class":213},[95,4102,4040],{"class":101},[95,4104,636],{"class":213},[95,4106,4107],{"class":105},"'updatedAt'",[95,4109,694],{"class":213},[95,4111,4112],{"class":97,"line":379},[95,4113,500],{"class":213},[95,4115,4116],{"class":97,"line":385},[95,4117,227],{"emptyLinePlaceholder":226},[95,4119,4120,4122,4124,4127,4129,4131,4133,4135],{"class":97,"line":391},[95,4121,3843],{"class":101},[95,4123,636],{"class":213},[95,4125,4126],{"class":105},"'should delete'",[95,4128,72],{"class":213},[95,4130,644],{"class":209},[95,4132,3952],{"class":213},[95,4134,657],{"class":209},[95,4136,660],{"class":213},[95,4138,4139,4141,4143,4145,4147],{"class":97,"line":402},[95,4140,3961],{"class":213},[95,4142,3964],{"class":101},[95,4144,636],{"class":213},[95,4146,3969],{"class":263},[95,4148,694],{"class":213},[95,4150,4151],{"class":97,"line":426},[95,4152,227],{"emptyLinePlaceholder":226},[95,4154,4155,4157,4160,4162,4164,4166,4168],{"class":97,"line":432},[95,4156,708],{"class":209},[95,4158,4159],{"class":263}," deleteResult",[95,4161,3985],{"class":209},[95,4163,3988],{"class":101},[95,4165,714],{"class":209},[95,4167,1582],{"class":209},[95,4169,3995],{"class":213},[95,4171,4172,4174,4176],{"class":97,"line":438},[95,4173,722],{"class":213},[95,4175,4002],{"class":101},[95,4177,4005],{"class":213},[95,4179,4180,4182,4185],{"class":97,"line":443},[95,4181,722],{"class":213},[95,4183,4184],{"class":101},"remove",[95,4186,4187],{"class":213},"(result._id)\n",[95,4189,4190],{"class":97,"line":449},[95,4191,227],{"emptyLinePlaceholder":226},[95,4193,4194,4196,4199,4201],{"class":97,"line":460},[95,4195,3859],{"class":101},[95,4197,4198],{"class":213},"(deleteResult).",[95,4200,4029],{"class":101},[95,4202,777],{"class":213},[95,4204,4205,4207,4209,4211,4213,4215],{"class":97,"line":470},[95,4206,3859],{"class":101},[95,4208,4198],{"class":213},[95,4210,4040],{"class":101},[95,4212,636],{"class":213},[95,4214,4045],{"class":105},[95,4216,694],{"class":213},[95,4218,4219,4221,4223,4225,4227,4230,4233,4235],{"class":97,"line":481},[95,4220,3859],{"class":101},[95,4222,4198],{"class":213},[95,4224,4040],{"class":101},[95,4226,636],{"class":213},[95,4228,4229],{"class":105},"'name'",[95,4231,4232],{"class":213},", result.name.",[95,4234,4072],{"class":101},[95,4236,4237],{"class":213},"())\n",[95,4239,4240,4242,4244,4246,4248,4250],{"class":97,"line":492},[95,4241,3859],{"class":101},[95,4243,4198],{"class":213},[95,4245,4040],{"class":101},[95,4247,636],{"class":213},[95,4249,4092],{"class":105},[95,4251,694],{"class":213},[95,4253,4254,4256,4258,4260,4262,4264],{"class":97,"line":497},[95,4255,3859],{"class":101},[95,4257,4198],{"class":213},[95,4259,4040],{"class":101},[95,4261,636],{"class":213},[95,4263,4107],{"class":105},[95,4265,694],{"class":213},[95,4267,4268],{"class":97,"line":1874},[95,4269,500],{"class":213},[10,4271,4272,4273,4276],{},"But the more I added features to the platform, the more I realized the value of testing. It can ",[14,4274,4275],{},"ensure that a new feature does not break an existing one"," without the hassle of manually testing everything. This was particularly evident because Feathers.js has many intricate parts and services that can easily break when one part is modified.",[84,4278,4281],{"className":200,"code":4279,"filename":4280,"language":202,"meta":90,"style":90},"export default {\n  before: {\n    all: [],\n    find: [],\n    get: [],\n    create: [checkData(checkDataOptions)],\n    update: [disallow()],\n    patch: [checkData(checkDataOptions)],\n    remove: [],\n  },\n\n  after: {\n    all: [],\n    find: [iff(isProvider('external'), pickResult())],\n    get: [iff(isProvider('external'), pickResult())],\n    create: [],\n    update: [],\n    patch: [],\n    remove: [],\n  },\n}\n","Feathers service hooks",[92,4282,4283,4291,4296,4301,4306,4311,4322,4333,4342,4347,4351,4355,4360,4364,4391,4412,4417,4422,4427,4431,4435],{"__ignoreMap":90},[95,4284,4285,4287,4289],{"class":97,"line":98},[95,4286,233],{"class":209},[95,4288,236],{"class":209},[95,4290,660],{"class":213},[95,4292,4293],{"class":97,"line":223},[95,4294,4295],{"class":213},"  before: {\n",[95,4297,4298],{"class":97,"line":230},[95,4299,4300],{"class":213},"    all: [],\n",[95,4302,4303],{"class":97,"line":245},[95,4304,4305],{"class":213},"    find: [],\n",[95,4307,4308],{"class":97,"line":257},[95,4309,4310],{"class":213},"    get: [],\n",[95,4312,4313,4316,4319],{"class":97,"line":269},[95,4314,4315],{"class":213},"    create: [",[95,4317,4318],{"class":101},"checkData",[95,4320,4321],{"class":213},"(checkDataOptions)],\n",[95,4323,4324,4327,4330],{"class":97,"line":286},[95,4325,4326],{"class":213},"    update: [",[95,4328,4329],{"class":101},"disallow",[95,4331,4332],{"class":213},"()],\n",[95,4334,4335,4338,4340],{"class":97,"line":308},[95,4336,4337],{"class":213},"    patch: [",[95,4339,4318],{"class":101},[95,4341,4321],{"class":213},[95,4343,4344],{"class":97,"line":318},[95,4345,4346],{"class":213},"    remove: [],\n",[95,4348,4349],{"class":97,"line":329},[95,4350,371],{"class":213},[95,4352,4353],{"class":97,"line":340},[95,4354,227],{"emptyLinePlaceholder":226},[95,4356,4357],{"class":97,"line":346},[95,4358,4359],{"class":213},"  after: {\n",[95,4361,4362],{"class":97,"line":357},[95,4363,4300],{"class":213},[95,4365,4366,4369,4372,4374,4377,4379,4382,4385,4388],{"class":97,"line":368},[95,4367,4368],{"class":213},"    find: [",[95,4370,4371],{"class":101},"iff",[95,4373,636],{"class":213},[95,4375,4376],{"class":101},"isProvider",[95,4378,636],{"class":213},[95,4380,4381],{"class":105},"'external'",[95,4383,4384],{"class":213},"), ",[95,4386,4387],{"class":101},"pickResult",[95,4389,4390],{"class":213},"())],\n",[95,4392,4393,4396,4398,4400,4402,4404,4406,4408,4410],{"class":97,"line":374},[95,4394,4395],{"class":213},"    get: [",[95,4397,4371],{"class":101},[95,4399,636],{"class":213},[95,4401,4376],{"class":101},[95,4403,636],{"class":213},[95,4405,4381],{"class":105},[95,4407,4384],{"class":213},[95,4409,4387],{"class":101},[95,4411,4390],{"class":213},[95,4413,4414],{"class":97,"line":379},[95,4415,4416],{"class":213},"    create: [],\n",[95,4418,4419],{"class":97,"line":385},[95,4420,4421],{"class":213},"    update: [],\n",[95,4423,4424],{"class":97,"line":391},[95,4425,4426],{"class":213},"    patch: [],\n",[95,4428,4429],{"class":97,"line":402},[95,4430,4346],{"class":213},[95,4432,4433],{"class":97,"line":426},[95,4434,371],{"class":213},[95,4436,4437],{"class":97,"line":432},[95,4438,572],{"class":213},[10,4440,4441,4442],{},"The complexity of the app grew exponentially, feature after feature. This was more related to the architecture of Feathers.js, but combined with the challenges of writing efficient tests, it was a nightmare to maintain. ",[3576,4443,4444],{},"Each change broke so many tests that I was unsure if the app was working or not.",[10,4446,4447,4448],{},"From that point on, I decided the ability to test the app was a requirement for choosing a new stack. ",[3576,4449,4450],{},"And this will be a long journey because in 2024, I'm still learning a lot but writing more tests than ever.",[10,4452,4453,4454,4459],{},"At the beginning of 2021, Strapi was gaining popularity, and I looked at it as a potential replacement for Feathers.js, still to build the tutoring platform. I was pleased to see that Strapi has a ",[3528,4455,4458],{"href":4456,"rel":4457},"https:\u002F\u002Fdocs.strapi.io\u002Fdev-docs\u002Ftesting",[3532],"dedicated page for testing"," in the documentation.",[10,4461,4462],{},"So, I jumped in and created a new project with Strapi to get started and see if testing was effective.",[10,4464,4465,4466,4471,4472],{},"Sadly, I immediately ",[3528,4467,4470],{"href":4468,"rel":4469},"https:\u002F\u002Fgithub.com\u002Fstrapi\u002Fstrapi\u002Fissues\u002F9376",[3532],"encountered a problem that never got resolved",". Unable to run tests, I gave up and the tutoring platform was never migrated to Strapi, nor deployed to production. ",[3576,4473,4474],{},"I learned a lot from this side project. Often, the journey is more important than the destination.",[3685,4476,4477,4481],{},[3688,4478],{"alt":4479,"src":4480},"Screenshot of this issue 9376","\u002Fposts\u002Ftesting-is-more-larger-than-just-writing-some-tests\u002Fstrapi-testing-issue.png",[3693,4482,4479],{},[10,4484,4485],{},"So let's recap:",[3541,4487,4488,4491,4494,4497],{},[3544,4489,4490],{},"I only know JavaScript.",[3544,4492,4493],{},"Feathers.js has a complex architecture and poor documentation on testing.",[3544,4495,4496],{},"Strapi has good documentation on testing, but I was unable to run tests.",[3544,4498,4499],{},"I need to find a new side project to learn testing.",[10,4501,4502,4503],{},"Some months later, I heard about AdonisJS. I don't remember how, but at that time, version 5 was in beta. It was a breath of fresh air because the documentation looked very good, and the framework was rich in features. Full of features, yes, but the testing part was not there yet. ",[3576,4504,4505],{},"The core team released Japa a year later. It's a pleasant testing framework for Node.js.",[10,4507,4508,4509],{},"Regardless, I learned so much about backend development and architecture with AdonisJS that testing was clearly not a priority. This was the first time I could split features and avoid internal dependencies. Much cleaner and easier to maintain than Feathers.js or NestJS. ",[3576,4510,4511],{},"Yes, I also tried NestJS, but this framework is a real joke to me.",[10,4513,4514,4515],{},"By the end of August 2021, I embarked on a new side project called Insamee, a student ecosystem. That was the successor of the tutoring platform. The architecture is important to clarify. Initially, it was an API server with AdonisJS and four front-end apps using Nuxt. ",[3576,4516,4517],{},"Overkill and overly complicated, as I realize now.",[3685,4519,4520,4524],{},[3688,4521],{"alt":4522,"src":4523},"Screenshot of Insamee","\u002Fposts\u002Ftesting-is-more-larger-than-just-writing-some-tests\u002Finsameeapp.png",[3693,4525,4522],{},[10,4527,4528],{},"By the end of 2021, I rewrote the project from scratch using only Adonis and a single server. No more tests.",[10,4530,4531,4532,4535],{},"I managed to pull myself away from school classes to focus on my project. ",[3576,4533,4534],{},"A real opportunity."," To validate my semester, I had to write a report and make a live presentation. During the presentation, I didn't talk about testing (there were none). However, the jury questioned me about it. I just said the runner was not ready yet, so I hadn't written any tests. They took a few minutes to explain that testing is crucial, and I clearly understood that a real and professional project must have tests, it's non-negotiable. In my mind, something clicked.",[10,4537,4538,4539,4542,4543,4546],{},"Subsequently, from April to August 2022, I did a four-month internship at a consulting company in Paris. I was responsible for building, from scratch, an administration panel for a high-performance computing cluster project using Angular 14. This was a first for me. I had never used Angular before. It took me months to grasp the concept of ",[92,4540,4541],{},"TestBed"," and the dependency injection (DI) system. ",[3576,4544,4545],{},"I was so lost, but later, I discovered that dependency injection is important."," During that period, I learned concepts but had no real practice.",[10,4548,4549],{},"In 2024, I did my six-month internship at a Swiss cloud company. I was part of a team developing components for other projects. This is where I truly began to appreciate testing. Firstly, the coverage was at 90%. This means if the coverage drops below 90%, you have no other choice than to write tests to submit an MR. The project was eight months old, so there were plenty of tests to reference. I also wrote many end-to-end tests using Playwright.",[10,4551,4552],{},"Simultaneously, I watched a live stream by Romain Lanz discussing \"writing testable code\" and explaining the DI in Adonis. With these explanations and the concrete examples I encountered during my internship, things started to come together and make sense.",[10,4554,4555],{},"This year, at Devoxx 2024, I tried to attend as many talks about TDD and DDD as possible. Hearing experts discuss real-world examples and how they architect their apps to make them testable and future-proof was truly enlightening.",[45,4557],{"id":4558},"08852918-9829-4658-97b3-1aabede8e9fe",[10,4560,4561],{},"Despite all this, I still struggle to find genuine and practical examples of testing. It's so frustrating to know the theory but not be able to apply it.",[10,4563,4564,4565,4570,4571],{},"But I believe that to learn, there is nothing more effective than taking action. So I took the framework I know best, Nuxt, and started experimenting with the ",[3528,4566,4569],{"href":4567,"rel":4568},"https:\u002F\u002Fgithub.com\u002Fnuxt\u002Ftest-utils",[3532],"available testing tools",". I used the end-to-end integration with Playwright, but it was not a pleasant experience. Tests took so long to run. ",[3576,4572,4573,4574,54],{},"Strangely, the experience during my internship felt the opposite. I discovered that the Nuxt integration rebuilds the application before every test. I made ",[3528,4575,4578],{"href":4576,"rel":4577},"https:\u002F\u002Fgithub.com\u002Fnuxt\u002Ftest-utils\u002Fpull\u002F881",[3532],"a PR to allow the runner to reuse an existing server",[10,4580,4581,4582,4587,4588,4591],{},"Simultaneously, I received feedback about ",[3528,4583,4586],{"href":4584,"rel":4585},"https:\u002F\u002Fgithub.com\u002FBarbapapazes\u002Fplausible-tracker",[3532],"my fork of the Plausible tracker",". Some bugs were reported, and new features were requested. The problem was the project had no tests, and I clearly remembered how painful it was on the tutoring platform. I also noticed I hadn't touched the project for a while, and manual testing wouldn't be enough to ensure the quality of the project in the long term. ",[3576,4589,4590],{},"When you haven't touched a project for some time, you have to relearn everything. With reliable tests, you can be confident that the project works as expected, even after refactoring, bug fixes, and new features."," I decided to write tests before touching anything else. It took me three days, but now, I'm confident that the project works as expected. This is satisfying, and there is no more fear of touching the project.",[3685,4593,4594,4598],{},[3688,4595],{"alt":4596,"src":4597},"Passing tests of Plausible Tracker","\u002Fposts\u002Ftesting-is-more-larger-than-just-writing-some-tests\u002Fplausible-tracker-passing-tests.png",[3693,4599,4596],{},[10,4601,4602,4603],{},"Finally, around the same time, I discovered Laracasts. I learned PHP and encountered testing in Laravel. It was eye-opening. The testing is well explained, writing tests, even with a database, is easy, and it runs so fast. Writing tests with Pest is truly enjoyable. ",[3576,4604,4605],{},"If you have never tried it, you should.",[3818,4607,4611],{"icon":4608,"ariaLabel":4609,"to":4610},"i-ph-book-duotone","Try Laracats","https:\u002F\u002Flaracasts.com\u002Freferral\u002FBarbapapazes",[10,4612,4609],{},[56,4614,4616],{"id":4615},"understanding-the-value-of-testing","Understanding the value of testing",[10,4618,4619],{},"It took me six years to grasp the value of testing and write meaningful tests. Is that long? I'm not sure. It demonstrates that learning is an iterative process, with failures and retries. With perseverance, you finally get there.",[10,4621,4622],{},"Throughout this journey, I asked myself many questions. Here are some answers I would have loved to find earlier.",[4624,4625,4626,4629,4635,4641,4647,4653,4659,4665,4671,4687,4693,4699],"ol",{},[3544,4627,4628],{},"Testing does not have to be difficult.",[3544,4630,4631,4632,54],{},"However, testing is more challenging than ",[92,4633,4634],{},"expect(1 + 1).toBe(2)",[3544,4636,4637,4638],{},"The difficulty of testing often relates to the application's architecture and the ability to separate features. ",[3576,4639,4640],{},"The more modular the app is, the easier it is to test.",[3544,4642,4643,4644],{},"Before choosing a tool, consider the ability to test your app. ",[3576,4645,4646],{},"If you can't test it, it's not worth it.",[3544,4648,4649,4650],{},"No tests are acceptable. ",[3576,4651,4652],{},"It's a trade-off. Use it wisely.",[3544,4654,4655,4656],{},"Rule 5 does not invalidate rule 4 or rule 3. ",[3576,4657,4658],{},"If you end up writing tests, you will thank yourself.",[3544,4660,4661,4662],{},"Aiming for 100% coverage is meaningless by itself. ",[3576,4663,4664],{},"It's a trap that can lead to poor practices.",[3544,4666,4667,4668],{},"Both unit, integration, and end-to-end tests are valuable. ",[3576,4669,4670],{},"Choose the one that best fits your needs.",[3544,4672,4673,4674,72,4677,76,4680,4683,4684],{},"Structure your test with the ",[92,4675,4676],{},"arrange",[92,4678,4679],{},"act",[92,4681,4682],{},"assert"," method. ",[3576,4685,4686],{},"It's a good method for organizing your test and starting to write them.",[3544,4688,4689,4690,4692],{},"Write the ",[92,4691,4682],{}," part first.",[3544,4694,4695,4696],{},"Think of a test as a description of a specification of the application. ",[3576,4697,4698],{},"My app should display\u002Fdo this when this happens.",[3544,4700,4701,4702],{},"And more importantly, writing testable code before writing tests. ",[3576,4703,4704],{},"This approach will make your code more readable, maintainable, and testable.",[10,4706,4707,4708],{},"Finally, do not attempt to test everything from day one in this journey. Start small, learn, write simple unit tests, understand how to modularize your code, and progress from there. ",[3576,4709,4710],{},"It's a long journey, but it's worth it.",[10,4712,4713],{},"I'm still learning a lot, but I'm confident that I'm on the right path. See you in the next article!",[10,4715,4716],{},[3576,4717,4718,4719,54],{},"Laracasts is the best resource I've found for learning testing. PHP is great, and learning general concepts is even better. ",[3528,4720,4722],{"href":4610,"rel":4721},[3532],"Try it now",[3471,4724,4725],{},"html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sIIMD, html code.shiki .sIIMD{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":90,"searchDepth":223,"depth":223,"links":4727},[4728,4729],{"id":3898,"depth":223,"text":3899},{"id":4615,"depth":223,"text":4616},"2024-08-30","Testing is a journey, a lengthy expedition to uncover how the architecture and dependencies of an application can directly impact its quality and testability.",{},"\u002Fposts\u002Ftesting-is-more-larger-than-just-writing-some-tests","---\ncontentId: a4721c3e-e9c6-4025-ae82-9c44edd68d75\ntitle: Testing is More Larger Than Just Writing Some Tests\ndescription: Testing is a journey, a lengthy expedition to uncover how the architecture and dependencies of an application can directly impact its quality and testability.\ndate: 2024-08-30\n---\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nI am not a testing expert. I am merely sharing my thoughts on testing as a developer, in an article I would have appreciated when I began coding.\n::\nI started coding six years ago. Since then, I've heard a lot about testing, but I have seen few real and practical examples.\n\nIn many articles I read, tests look like this:\n\n```js [A simple arithmetic test]\nit('should return 2 when 1 + 1', () => {\n  expect(1 + 1).toBe(2)\n})\n```\n\nThis is **far from real-world scenarios** and does not help in understanding the true value of testing.\n\nI have to admit, when I don't comprehend something, I avoid using it. Nevertheless, since I first encountered the concept of testing, it has lingered in my mind, prompting me to gather knowledge about it.\n\n## A long journey\n\nI first heard about testing when I learned Vue 2 in 2019. In the tooling section, under the \"Single File Component\" page, I found a section dedicated to \"Testing.\"\n\nI think I read the beginning of the page but never went further. There were too many new concepts to grasp, too many tools to learn, and too many choices to make. _At that time, I understood that front-end testing is by far the most challenging part of testing._\n\nIn 2020, with some friends, we developed a tutoring platform. The API server was built with [Feathers.js 4](https:\u002F\u002Fcrow.docs.feathersjs.com\u002F). At that time, I was still grappling with testing. I remember looking for [the testing page in the Feathers.js documentation](https:\u002F\u002Fcrow.docs.feathersjs.com\u002Fguides\u002Fbasics\u002Ftesting.html#writing-tests) and even reading it. Despite not fully understanding it, I wrote many tests. It was a real struggle because the distinction between unit tests and integration tests was unclear to me, and running them in a CI was very difficult. _I was using MongoDB and Azure CI. Looking back, I think I wanted to endure pain._ I also remember trying to achieve 100% coverage. _I was so naive._\n\n```ts [Department patch test]\nit('should patch', async () => {\n  expect.assertions(5)\n\n  const patchedResult: Department = await app\n    .service(serviceName)\n    .patch(result._id, anotherDepartment)\n\n  expect(patchedResult).toBeDefined()\n  expect(patchedResult).toHaveProperty('_id')\n  expect(patchedResult).toHaveProperty(\n    'name',\n    anotherDepartment.name.toLowerCase()\n  )\n  expect(patchedResult).toHaveProperty('createdAt')\n  expect(patchedResult).toHaveProperty('updatedAt')\n})\n\nit('should delete', async () => {\n  expect.assertions(5)\n\n  const deleteResult: Department = await app\n    .service(serviceName)\n    .remove(result._id)\n\n  expect(deleteResult).toBeDefined()\n  expect(deleteResult).toHaveProperty('_id')\n  expect(deleteResult).toHaveProperty('name', result.name.toLowerCase())\n  expect(deleteResult).toHaveProperty('createdAt')\n  expect(deleteResult).toHaveProperty('updatedAt')\n})\n```\n\nBut the more I added features to the platform, the more I realized the value of testing. It can **ensure that a new feature does not break an existing one** without the hassle of manually testing everything. This was particularly evident because Feathers.js has many intricate parts and services that can easily break when one part is modified.\n\n```ts [Feathers service hooks]\nexport default {\n  before: {\n    all: [],\n    find: [],\n    get: [],\n    create: [checkData(checkDataOptions)],\n    update: [disallow()],\n    patch: [checkData(checkDataOptions)],\n    remove: [],\n  },\n\n  after: {\n    all: [],\n    find: [iff(isProvider('external'), pickResult())],\n    get: [iff(isProvider('external'), pickResult())],\n    create: [],\n    update: [],\n    patch: [],\n    remove: [],\n  },\n}\n```\n\nThe complexity of the app grew exponentially, feature after feature. This was more related to the architecture of Feathers.js, but combined with the challenges of writing efficient tests, it was a nightmare to maintain. _Each change broke so many tests that I was unsure if the app was working or not._\n\nFrom that point on, I decided the ability to test the app was a requirement for choosing a new stack. _And this will be a long journey because in 2024, I'm still learning a lot but writing more tests than ever._\n\nAt the beginning of 2021, Strapi was gaining popularity, and I looked at it as a potential replacement for Feathers.js, still to build the tutoring platform. I was pleased to see that Strapi has a [dedicated page for testing](https:\u002F\u002Fdocs.strapi.io\u002Fdev-docs\u002Ftesting) in the documentation.\n\nSo, I jumped in and created a new project with Strapi to get started and see if testing was effective.\n\nSadly, I immediately [encountered a problem that never got resolved](https:\u002F\u002Fgithub.com\u002Fstrapi\u002Fstrapi\u002Fissues\u002F9376). Unable to run tests, I gave up and the tutoring platform was never migrated to Strapi, nor deployed to production. _I learned a lot from this side project. Often, the journey is more important than the destination._\n\n![Screenshot of this issue 9376](\u002Fposts\u002Ftesting-is-more-larger-than-just-writing-some-tests\u002Fstrapi-testing-issue.png)\n\nSo let's recap:\n\n- I only know JavaScript.\n- Feathers.js has a complex architecture and poor documentation on testing.\n- Strapi has good documentation on testing, but I was unable to run tests.\n- I need to find a new side project to learn testing.\n\nSome months later, I heard about AdonisJS. I don't remember how, but at that time, version 5 was in beta. It was a breath of fresh air because the documentation looked very good, and the framework was rich in features. Full of features, yes, but the testing part was not there yet. _The core team released Japa a year later. It's a pleasant testing framework for Node.js._\n\nRegardless, I learned so much about backend development and architecture with AdonisJS that testing was clearly not a priority. This was the first time I could split features and avoid internal dependencies. Much cleaner and easier to maintain than Feathers.js or NestJS. _Yes, I also tried NestJS, but this framework is a real joke to me._\n\nBy the end of August 2021, I embarked on a new side project called Insamee, a student ecosystem. That was the successor of the tutoring platform. The architecture is important to clarify. Initially, it was an API server with AdonisJS and four front-end apps using Nuxt. _Overkill and overly complicated, as I realize now._\n\n![Screenshot of Insamee](\u002Fposts\u002Ftesting-is-more-larger-than-just-writing-some-tests\u002Finsameeapp.png)\n\nBy the end of 2021, I rewrote the project from scratch using only Adonis and a single server. No more tests.\n\nI managed to pull myself away from school classes to focus on my project. _A real opportunity._ To validate my semester, I had to write a report and make a live presentation. During the presentation, I didn't talk about testing (there were none). However, the jury questioned me about it. I just said the runner was not ready yet, so I hadn't written any tests. They took a few minutes to explain that testing is crucial, and I clearly understood that a real and professional project must have tests, it's non-negotiable. In my mind, something clicked.\n\nSubsequently, from April to August 2022, I did a four-month internship at a consulting company in Paris. I was responsible for building, from scratch, an administration panel for a high-performance computing cluster project using Angular 14. This was a first for me. I had never used Angular before. It took me months to grasp the concept of `TestBed` and the dependency injection (DI) system. _I was so lost, but later, I discovered that dependency injection is important._ During that period, I learned concepts but had no real practice.\n\nIn 2024, I did my six-month internship at a Swiss cloud company. I was part of a team developing components for other projects. This is where I truly began to appreciate testing. Firstly, the coverage was at 90%. This means if the coverage drops below 90%, you have no other choice than to write tests to submit an MR. The project was eight months old, so there were plenty of tests to reference. I also wrote many end-to-end tests using Playwright.\n\nSimultaneously, I watched a live stream by Romain Lanz discussing \"writing testable code\" and explaining the DI in Adonis. With these explanations and the concrete examples I encountered during my internship, things started to come together and make sense.\n\nThis year, at Devoxx 2024, I tried to attend as many talks about TDD and DDD as possible. Hearing experts discuss real-world examples and how they architect their apps to make them testable and future-proof was truly enlightening.\n\n\u003CCalloutReadMore id=\"08852918-9829-4658-97b3-1aabede8e9fe\" \u002F>\n\nDespite all this, I still struggle to find genuine and practical examples of testing. It's so frustrating to know the theory but not be able to apply it.\n\nBut I believe that to learn, there is nothing more effective than taking action. So I took the framework I know best, Nuxt, and started experimenting with the [available testing tools](https:\u002F\u002Fgithub.com\u002Fnuxt\u002Ftest-utils). I used the end-to-end integration with Playwright, but it was not a pleasant experience. Tests took so long to run. _Strangely, the experience during my internship felt the opposite. I discovered that the Nuxt integration rebuilds the application before every test. I made [a PR to allow the runner to reuse an existing server](https:\u002F\u002Fgithub.com\u002Fnuxt\u002Ftest-utils\u002Fpull\u002F881)._\n\nSimultaneously, I received feedback about [my fork of the Plausible tracker](https:\u002F\u002Fgithub.com\u002FBarbapapazes\u002Fplausible-tracker). Some bugs were reported, and new features were requested. The problem was the project had no tests, and I clearly remembered how painful it was on the tutoring platform. I also noticed I hadn't touched the project for a while, and manual testing wouldn't be enough to ensure the quality of the project in the long term. _When you haven't touched a project for some time, you have to relearn everything. With reliable tests, you can be confident that the project works as expected, even after refactoring, bug fixes, and new features._ I decided to write tests before touching anything else. It took me three days, but now, I'm confident that the project works as expected. This is satisfying, and there is no more fear of touching the project.\n\n![Passing tests of Plausible Tracker](\u002Fposts\u002Ftesting-is-more-larger-than-just-writing-some-tests\u002Fplausible-tracker-passing-tests.png)\n\nFinally, around the same time, I discovered Laracasts. I learned PHP and encountered testing in Laravel. It was eye-opening. The testing is well explained, writing tests, even with a database, is easy, and it runs so fast. Writing tests with Pest is truly enjoyable. _If you have never tried it, you should._\n\n::callout{icon=\"i-ph-book-duotone\" to=\"https:\u002F\u002Flaracasts.com\u002Freferral\u002FBarbapapazes\" aria-label=\"Try Laracats\"}\nTry Laracats\n::\n\n## Understanding the value of testing\n\nIt took me six years to grasp the value of testing and write meaningful tests. Is that long? I'm not sure. It demonstrates that learning is an iterative process, with failures and retries. With perseverance, you finally get there.\n\nThroughout this journey, I asked myself many questions. Here are some answers I would have loved to find earlier.\n\n1. Testing does not have to be difficult.\n2. However, testing is more challenging than `expect(1 + 1).toBe(2)`.\n3. The difficulty of testing often relates to the application's architecture and the ability to separate features. _The more modular the app is, the easier it is to test._\n4. Before choosing a tool, consider the ability to test your app. _If you can't test it, it's not worth it._\n5. No tests are acceptable. _It's a trade-off. Use it wisely._\n6. Rule 5 does not invalidate rule 4 or rule 3. _If you end up writing tests, you will thank yourself._\n7. Aiming for 100% coverage is meaningless by itself. _It's a trap that can lead to poor practices._\n8. Both unit, integration, and end-to-end tests are valuable. _Choose the one that best fits your needs._\n9. Structure your test with the `arrange`, `act`, and `assert` method. _It's a good method for organizing your test and starting to write them._\n10. Write the `assert` part first.\n11. Think of a test as a description of a specification of the application. _My app should display\u002Fdo this when this happens._\n12. And more importantly, writing testable code before writing tests. _This approach will make your code more readable, maintainable, and testable._\n\nFinally, do not attempt to test everything from day one in this journey. Start small, learn, write simple unit tests, understand how to modularize your code, and progress from there. _It's a long journey, but it's worth it._\n\nI'm still learning a lot, but I'm confident that I'm on the right path. See you in the next article!\n\n_Laracasts is the best resource I've found for learning testing. PHP is great, and learning general concepts is even better. [Try it now](https:\u002F\u002Flaracasts.com\u002Freferral\u002FBarbapapazes)._\n",{"title":3814,"description":4731},{"loc":4733,"images":4737},[4738,4739,4740],{"loc":4480},{"loc":4523},{"loc":4597},"posts\u002Ftesting-is-more-larger-than-just-writing-some-tests","6a0X_-60OjERkPMnlCJtQkvLP9KTm7aNGktdFL3QAkE",1795016692939]