[{"data":1,"prerenderedAt":941},["ShallowReactive",2],{"authors":3,"article-2022-11-17-nodejs-test-runner":331},[4,23,35,48,61,73,85,98,111,124,136,148,161,173,185,197,209,221,233,245,258,270,282,295,307,319],{"id":5,"title":6,"body":7,"description":11,"extension":14,"meta":15,"name":16,"navigation":17,"path":18,"readingTime":19,"seo":20,"stem":21,"__hash__":22},"authors\u002Fauthors\u002Falexandre-guillon.md","Software Engineer",{"type":8,"value":9,"toc":10},"minimark",[],{"title":11,"searchDepth":12,"depth":12,"links":13},"",2,[],"md",{},"Alexandre Guillon",true,"\u002Fauthors\u002Falexandre-guillon",1,{"title":6,"description":11},"authors\u002Falexandre-guillon","4tf48mjyjFNqItOHaulICbrjeCyMag1o6801uHeTz98",{"id":24,"title":6,"body":25,"description":11,"extension":14,"meta":29,"name":30,"navigation":17,"path":31,"readingTime":19,"seo":32,"stem":33,"__hash__":34},"authors\u002Fauthors\u002Falexis-ablain.md",{"type":8,"value":26,"toc":27},[],{"title":11,"searchDepth":12,"depth":12,"links":28},[],{},"Alexis Ablain","\u002Fauthors\u002Falexis-ablain",{"title":6,"description":11},"authors\u002Falexis-ablain","_SIAtB7f-39e5t3GiJof81NP47s6MGo2n4gaHkTy1uQ",{"id":36,"title":37,"body":38,"description":11,"extension":14,"meta":42,"name":43,"navigation":17,"path":44,"readingTime":19,"seo":45,"stem":46,"__hash__":47},"authors\u002Fauthors\u002Faxel-shaita.md","Engineering Manager",{"type":8,"value":39,"toc":40},[],{"title":11,"searchDepth":12,"depth":12,"links":41},[],{},"Axel Shaïta","\u002Fauthors\u002Faxel-shaita",{"title":37,"description":11},"authors\u002Faxel-shaita","fK0argUhsBkWLjpTAhY13oYLVzQthcEYkCEdtHWmIgE",{"id":49,"title":50,"body":51,"description":11,"extension":14,"meta":55,"name":56,"navigation":17,"path":57,"readingTime":19,"seo":58,"stem":59,"__hash__":60},"authors\u002Fauthors\u002Fbaptiste-faure.md","Head of Talent Acquisition",{"type":8,"value":52,"toc":53},[],{"title":11,"searchDepth":12,"depth":12,"links":54},[],{},"Baptiste Faure","\u002Fauthors\u002Fbaptiste-faure",{"title":50,"description":11},"authors\u002Fbaptiste-faure","ELisToYtcgHmgdVWZkCclTPV6exZtfyXqhpx1jjbJHs",{"id":62,"title":6,"body":63,"description":11,"extension":14,"meta":67,"name":68,"navigation":17,"path":69,"readingTime":19,"seo":70,"stem":71,"__hash__":72},"authors\u002Fauthors\u002Fbenjamin-bouillot.md",{"type":8,"value":64,"toc":65},[],{"title":11,"searchDepth":12,"depth":12,"links":66},[],{},"Benjamin Bouillot","\u002Fauthors\u002Fbenjamin-bouillot",{"title":6,"description":11},"authors\u002Fbenjamin-bouillot","tbhCFZyfTt7ZM5b5YgqQ2nhgnSTl8BweaQQryc87fHo",{"id":74,"title":37,"body":75,"description":11,"extension":14,"meta":79,"name":80,"navigation":17,"path":81,"readingTime":19,"seo":82,"stem":83,"__hash__":84},"authors\u002Fauthors\u002Fcedric-nicoloso.md",{"type":8,"value":76,"toc":77},[],{"title":11,"searchDepth":12,"depth":12,"links":78},[],{},"Cédric Nicoloso","\u002Fauthors\u002Fcedric-nicoloso",{"title":37,"description":11},"authors\u002Fcedric-nicoloso","ibSoh4VZYiWYTuLOnZTedaAfcnvet1Q9H7ogW0LgorY",{"id":86,"title":87,"body":88,"description":11,"extension":14,"meta":92,"name":93,"navigation":17,"path":94,"readingTime":19,"seo":95,"stem":96,"__hash__":97},"authors\u002Fauthors\u002Fdavid-touzet.md","Staff Engineer",{"type":8,"value":89,"toc":90},[],{"title":11,"searchDepth":12,"depth":12,"links":91},[],{},"David Touzet","\u002Fauthors\u002Fdavid-touzet",{"title":87,"description":11},"authors\u002Fdavid-touzet","dHWwnQxb1Ubt-WwXWEODGEo9AFoq1cJUhfg3kdnYSBM",{"id":99,"title":100,"body":101,"description":11,"extension":14,"meta":105,"name":106,"navigation":17,"path":107,"readingTime":19,"seo":108,"stem":109,"__hash__":110},"authors\u002Fauthors\u002Feloise-chizat.md","Data Engineer",{"type":8,"value":102,"toc":103},[],{"title":11,"searchDepth":12,"depth":12,"links":104},[],{},"Eloïse Chizat","\u002Fauthors\u002Feloise-chizat",{"title":100,"description":11},"authors\u002Feloise-chizat","Utd72Vm9qT4hh2ZbFi6a2_nXw5Wb494Ed_HL1ra5yw8",{"id":112,"title":113,"body":114,"description":11,"extension":14,"meta":118,"name":119,"navigation":17,"path":120,"readingTime":19,"seo":121,"stem":122,"__hash__":123},"authors\u002Fauthors\u002Femmanuel-auclair.md","Staff engineer",{"type":8,"value":115,"toc":116},[],{"title":11,"searchDepth":12,"depth":12,"links":117},[],{},"Emmanuel Auclair","\u002Fauthors\u002Femmanuel-auclair",{"title":113,"description":11},"authors\u002Femmanuel-auclair","MtsA8THNLEn0dTtYEIQaGwDuf7MjQL55IOeei5gugEg",{"id":125,"title":6,"body":126,"description":11,"extension":14,"meta":130,"name":131,"navigation":17,"path":132,"readingTime":19,"seo":133,"stem":134,"__hash__":135},"authors\u002Fauthors\u002Fhoreb-parraud.md",{"type":8,"value":127,"toc":128},[],{"title":11,"searchDepth":12,"depth":12,"links":129},[],{},"Horeb Parraud","\u002Fauthors\u002Fhoreb-parraud",{"title":6,"description":11},"authors\u002Fhoreb-parraud","ajjsnUX4ohZI-ghMdbb92q_taWDkKXVZSLZXoAeLQtg",{"id":137,"title":37,"body":138,"description":11,"extension":14,"meta":142,"name":143,"navigation":17,"path":144,"readingTime":19,"seo":145,"stem":146,"__hash__":147},"authors\u002Fauthors\u002Fhugo-contreras.md",{"type":8,"value":139,"toc":140},[],{"title":11,"searchDepth":12,"depth":12,"links":141},[],{},"Hugo Contreras","\u002Fauthors\u002Fhugo-contreras",{"title":37,"description":11},"authors\u002Fhugo-contreras","2nc3VMu9ASq9Z6Pwx2-7-Ye991Pww4p-UEDBQFfjF-Q",{"id":149,"title":150,"body":151,"description":11,"extension":14,"meta":155,"name":156,"navigation":17,"path":157,"readingTime":19,"seo":158,"stem":159,"__hash__":160},"authors\u002Fauthors\u002Fjulien-tassin.md","Head of Engineering",{"type":8,"value":152,"toc":153},[],{"title":11,"searchDepth":12,"depth":12,"links":154},[],{},"Julien Tassin","\u002Fauthors\u002Fjulien-tassin",{"title":150,"description":11},"authors\u002Fjulien-tassin","iUIHI7SITje38Jh9X9uvYs4-VsHx4eCdt6hAlyLFG_o",{"id":162,"title":6,"body":163,"description":11,"extension":14,"meta":167,"name":168,"navigation":17,"path":169,"readingTime":19,"seo":170,"stem":171,"__hash__":172},"authors\u002Fauthors\u002Flaurent-renard.md",{"type":8,"value":164,"toc":165},[],{"title":11,"searchDepth":12,"depth":12,"links":166},[],{},"Laurent Renard","\u002Fauthors\u002Flaurent-renard",{"title":6,"description":11},"authors\u002Flaurent-renard","5BP7Ed-pt1SQHjh0UJ1XUrlLTcdlFaDoKBCP4deHq8A",{"id":174,"title":6,"body":175,"description":11,"extension":14,"meta":179,"name":180,"navigation":17,"path":181,"readingTime":19,"seo":182,"stem":183,"__hash__":184},"authors\u002Fauthors\u002Fleo-martin.md",{"type":8,"value":176,"toc":177},[],{"title":11,"searchDepth":12,"depth":12,"links":178},[],{},"Léo Martin","\u002Fauthors\u002Fleo-martin",{"title":6,"description":11},"authors\u002Fleo-martin","eYxCHkRgbGDV7shKdTA9s7Tu0zGV4yDGFoKR5MHQntY",{"id":186,"title":6,"body":187,"description":11,"extension":14,"meta":191,"name":192,"navigation":17,"path":193,"readingTime":19,"seo":194,"stem":195,"__hash__":196},"authors\u002Fauthors\u002Floic-bousquet.md",{"type":8,"value":188,"toc":189},[],{"title":11,"searchDepth":12,"depth":12,"links":190},[],{},"Loïc Bousquet","\u002Fauthors\u002Floic-bousquet",{"title":6,"description":11},"authors\u002Floic-bousquet","ko12qZwiGL8XNjAoy9oWypPkIjr29Pbq7vhdtgldqeQ",{"id":198,"title":6,"body":199,"description":11,"extension":14,"meta":203,"name":204,"navigation":17,"path":205,"readingTime":19,"seo":206,"stem":207,"__hash__":208},"authors\u002Fauthors\u002Floic-poullain.md",{"type":8,"value":200,"toc":201},[],{"title":11,"searchDepth":12,"depth":12,"links":202},[],{},"Loïc Poullain","\u002Fauthors\u002Floic-poullain",{"title":6,"description":11},"authors\u002Floic-poullain","oRIyJhFRTqxy5dLCYQ2OnYZ1DB-gLDUM-85vTSYuTF0",{"id":210,"title":100,"body":211,"description":11,"extension":14,"meta":215,"name":216,"navigation":17,"path":217,"readingTime":19,"seo":218,"stem":219,"__hash__":220},"authors\u002Fauthors\u002Fmaud-lelu.md",{"type":8,"value":212,"toc":213},[],{"title":11,"searchDepth":12,"depth":12,"links":214},[],{},"Maud Lélu","\u002Fauthors\u002Fmaud-lelu",{"title":100,"description":11},"authors\u002Fmaud-lelu","MMbsCKuE41OMHusrl12FIEsI-Trx7l8Nn_ANhvj2_y4",{"id":222,"title":37,"body":223,"description":11,"extension":14,"meta":227,"name":228,"navigation":17,"path":229,"readingTime":19,"seo":230,"stem":231,"__hash__":232},"authors\u002Fauthors\u002Fnicolas-poirier.md",{"type":8,"value":224,"toc":225},[],{"title":11,"searchDepth":12,"depth":12,"links":226},[],{},"Nicolas Poirier","\u002Fauthors\u002Fnicolas-poirier",{"title":37,"description":11},"authors\u002Fnicolas-poirier","dXrJkYo8az4SN_D23aYc3fQ7z8s1dR2a0lt1ogjAjJs",{"id":234,"title":37,"body":235,"description":11,"extension":14,"meta":239,"name":240,"navigation":17,"path":241,"readingTime":19,"seo":242,"stem":243,"__hash__":244},"authors\u002Fauthors\u002Fraphael-sauget.md",{"type":8,"value":236,"toc":237},[],{"title":11,"searchDepth":12,"depth":12,"links":238},[],{},"Raphaël Sauget","\u002Fauthors\u002Fraphael-sauget",{"title":37,"description":11},"authors\u002Fraphael-sauget","Uri9bcq0QDuxRA0PbBoNtu7p_5L3dALu4kzcXVW0xyM",{"id":246,"title":247,"body":248,"description":11,"extension":14,"meta":252,"name":253,"navigation":17,"path":254,"readingTime":19,"seo":255,"stem":256,"__hash__":257},"authors\u002Fauthors\u002Fromain-koenig.md","Co-funder & Head of innovation",{"type":8,"value":249,"toc":250},[],{"title":11,"searchDepth":12,"depth":12,"links":251},[],{},"Romain Koenig","\u002Fauthors\u002Fromain-koenig",{"title":247,"description":11},"authors\u002Fromain-koenig","uyS8--eG2_ezyqRABcJnMJmQKKuSArhPWd14aUvFeEw",{"id":259,"title":37,"body":260,"description":11,"extension":14,"meta":264,"name":265,"navigation":17,"path":266,"readingTime":19,"seo":267,"stem":268,"__hash__":269},"authors\u002Fauthors\u002Fromaric-juniet.md",{"type":8,"value":261,"toc":262},[],{"title":11,"searchDepth":12,"depth":12,"links":263},[],{},"Romaric Juniet","\u002Fauthors\u002Fromaric-juniet",{"title":37,"description":11},"authors\u002Fromaric-juniet","4Zb2artgT-eo-PHLXi3xi4d5t7s6PfhUxeSfXIikSUY",{"id":271,"title":6,"body":272,"description":11,"extension":14,"meta":276,"name":277,"navigation":17,"path":278,"readingTime":19,"seo":279,"stem":280,"__hash__":281},"authors\u002Fauthors\u002Fstanyslas-bres.md",{"type":8,"value":273,"toc":274},[],{"title":11,"searchDepth":12,"depth":12,"links":275},[],{},"Stanyslas Bres","\u002Fauthors\u002Fstanyslas-bres",{"title":6,"description":11},"authors\u002Fstanyslas-bres","Xa0SahETuiN4q1jrmR2ych3moAqcZ2LbU7vSfEt2RuU",{"id":283,"title":284,"body":285,"description":11,"extension":14,"meta":289,"name":290,"navigation":17,"path":291,"readingTime":19,"seo":292,"stem":293,"__hash__":294},"authors\u002Fauthors\u002Ftalent-acquisition.md","Talent Acquisition",{"type":8,"value":286,"toc":287},[],{"title":11,"searchDepth":12,"depth":12,"links":288},[],{},"Équipe Talent Acquisition","\u002Fauthors\u002Ftalent-acquisition",{"description":11},"authors\u002Ftalent-acquisition","doDfE76txftQ4wIiKjJoDmSpyzSKk0tzlgVAp6-opAY",{"id":296,"title":6,"body":297,"description":11,"extension":14,"meta":301,"name":302,"navigation":17,"path":303,"readingTime":19,"seo":304,"stem":305,"__hash__":306},"authors\u002Fauthors\u002Fvictor-borg.md",{"type":8,"value":298,"toc":299},[],{"title":11,"searchDepth":12,"depth":12,"links":300},[],{},"Victor Borg","\u002Fauthors\u002Fvictor-borg",{"title":6,"description":11},"authors\u002Fvictor-borg","-Za-JweoiP6hyclue_WkxMXdRUDTczPGlJf6AZckjUc",{"id":308,"title":6,"body":309,"description":11,"extension":14,"meta":313,"name":314,"navigation":17,"path":315,"readingTime":19,"seo":316,"stem":317,"__hash__":318},"authors\u002Fauthors\u002Fvirgil-roger.md",{"type":8,"value":310,"toc":311},[],{"title":11,"searchDepth":12,"depth":12,"links":312},[],{},"Virgil Roger","\u002Fauthors\u002Fvirgil-roger",{"title":6,"description":11},"authors\u002Fvirgil-roger","DfVFe5j0bCgXeEr381ZYOM5DP4m-pWb93J9-m_muKJ0",{"id":320,"title":6,"body":321,"description":11,"extension":14,"meta":325,"name":326,"navigation":17,"path":327,"readingTime":19,"seo":328,"stem":329,"__hash__":330},"authors\u002Fauthors\u002Fyukan-zhao.md",{"type":8,"value":322,"toc":323},[],{"title":11,"searchDepth":12,"depth":12,"links":324},[],{},"Yukan Zhao","\u002Fauthors\u002Fyukan-zhao",{"title":6,"description":11},"authors\u002Fyukan-zhao","LRPHugtAJnWHsmHxy9_SR5Zas_C5p-GR_uHEs1Fhk_E",{"id":332,"title":333,"author":334,"body":335,"date":931,"description":932,"extension":14,"lang":933,"meta":934,"navigation":17,"path":935,"published":17,"readingTime":457,"seo":936,"stem":937,"tags":938,"__hash__":940},"articles\u002Farticles\u002F2022-11-17-nodejs-test-runner.md","NodeJS Test Runner","leo-martin",{"type":8,"value":336,"toc":927},[337,345,352,358,363,369,461,467,696,710,716,743,839,850,859,865,878,890,894,900,903,923],[338,339,340,341],"p",{},"Avec NodeJS v18, il est possible d’écrire ses tests sans librairie externe grâce au module\n",[342,343,344],"code",{},"node:test",[338,346,347,348,351],{},"Ce nouveau module permet de définir un jeu de test, que l’on pourra jouer via la commande\n",[342,349,350],{},"[node --test](https:\u002F\u002Fnodejs.org\u002Fapi\u002Ftest.html#running-tests-from-the-command-line)",".",[338,353,354,355,351],{},"Toujours dans l’idée d’utiliser le moins de dépendances externes, un bon module pour faire des\nassertions est ",[342,356,357],{},"[node:assert\u002Fstrict](https:\u002F\u002Fnodejs.org\u002Fapi\u002Fassert.html#strict-assertion-mode)",[359,360,362],"h2",{"id":361},"en-prenant-un-exemple","En prenant un exemple",[338,364,365,366],{},"Dans un fichier ",[342,367,368],{},"index.js",[370,371,375],"pre",{"className":372,"code":373,"language":374,"meta":11,"style":11},"language-ts shiki shiki-themes github-light github-dark","export function canRegister({ age, country, job }) {\n  return age >= 18 && country === \"US\" && job === \"engineer\";\n}\n","ts",[342,376,377,414,455],{"__ignoreMap":11},[378,379,381,385,388,392,396,400,403,406,408,411],"span",{"class":380,"line":19},"line",[378,382,384],{"class":383},"szBVR","export",[378,386,387],{"class":383}," function",[378,389,391],{"class":390},"sScJk"," canRegister",[378,393,395],{"class":394},"sVt8B","({ ",[378,397,399],{"class":398},"s4XuR","age",[378,401,402],{"class":394},", ",[378,404,405],{"class":398},"country",[378,407,402],{"class":394},[378,409,410],{"class":398},"job",[378,412,413],{"class":394}," }) {\n",[378,415,416,419,422,425,429,432,435,438,442,444,447,449,452],{"class":380,"line":12},[378,417,418],{"class":383},"  return",[378,420,421],{"class":394}," age ",[378,423,424],{"class":383},">=",[378,426,428],{"class":427},"sj4cs"," 18",[378,430,431],{"class":383}," &&",[378,433,434],{"class":394}," country ",[378,436,437],{"class":383},"===",[378,439,441],{"class":440},"sZZnC"," \"US\"",[378,443,431],{"class":383},[378,445,446],{"class":394}," job ",[378,448,437],{"class":383},[378,450,451],{"class":440}," \"engineer\"",[378,453,454],{"class":394},";\n",[378,456,458],{"class":380,"line":457},3,[378,459,460],{"class":394},"}\n",[338,462,463,464],{},"En utilisant le test runner de Node, on peut écrire le test suivant dans le fichier ",[342,465,466],{},"index.test.js",[370,468,470],{"className":372,"code":469,"language":374,"meta":11,"style":11},"import assert from \"node:assert\u002Fstrict\";\nimport { describe, it } from \"node:test\";\n\nimport { canRegister } from \".\u002Findex.js\";\n\ndescribe(\"canRegister\", () => {\n  it(\"returns true when age is 18, country is US, and job is engineer\", () => {\n    const result = canRegister({ age: 18, country: \"US\", job: \"engineer\" });\n    assert.strictEqual(result, true);\n  });\n\n  it(\"returns false when age is 17, country is US, and job is engineer\", () => {\n    const result = canRegister({ age: 17, country: \"US\", job: \"engineer\" });\n    assert.strictEqual(result, false);\n  });\n});\n",[342,471,472,488,502,507,522,527,548,565,600,618,624,629,645,671,685,690],{"__ignoreMap":11},[378,473,474,477,480,483,486],{"class":380,"line":19},[378,475,476],{"class":383},"import",[378,478,479],{"class":394}," assert ",[378,481,482],{"class":383},"from",[378,484,485],{"class":440}," \"node:assert\u002Fstrict\"",[378,487,454],{"class":394},[378,489,490,492,495,497,500],{"class":380,"line":12},[378,491,476],{"class":383},[378,493,494],{"class":394}," { describe, it } ",[378,496,482],{"class":383},[378,498,499],{"class":440}," \"node:test\"",[378,501,454],{"class":394},[378,503,504],{"class":380,"line":457},[378,505,506],{"emptyLinePlaceholder":17},"\n",[378,508,510,512,515,517,520],{"class":380,"line":509},4,[378,511,476],{"class":383},[378,513,514],{"class":394}," { canRegister } ",[378,516,482],{"class":383},[378,518,519],{"class":440}," \".\u002Findex.js\"",[378,521,454],{"class":394},[378,523,525],{"class":380,"line":524},5,[378,526,506],{"emptyLinePlaceholder":17},[378,528,530,533,536,539,542,545],{"class":380,"line":529},6,[378,531,532],{"class":390},"describe",[378,534,535],{"class":394},"(",[378,537,538],{"class":440},"\"canRegister\"",[378,540,541],{"class":394},", () ",[378,543,544],{"class":383},"=>",[378,546,547],{"class":394}," {\n",[378,549,551,554,556,559,561,563],{"class":380,"line":550},7,[378,552,553],{"class":390},"  it",[378,555,535],{"class":394},[378,557,558],{"class":440},"\"returns true when age is 18, country is US, and job is engineer\"",[378,560,541],{"class":394},[378,562,544],{"class":383},[378,564,547],{"class":394},[378,566,568,571,574,577,579,582,585,588,591,594,597],{"class":380,"line":567},8,[378,569,570],{"class":383},"    const",[378,572,573],{"class":427}," result",[378,575,576],{"class":383}," =",[378,578,391],{"class":390},[378,580,581],{"class":394},"({ age: ",[378,583,584],{"class":427},"18",[378,586,587],{"class":394},", country: ",[378,589,590],{"class":440},"\"US\"",[378,592,593],{"class":394},", job: ",[378,595,596],{"class":440},"\"engineer\"",[378,598,599],{"class":394}," });\n",[378,601,603,606,609,612,615],{"class":380,"line":602},9,[378,604,605],{"class":394},"    assert.",[378,607,608],{"class":390},"strictEqual",[378,610,611],{"class":394},"(result, ",[378,613,614],{"class":427},"true",[378,616,617],{"class":394},");\n",[378,619,621],{"class":380,"line":620},10,[378,622,623],{"class":394},"  });\n",[378,625,627],{"class":380,"line":626},11,[378,628,506],{"emptyLinePlaceholder":17},[378,630,632,634,636,639,641,643],{"class":380,"line":631},12,[378,633,553],{"class":390},[378,635,535],{"class":394},[378,637,638],{"class":440},"\"returns false when age is 17, country is US, and job is engineer\"",[378,640,541],{"class":394},[378,642,544],{"class":383},[378,644,547],{"class":394},[378,646,648,650,652,654,656,658,661,663,665,667,669],{"class":380,"line":647},13,[378,649,570],{"class":383},[378,651,573],{"class":427},[378,653,576],{"class":383},[378,655,391],{"class":390},[378,657,581],{"class":394},[378,659,660],{"class":427},"17",[378,662,587],{"class":394},[378,664,590],{"class":440},[378,666,593],{"class":394},[378,668,596],{"class":440},[378,670,599],{"class":394},[378,672,674,676,678,680,683],{"class":380,"line":673},14,[378,675,605],{"class":394},[378,677,608],{"class":390},[378,679,611],{"class":394},[378,681,682],{"class":427},"false",[378,684,617],{"class":394},[378,686,688],{"class":380,"line":687},15,[378,689,623],{"class":394},[378,691,693],{"class":380,"line":692},16,[378,694,695],{"class":394},"});\n",[697,698,699],"blockquote",{},[338,700,701,702,709],{},"À noter qu’il est possible de skip un test avec la syntaxe suivante\n",[703,704,708],"a",{"href":705,"rel":706},"https:\u002F\u002Fnodejs.org\u002Fapi\u002Ftest.html#testname-options-fn",[707],"nofollow","it([name], { skip: true }[, fn])"," ou en\najoutant it.skip",[338,711,712,713],{},"Et on exécute le test avec la commande ",[342,714,715],{},"node --test",[697,717,718],{},[338,719,720,722,723,726,727,730,731,734,735,740,741,351],{},[342,721,715],{}," va chercher récursivement les fichiers dont le nom est ",[342,724,725],{},"test.js"," ,\n",[342,728,729],{},"monfichier.test.js"," ou encore ",[342,732,733],{},"test-monfichier.js","\n(",[703,736,739],{"href":737,"rel":738},"https:\u002F\u002Fnodejs.org\u002Fapi\u002Ftest.html#test-runner-execution-model",[707],"plus de détail dans la doc","). Il\nest aussi possible de passer un fichier en argument à la commande ",[342,742,715],{},[370,744,748],{"className":745,"code":746,"language":747,"meta":11,"style":11},"language-sh shiki shiki-themes github-light github-dark","TAP version 13\n# Subtest: \u002Fnode-test-runner\u002Findex.test.js\nok 1 - \u002Fnode-test-runner\u002Findex.test.js\n  ---\n  duration_ms: 44.544125\n  ...\n1..1\n# tests 1\n# pass 1\n# fail 0\n# cancelled 0\n# skipped 0\n# todo 0\n# duration_ms 47.909458\n\n","sh",[342,749,750,761,767,781,786,794,799,804,809,814,819,824,829,834],{"__ignoreMap":11},[378,751,752,755,758],{"class":380,"line":19},[378,753,754],{"class":390},"TAP",[378,756,757],{"class":440}," version",[378,759,760],{"class":427}," 13\n",[378,762,763],{"class":380,"line":12},[378,764,766],{"class":765},"sJ8bj","# Subtest: \u002Fnode-test-runner\u002Findex.test.js\n",[378,768,769,772,775,778],{"class":380,"line":457},[378,770,771],{"class":390},"ok",[378,773,774],{"class":427}," 1",[378,776,777],{"class":440}," -",[378,779,780],{"class":440}," \u002Fnode-test-runner\u002Findex.test.js\n",[378,782,783],{"class":380,"line":509},[378,784,785],{"class":390},"  ---\n",[378,787,788,791],{"class":380,"line":524},[378,789,790],{"class":390},"  duration_ms:",[378,792,793],{"class":427}," 44.544125\n",[378,795,796],{"class":380,"line":529},[378,797,798],{"class":427},"  ...\n",[378,800,801],{"class":380,"line":550},[378,802,803],{"class":390},"1..1\n",[378,805,806],{"class":380,"line":567},[378,807,808],{"class":765},"# tests 1\n",[378,810,811],{"class":380,"line":602},[378,812,813],{"class":765},"# pass 1\n",[378,815,816],{"class":380,"line":620},[378,817,818],{"class":765},"# fail 0\n",[378,820,821],{"class":380,"line":626},[378,822,823],{"class":765},"# cancelled 0\n",[378,825,826],{"class":380,"line":631},[378,827,828],{"class":765},"# skipped 0\n",[378,830,831],{"class":380,"line":647},[378,832,833],{"class":765},"# todo 0\n",[378,835,836],{"class":380,"line":673},[378,837,838],{"class":765},"# duration_ms 47.909458\n",[338,840,841,842,846,849],{},"On obtient un retour au format TAP (Test Anything Protocol)\n",[703,843],{"href":844,"rel":845},"https:\u002F\u002Ftestanything.org\u002Ftap-specification.html",[707],[703,847,844],{"href":844,"rel":848},[707],"\nce qui nous permettra de pouvoir utiliser des reporters compatibles avec ce standard.",[338,851,852,853,858],{},"Par exemple, le module ",[703,854,857],{"href":855,"rel":856},"https:\u002F\u002Fgithub.com\u002Fscottcorgan\u002Ftap-spec",[707],"tap-spec"," permet d’obtenir le rendu\nsuivant :",[338,860,861],{},[862,863],"img",{"alt":11,"src":864},"\u002Fimages\u002FUntitled.png",[338,866,867,868,870,871,874,875],{},"Il suffit de piper le résultat de ",[342,869,715],{}," dans ",[342,872,873],{},"tape-spec"," : ",[342,876,877],{},"node --test | tap-spec",[697,879,880],{},[338,881,882,883,887],{},"Une liste de reporters est disponible ici\n",[703,884],{"href":885,"rel":886},"https:\u002F\u002Fgithub.com\u002Fljharb\u002Ftape#pretty-reporters",[707],[703,888,885],{"href":885,"rel":889},[707],[359,891,893],{"id":892},"spy-stub-et-mocks","Spy, stub et mocks",[338,895,896,897,899],{},"Contrairement à jest, ",[342,898,344],{}," ne permet pas de faire des spy ou mocks de modules.",[338,901,902],{},"Il est possible d’utiliser les librairies suivantes :",[904,905,906,915],"ul",{},[907,908,909,910],"li",{},"spying et stubbing avec ",[703,911,914],{"href":912,"rel":913},"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fsinon",[707],"sinon",[907,916,917,918],{},"snapshots avec ",[703,919,922],{"href":920,"rel":921},"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fsnapshot-assertion",[707],"snapshot-assertion",[924,925,926],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}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 .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":11,"searchDepth":12,"depth":12,"links":928},[929,930],{"id":361,"depth":12,"text":362},{"id":892,"depth":12,"text":893},"2022-11-17","Avec NodeJS v18, il est possible d’écrire ses tests sans librairie externe grâce au module node:test","fr",{},"\u002Farticles\u002F2022-11-17-nodejs-test-runner",{"title":333,"description":932},"articles\u002F2022-11-17-nodejs-test-runner",[939],"Tech","9CiEcnMi-bMA7h-X2bZN4le8Jlu8bCKzAkpBl3bzIos",1778159243192]