[{"data":1,"prerenderedAt":1450},["ShallowReactive",2],{"navigation":3,"\u002Frecipes\u002Ftesting":208,"\u002Frecipes\u002Ftesting-surround":1445},[4,98,175],{"title":5,"path":6,"stem":7,"children":8,"icon":97},"Guide","\u002Fguide","1.guide\u002F1.index",[9,12,17,22,46,61,79],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-house",{"title":13,"path":14,"stem":15,"icon":16},"Installation","\u002Fguide\u002Finstallation","1.guide\u002F2.installation","i-lucide-download",{"title":18,"path":19,"stem":20,"icon":21},"Quick start","\u002Fguide\u002Fquick-start","1.guide\u002F3.quick-start","i-lucide-rocket",{"title":23,"path":24,"stem":25,"children":26,"icon":45},"Server","\u002Fguide\u002Fserver","1.guide\u002F4.server\u002F1.index",[27,30,35,40],{"title":28,"path":24,"stem":25,"icon":29},"Usage","i-lucide-server",{"title":31,"path":32,"stem":33,"icon":34},"Config file","\u002Fguide\u002Fserver\u002Fconfig-file","1.guide\u002F4.server\u002F2.config-file","i-lucide-file-cog",{"title":36,"path":37,"stem":38,"icon":39},"Options","\u002Fguide\u002Fserver\u002Foptions","1.guide\u002F4.server\u002F3.options","i-lucide-settings",{"title":41,"path":42,"stem":43,"icon":44},"Advanced","\u002Fguide\u002Fserver\u002Fadvanced","1.guide\u002F4.server\u002F4.advanced","i-lucide-flask-conical",false,{"title":47,"path":48,"stem":49,"children":50,"icon":45},"Client","\u002Fguide\u002Fclient","1.guide\u002F5.client\u002F1.index",[51,53,58],{"title":28,"path":48,"stem":49,"icon":52},"i-lucide-monitor-smartphone",{"title":54,"path":55,"stem":56,"icon":57},"Live queries","\u002Fguide\u002Fclient\u002Flive-queries","1.guide\u002F5.client\u002F2.live-queries","i-lucide-radio",{"title":41,"path":59,"stem":60,"icon":44},"\u002Fguide\u002Fclient\u002Fadvanced","1.guide\u002F5.client\u002F3.advanced",{"title":62,"path":63,"stem":64,"children":65,"icon":45},"Development socket","\u002Fguide\u002Fsocket","1.guide\u002F6.socket\u002F1.index",[66,68,71,74],{"title":28,"path":63,"stem":64,"icon":67},"i-lucide-plug",{"title":36,"path":69,"stem":70,"icon":39},"\u002Fguide\u002Fsocket\u002Foptions","1.guide\u002F6.socket\u002F2.options",{"title":41,"path":72,"stem":73,"icon":44},"\u002Fguide\u002Fsocket\u002Fadvanced","1.guide\u002F6.socket\u002F3.advanced",{"title":75,"path":76,"stem":77,"icon":78},"PGlite in dev, Postgres in prod","\u002Fguide\u002Fsocket\u002Fdevelopment-only","1.guide\u002F6.socket\u002F4.development-only","i-lucide-cloud-upload",{"title":80,"path":81,"stem":82,"children":83,"icon":45},"DevTools & tooling","\u002Fguide\u002Fdevtools","1.guide\u002F7.devtools\u002F1.index",[84,87,92],{"title":85,"path":81,"stem":82,"icon":86},"DevTools tab","i-lucide-wrench",{"title":88,"path":89,"stem":90,"icon":91},"Actions","\u002Fguide\u002Fdevtools\u002Factions","1.guide\u002F7.devtools\u002F2.actions","i-lucide-zap",{"title":93,"path":94,"stem":95,"icon":96},"Terminal","\u002Fguide\u002Fdevtools\u002Fterminal","1.guide\u002F7.devtools\u002F3.terminal","i-lucide-square-terminal","i-lucide-book-open",{"title":99,"icon":100,"path":101,"stem":102,"children":103,"page":45},"Recipes","i-lucide-chef-hat","\u002Frecipes","2.recipes",[104,116,138,159,171],{"title":105,"path":106,"stem":107,"children":108,"icon":45},"Migrations","\u002Frecipes\u002Fmigrations","2.recipes\u002F1.migrations\u002F1.index",[109,111],{"title":28,"path":106,"stem":107,"icon":110},"i-lucide-database-backup",{"title":112,"path":113,"stem":114,"icon":115},"Edited migrations","\u002Frecipes\u002Fmigrations\u002Fedited-migrations","2.recipes\u002F1.migrations\u002F2.edited-migrations","i-lucide-file-diff",{"title":117,"path":118,"stem":119,"children":120,"icon":45},"Testing","\u002Frecipes\u002Ftesting","2.recipes\u002F2.testing\u002F1.index",[121,123,128,133],{"title":28,"path":118,"stem":119,"icon":122},"i-lucide-test-tube",{"title":124,"path":125,"stem":126,"icon":127},"Isolation","\u002Frecipes\u002Ftesting\u002Fisolation","2.recipes\u002F2.testing\u002F2.isolation","i-lucide-git-fork",{"title":129,"path":130,"stem":131,"icon":132},"vitest","\u002Frecipes\u002Ftesting\u002Fvitest","2.recipes\u002F2.testing\u002F3.vitest","i-simple-icons-vitest",{"title":134,"path":135,"stem":136,"icon":137},"@nuxt\u002Ftest-utils","\u002Frecipes\u002Ftesting\u002Fnuxt-test-utils","2.recipes\u002F2.testing\u002F4.nuxt-test-utils","i-simple-icons-nuxt",{"title":139,"path":140,"stem":141,"children":142,"icon":45},"Deploy","\u002Frecipes\u002Fdeploy","2.recipes\u002F3.deploy\u002F1.index",[143,144,149,154],{"title":139,"path":140,"stem":141},{"title":145,"path":146,"stem":147,"icon":148},"Any Postgres","\u002Frecipes\u002Fdeploy\u002Fpostgres","2.recipes\u002F3.deploy\u002F2.postgres","i-lucide-database",{"title":150,"path":151,"stem":152,"icon":153},"Netlify","\u002Frecipes\u002Fdeploy\u002Fnetlify","2.recipes\u002F3.deploy\u002F3.netlify","i-simple-icons-netlify",{"title":155,"path":156,"stem":157,"icon":158},"Neon","\u002Frecipes\u002Fdeploy\u002Fneon","2.recipes\u002F3.deploy\u002F4.neon","i-simple-icons-neon",{"title":160,"path":161,"stem":162,"children":163,"icon":45},"Outside Nuxt","\u002Frecipes\u002Foutside-nuxt","2.recipes\u002F4.outside-nuxt\u002F1.index",[164,167],{"title":165,"path":161,"stem":162,"icon":166},"Config and provider","i-lucide-package",{"title":168,"path":169,"stem":170,"icon":67},"Socket server","\u002Frecipes\u002Foutside-nuxt\u002Fsocket","2.recipes\u002F4.outside-nuxt\u002F2.socket",{"title":172,"path":173,"stem":174,"icon":67},"Nitro's useDatabase","\u002Frecipes\u002Fnitro-database","2.recipes\u002F5.nitro-database",{"title":176,"icon":177,"path":178,"stem":179,"children":180,"page":45},"Reference","i-lucide-code-xml","\u002Freference","3.reference",[181,185,189,193,198,203],{"title":182,"path":183,"stem":184,"icon":34},"Config files","\u002Freference\u002Fconfig-files","3.reference\u002F1.config-files",{"title":186,"path":187,"stem":188,"icon":39},"Module options","\u002Freference\u002Fmodule-options","3.reference\u002F2.module-options",{"title":190,"path":191,"stem":192,"icon":67},"Socket options","\u002Freference\u002Fsocket-options","3.reference\u002F3.socket-options",{"title":194,"path":195,"stem":196,"icon":197},"Exports","\u002Freference\u002Fexports","3.reference\u002F4.exports","i-lucide-boxes",{"title":199,"path":200,"stem":201,"icon":202},"Hooks","\u002Freference\u002Fhooks","3.reference\u002F5.hooks","i-lucide-anchor",{"title":204,"path":205,"stem":206,"icon":207},"Environment","\u002Freference\u002Fenvironment","3.reference\u002F6.environment","i-lucide-variable",{"id":209,"title":117,"body":210,"description":1438,"extension":1439,"links":1440,"meta":1441,"navigation":1442,"path":118,"seo":1443,"stem":119,"__hash__":1444},"docs\u002F2.recipes\u002F2.testing\u002F1.index.md",{"type":211,"value":212,"toc":1433},"minimark",[213,245,624,645,654,658,771,926,935,938,948,990,1096,1113,1231,1242,1245,1284,1357,1394,1406,1429],[214,215,216,217,221,222,226,227,230,231,233,234,239,240,244],"p",{},"A test suite needs a database that matches the app's: the same extensions, the same schema, the same seed. ",[218,219,220],"code",{},"nuxt-pglite\u002Ftesting"," builds one from your ",[223,224,225],"a",{"href":32},"server config",", ",[218,228,229],{},"init"," included, so migrations applied from ",[218,232,229],{}," with ",[223,235,236],{"href":106},[218,237,238],{},"applyMigrations"," are applied here too. It lives in memory, so nothing of the app's data directory is touched, and it works with vitest, ",[223,241,242],{"href":135},[218,243,134],{}," or any other runner.",[246,247,253],"pre",{"className":248,"code":249,"filename":250,"language":251,"meta":252,"style":252},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { afterAll, beforeAll, expect, it } from 'vitest'\nimport { createTestDatabase } from 'nuxt-pglite\u002Ftesting'\nimport type { TestDatabase } from 'nuxt-pglite\u002Ftesting'\n\nlet db: TestDatabase\n\nbeforeAll(async () => {\n  db = await createTestDatabase({ config: 'server\u002Fpglite.config' })\n})\nafterAll(() => db.close())\n\nit('stores a todo', async () => {\n  await db.pg.query('INSERT INTO todos (title) VALUES ($1)', ['first'])\n  const { rows } = await db.pg.query('SELECT title FROM todos')\n  expect(rows).toEqual([{ title: 'first' }])\n})\n","test\u002Ftodos.test.ts","ts","",[218,254,255,303,323,346,353,370,375,397,435,443,467,472,498,540,578,617],{"__ignoreMap":252},[256,257,260,264,268,272,275,278,280,283,285,288,291,294,297,300],"span",{"class":258,"line":259},"line",1,[256,261,263],{"class":262},"s7zQu","import",[256,265,267],{"class":266},"sMK4o"," {",[256,269,271],{"class":270},"sTEyZ"," afterAll",[256,273,274],{"class":266},",",[256,276,277],{"class":270}," beforeAll",[256,279,274],{"class":266},[256,281,282],{"class":270}," expect",[256,284,274],{"class":266},[256,286,287],{"class":270}," it",[256,289,290],{"class":266}," }",[256,292,293],{"class":262}," from",[256,295,296],{"class":266}," '",[256,298,129],{"class":299},"sfazB",[256,301,302],{"class":266},"'\n",[256,304,306,308,310,313,315,317,319,321],{"class":258,"line":305},2,[256,307,263],{"class":262},[256,309,267],{"class":266},[256,311,312],{"class":270}," createTestDatabase",[256,314,290],{"class":266},[256,316,293],{"class":262},[256,318,296],{"class":266},[256,320,220],{"class":299},[256,322,302],{"class":266},[256,324,326,328,331,333,336,338,340,342,344],{"class":258,"line":325},3,[256,327,263],{"class":262},[256,329,330],{"class":262}," type",[256,332,267],{"class":266},[256,334,335],{"class":270}," TestDatabase",[256,337,290],{"class":266},[256,339,293],{"class":262},[256,341,296],{"class":266},[256,343,220],{"class":299},[256,345,302],{"class":266},[256,347,349],{"class":258,"line":348},4,[256,350,352],{"emptyLinePlaceholder":351},true,"\n",[256,354,356,360,363,366],{"class":258,"line":355},5,[256,357,359],{"class":358},"spNyl","let",[256,361,362],{"class":270}," db",[256,364,365],{"class":266},":",[256,367,369],{"class":368},"sBMFI"," TestDatabase\n",[256,371,373],{"class":258,"line":372},6,[256,374,352],{"emptyLinePlaceholder":351},[256,376,378,382,385,388,391,394],{"class":258,"line":377},7,[256,379,381],{"class":380},"s2Zo4","beforeAll",[256,383,384],{"class":270},"(",[256,386,387],{"class":358},"async",[256,389,390],{"class":266}," ()",[256,392,393],{"class":358}," =>",[256,395,396],{"class":266}," {\n",[256,398,400,403,406,409,411,414,417,420,422,424,427,430,432],{"class":258,"line":399},8,[256,401,402],{"class":270},"  db",[256,404,405],{"class":266}," =",[256,407,408],{"class":262}," await",[256,410,312],{"class":380},[256,412,384],{"class":413},"swJcz",[256,415,416],{"class":266},"{",[256,418,419],{"class":413}," config",[256,421,365],{"class":266},[256,423,296],{"class":266},[256,425,426],{"class":299},"server\u002Fpglite.config",[256,428,429],{"class":266},"'",[256,431,290],{"class":266},[256,433,434],{"class":413},")\n",[256,436,438,441],{"class":258,"line":437},9,[256,439,440],{"class":266},"}",[256,442,434],{"class":270},[256,444,446,449,451,454,456,458,461,464],{"class":258,"line":445},10,[256,447,448],{"class":380},"afterAll",[256,450,384],{"class":270},[256,452,453],{"class":266},"()",[256,455,393],{"class":358},[256,457,362],{"class":270},[256,459,460],{"class":266},".",[256,462,463],{"class":380},"close",[256,465,466],{"class":270},"())\n",[256,468,470],{"class":258,"line":469},11,[256,471,352],{"emptyLinePlaceholder":351},[256,473,475,478,480,482,485,487,489,492,494,496],{"class":258,"line":474},12,[256,476,477],{"class":380},"it",[256,479,384],{"class":270},[256,481,429],{"class":266},[256,483,484],{"class":299},"stores a todo",[256,486,429],{"class":266},[256,488,274],{"class":266},[256,490,491],{"class":358}," async",[256,493,390],{"class":266},[256,495,393],{"class":358},[256,497,396],{"class":266},[256,499,501,504,506,508,511,513,516,518,520,523,525,527,530,532,535,537],{"class":258,"line":500},13,[256,502,503],{"class":262},"  await",[256,505,362],{"class":270},[256,507,460],{"class":266},[256,509,510],{"class":270},"pg",[256,512,460],{"class":266},[256,514,515],{"class":380},"query",[256,517,384],{"class":413},[256,519,429],{"class":266},[256,521,522],{"class":299},"INSERT INTO todos (title) VALUES ($1)",[256,524,429],{"class":266},[256,526,274],{"class":266},[256,528,529],{"class":413}," [",[256,531,429],{"class":266},[256,533,534],{"class":299},"first",[256,536,429],{"class":266},[256,538,539],{"class":413},"])\n",[256,541,543,546,548,551,553,555,557,559,561,563,565,567,569,571,574,576],{"class":258,"line":542},14,[256,544,545],{"class":358},"  const",[256,547,267],{"class":266},[256,549,550],{"class":270}," rows",[256,552,290],{"class":266},[256,554,405],{"class":266},[256,556,408],{"class":262},[256,558,362],{"class":270},[256,560,460],{"class":266},[256,562,510],{"class":270},[256,564,460],{"class":266},[256,566,515],{"class":380},[256,568,384],{"class":413},[256,570,429],{"class":266},[256,572,573],{"class":299},"SELECT title FROM todos",[256,575,429],{"class":266},[256,577,434],{"class":413},[256,579,581,584,586,589,592,594,597,600,602,605,607,609,611,613,615],{"class":258,"line":580},15,[256,582,583],{"class":380},"  expect",[256,585,384],{"class":413},[256,587,588],{"class":270},"rows",[256,590,591],{"class":413},")",[256,593,460],{"class":266},[256,595,596],{"class":380},"toEqual",[256,598,599],{"class":413},"([",[256,601,416],{"class":266},[256,603,604],{"class":413}," title",[256,606,365],{"class":266},[256,608,296],{"class":266},[256,610,534],{"class":299},[256,612,429],{"class":266},[256,614,290],{"class":266},[256,616,539],{"class":413},[256,618,620,622],{"class":258,"line":619},16,[256,621,440],{"class":266},[256,623,434],{"class":270},[214,625,626,629,630,632,633,636,637,640,641,644],{},[218,627,628],{},"db.pg"," is the PGlite instance, after ",[218,631,229],{}," has run. ",[218,634,635],{},"close()"," runs the config's ",[218,638,639],{},"dispose",", then closes everything the database opened: its ",[223,642,643],{"href":125},"forks",", its socket and the instance.",[214,646,647,648,651,652,460],{},"One database can serve a whole suite, or be ",[223,649,650],{"href":125},"forked per test"," so that each test starts from the same data. For a whole vitest run behind one URL, see ",[223,653,129],{"href":130},[655,656,36],"h2",{"id":657},"options",[246,659,661],{"className":248,"code":660,"language":251,"meta":252,"style":252},"const db = await createTestDatabase({\n  config: 'server\u002Fpglite.config', \u002F\u002F or the config object itself\n  alias: {}, \u002F\u002F import aliases the config file uses, see below\n  dataDir: 'memory:\u002F\u002F', \u002F\u002F whatever the config says\n  socket: false, \u002F\u002F `true`, or the socket's options, to serve it over a URL\n  exportEnv: true, \u002F\u002F when `socket` is on: set its variables on `process.env`\n})\n",[218,662,663,683,702,715,734,750,765],{"__ignoreMap":252},[256,664,665,668,671,674,676,678,680],{"class":258,"line":259},[256,666,667],{"class":358},"const",[256,669,670],{"class":270}," db ",[256,672,673],{"class":266},"=",[256,675,408],{"class":262},[256,677,312],{"class":380},[256,679,384],{"class":270},[256,681,682],{"class":266},"{\n",[256,684,685,688,690,692,694,696,698],{"class":258,"line":305},[256,686,687],{"class":413},"  config",[256,689,365],{"class":266},[256,691,296],{"class":266},[256,693,426],{"class":299},[256,695,429],{"class":266},[256,697,274],{"class":266},[256,699,701],{"class":700},"sHwdD"," \u002F\u002F or the config object itself\n",[256,703,704,707,709,712],{"class":258,"line":325},[256,705,706],{"class":413},"  alias",[256,708,365],{"class":266},[256,710,711],{"class":266}," {},",[256,713,714],{"class":700}," \u002F\u002F import aliases the config file uses, see below\n",[256,716,717,720,722,724,727,729,731],{"class":258,"line":348},[256,718,719],{"class":413},"  dataDir",[256,721,365],{"class":266},[256,723,296],{"class":266},[256,725,726],{"class":299},"memory:\u002F\u002F",[256,728,429],{"class":266},[256,730,274],{"class":266},[256,732,733],{"class":700}," \u002F\u002F whatever the config says\n",[256,735,736,739,741,745,747],{"class":258,"line":355},[256,737,738],{"class":413},"  socket",[256,740,365],{"class":266},[256,742,744],{"class":743},"sfNiH"," false",[256,746,274],{"class":266},[256,748,749],{"class":700}," \u002F\u002F `true`, or the socket's options, to serve it over a URL\n",[256,751,752,755,757,760,762],{"class":258,"line":372},[256,753,754],{"class":413},"  exportEnv",[256,756,365],{"class":266},[256,758,759],{"class":743}," true",[256,761,274],{"class":266},[256,763,764],{"class":700}," \u002F\u002F when `socket` is on: set its variables on `process.env`\n",[256,766,767,769],{"class":258,"line":377},[256,768,440],{"class":266},[256,770,434],{"class":270},[772,773,774,792],"table",{},[775,776,777],"thead",{},[778,779,780,784,787,790],"tr",{},[781,782,783],"th",{},"Option",[781,785,786],{},"Type",[781,788,789],{},"Default",[781,791],{},[793,794,795,820,844,871,899],"tbody",{},[778,796,797,803,808,813],{},[798,799,800],"td",{},[218,801,802],{},"config",[798,804,805],{},[218,806,807],{},"PGliteConfig | string",[798,809,810],{},[218,811,812],{},"{}",[798,814,815,816,819],{},"The app's server config, or the path of its file. ",[218,817,818],{},"$test"," overrides apply.",[778,821,822,827,832,834],{},[798,823,824],{},[218,825,826],{},"alias",[798,828,829],{},[218,830,831],{},"Record\u003Cstring, string>",[798,833],{},[798,835,836,837,840,841,460],{},"Import aliases a config path may use, name to absolute path, as ",[218,838,839],{},"nuxt.options.alias"," holds them. See ",[223,842,182],{"href":843},"#config-files",[778,845,846,851,856,861],{},[798,847,848],{},[218,849,850],{},"dataDir",[798,852,853],{},[218,854,855],{},"string",[798,857,858],{},[218,859,860],{},"'memory:\u002F\u002F'",[798,862,863,864,866,867,870],{},"Replaces the config's ",[218,865,850],{},". The config's ",[218,868,869],{},"fs"," is dropped too, since it would hold the app's own data directory.",[778,872,873,878,883,888],{},[798,874,875],{},[218,876,877],{},"socket",[798,879,880],{},[218,881,882],{},"boolean | TestSocketOptions",[798,884,885],{},[218,886,887],{},"false",[798,889,890,891,894,895,460],{},"Serves the database over the Postgres wire protocol: ",[218,892,893],{},"true"," for a free loopback port. See ",[223,896,898],{"href":897},"#through-the-socket","Through the socket",[778,900,901,906,911,919],{},[798,902,903],{},[218,904,905],{},"exportEnv",[798,907,908],{},[218,909,910],{},"boolean",[798,912,913,915,916,918],{},[218,914,893],{}," when ",[218,917,877],{}," is on",[798,920,921,922,925],{},"Sets the socket's variables on ",[218,923,924],{},"process.env"," while the database is open, those still unset only.",[214,927,928,929,931,932,934],{},"Passed as an object, ",[218,930,802],{}," types ",[218,933,628],{}," with its extensions; loaded from a path, it cannot.",[655,936,182],{"id":937},"config-files",[214,939,940,941,943,944,947],{},"A ",[218,942,802],{}," path is loaded with ",[218,945,946],{},"loadPGliteConfig(path, { alias })",", also exported, the way the module loads it:",[949,950,951,959,969,976],"ul",{},[952,953,954,955,958],"li",{},"relative to ",[218,956,957],{},"process.cwd()",", extension optional;",[952,960,961,962,968],{},"imported through ",[223,963,967],{"href":964,"rel":965},"https:\u002F\u002Fgithub.com\u002Funjs\u002Fjiti",[966],"nofollow","jiti",", so TypeScript works on any runtime, and fresh on every call;",[952,970,971,972,975],{},"with ",[218,973,974],{},"definePGliteServerConfig"," provided as a global while the file is imported, so a file written for the auto-import works unchanged;",[952,977,978,979,981,982,985,986,989],{},"with the ",[218,980,818],{}," overrides applied, and ",[218,983,984],{},"$development"," \u002F ",[218,987,988],{},"$production"," ignored.",[246,991,994],{"className":248,"code":992,"filename":993,"language":251,"meta":252,"style":252},"export default definePGliteServerConfig({\n  init: async (pg) => {\n    await pg.exec('CREATE TABLE IF NOT EXISTS todos (id serial PRIMARY KEY, title text NOT NULL)')\n  },\n  $test: {\n    debug: 1, \u002F\u002F a shallow override, applied in tests only\n  },\n})\n","server\u002Fpglite.config.ts",[218,995,996,1011,1032,1056,1061,1070,1086,1090],{"__ignoreMap":252},[256,997,998,1001,1004,1007,1009],{"class":258,"line":259},[256,999,1000],{"class":262},"export",[256,1002,1003],{"class":262}," default",[256,1005,1006],{"class":380}," definePGliteServerConfig",[256,1008,384],{"class":270},[256,1010,682],{"class":266},[256,1012,1013,1016,1018,1020,1023,1026,1028,1030],{"class":258,"line":305},[256,1014,1015],{"class":380},"  init",[256,1017,365],{"class":266},[256,1019,491],{"class":358},[256,1021,1022],{"class":266}," (",[256,1024,510],{"class":1025},"sHdIc",[256,1027,591],{"class":266},[256,1029,393],{"class":358},[256,1031,396],{"class":266},[256,1033,1034,1037,1040,1042,1045,1047,1049,1052,1054],{"class":258,"line":325},[256,1035,1036],{"class":262},"    await",[256,1038,1039],{"class":270}," pg",[256,1041,460],{"class":266},[256,1043,1044],{"class":380},"exec",[256,1046,384],{"class":413},[256,1048,429],{"class":266},[256,1050,1051],{"class":299},"CREATE TABLE IF NOT EXISTS todos (id serial PRIMARY KEY, title text NOT NULL)",[256,1053,429],{"class":266},[256,1055,434],{"class":413},[256,1057,1058],{"class":258,"line":348},[256,1059,1060],{"class":266},"  },\n",[256,1062,1063,1066,1068],{"class":258,"line":355},[256,1064,1065],{"class":413},"  $test",[256,1067,365],{"class":266},[256,1069,396],{"class":266},[256,1071,1072,1075,1077,1081,1083],{"class":258,"line":372},[256,1073,1074],{"class":413},"    debug",[256,1076,365],{"class":266},[256,1078,1080],{"class":1079},"sbssI"," 1",[256,1082,274],{"class":266},[256,1084,1085],{"class":700}," \u002F\u002F a shallow override, applied in tests only\n",[256,1087,1088],{"class":258,"line":377},[256,1089,1060],{"class":266},[256,1091,1092,1094],{"class":258,"line":399},[256,1093,440],{"class":266},[256,1095,434],{"class":270},[214,1097,1098,1099,226,1102,1105,1106,1109,1110,1112],{},"Outside Nuxt the app's aliases (",[218,1100,1101],{},"~~",[218,1103,1104],{},"#pglite\u002Fmigrations",", …) are not defined, so a file importing through one fails to load. Either import from ",[218,1107,1108],{},"nuxt-pglite\u002Fmigrations"," in the file, which resolves anywhere, or pass the aliases as ",[218,1111,826],{},", name to absolute path:",[246,1114,1116],{"className":248,"code":1115,"language":251,"meta":252,"style":252},"import { fileURLToPath } from 'node:url'\n\nconst db = await createTestDatabase({\n  config: 'server\u002Fpglite.config',\n  alias: {\n    '#pglite\u002Fmigrations': fileURLToPath(import.meta.resolve('nuxt-pglite\u002Fmigrations')),\n  },\n})\n",[218,1117,1118,1138,1142,1158,1173,1181,1221,1225],{"__ignoreMap":252},[256,1119,1120,1122,1124,1127,1129,1131,1133,1136],{"class":258,"line":259},[256,1121,263],{"class":262},[256,1123,267],{"class":266},[256,1125,1126],{"class":270}," fileURLToPath",[256,1128,290],{"class":266},[256,1130,293],{"class":262},[256,1132,296],{"class":266},[256,1134,1135],{"class":299},"node:url",[256,1137,302],{"class":266},[256,1139,1140],{"class":258,"line":305},[256,1141,352],{"emptyLinePlaceholder":351},[256,1143,1144,1146,1148,1150,1152,1154,1156],{"class":258,"line":325},[256,1145,667],{"class":358},[256,1147,670],{"class":270},[256,1149,673],{"class":266},[256,1151,408],{"class":262},[256,1153,312],{"class":380},[256,1155,384],{"class":270},[256,1157,682],{"class":266},[256,1159,1160,1162,1164,1166,1168,1170],{"class":258,"line":348},[256,1161,687],{"class":413},[256,1163,365],{"class":266},[256,1165,296],{"class":266},[256,1167,426],{"class":299},[256,1169,429],{"class":266},[256,1171,1172],{"class":266},",\n",[256,1174,1175,1177,1179],{"class":258,"line":355},[256,1176,706],{"class":413},[256,1178,365],{"class":266},[256,1180,396],{"class":266},[256,1182,1183,1186,1188,1190,1192,1194,1196,1198,1200,1203,1205,1208,1210,1212,1214,1216,1219],{"class":258,"line":372},[256,1184,1185],{"class":266},"    '",[256,1187,1104],{"class":413},[256,1189,429],{"class":266},[256,1191,365],{"class":266},[256,1193,1126],{"class":380},[256,1195,384],{"class":270},[256,1197,263],{"class":262},[256,1199,460],{"class":266},[256,1201,1202],{"class":270},"meta",[256,1204,460],{"class":266},[256,1206,1207],{"class":380},"resolve",[256,1209,384],{"class":270},[256,1211,429],{"class":266},[256,1213,1108],{"class":299},[256,1215,429],{"class":266},[256,1217,1218],{"class":270},"))",[256,1220,1172],{"class":266},[256,1222,1223],{"class":258,"line":377},[256,1224,1060],{"class":266},[256,1226,1227,1229],{"class":258,"line":399},[256,1228,440],{"class":266},[256,1230,434],{"class":270},[214,1232,1233,1234,1237,1238,1241],{},"The ",[218,1235,1236],{},"paths"," of ",[218,1239,1240],{},".nuxt\u002Ftsconfig.json"," list the others.",[655,1243,898],{"id":1244},"through-the-socket",[214,1246,1247,1248,1250,1251,1253,1254,1256,1257,1260,1261,1022,1264,226,1267,226,1270,1273,1274,226,1277,1280,1281,460],{},"Code that connects through a URL, rather than receiving ",[218,1249,510],{},", reaches the database over the Postgres wire protocol with ",[218,1252,877],{},": ",[218,1255,893],{}," for a free loopback port, or the module's ",[223,1258,1259],{"href":69},"socket options"," but ",[218,1262,1263],{},"devtoolsActions",[218,1265,1266],{},"port",[218,1268,1269],{},"env",[218,1271,1272],{},"provider",", …), plus the server's own ",[218,1275,1276],{},"user",[218,1278,1279],{},"database"," and ",[218,1282,1283],{},"logger",[246,1285,1287],{"className":248,"code":1286,"language":251,"meta":252,"style":252},"const db = await createTestDatabase({ config: 'server\u002Fpglite.config', socket: true })\n\ndb.url \u002F\u002F postgres:\u002F\u002Fpostgres@127.0.0.1:\u003Cport>\u002Fpostgres\ndb.env \u002F\u002F { DATABASE_URL: db.url }\n",[218,1288,1289,1328,1332,1345],{"__ignoreMap":252},[256,1290,1291,1293,1295,1297,1299,1301,1303,1305,1307,1309,1311,1313,1315,1317,1320,1322,1324,1326],{"class":258,"line":259},[256,1292,667],{"class":358},[256,1294,670],{"class":270},[256,1296,673],{"class":266},[256,1298,408],{"class":262},[256,1300,312],{"class":380},[256,1302,384],{"class":270},[256,1304,416],{"class":266},[256,1306,419],{"class":413},[256,1308,365],{"class":266},[256,1310,296],{"class":266},[256,1312,426],{"class":299},[256,1314,429],{"class":266},[256,1316,274],{"class":266},[256,1318,1319],{"class":413}," socket",[256,1321,365],{"class":266},[256,1323,759],{"class":743},[256,1325,290],{"class":266},[256,1327,434],{"class":270},[256,1329,1330],{"class":258,"line":305},[256,1331,352],{"emptyLinePlaceholder":351},[256,1333,1334,1337,1339,1342],{"class":258,"line":325},[256,1335,1336],{"class":270},"db",[256,1338,460],{"class":266},[256,1340,1341],{"class":270},"url ",[256,1343,1344],{"class":700},"\u002F\u002F postgres:\u002F\u002Fpostgres@127.0.0.1:\u003Cport>\u002Fpostgres\n",[256,1346,1347,1349,1351,1354],{"class":258,"line":348},[256,1348,1336],{"class":270},[256,1350,460],{"class":266},[256,1352,1353],{"class":270},"env ",[256,1355,1356],{"class":700},"\u002F\u002F { DATABASE_URL: db.url }\n",[214,1358,1359,1362,1363,1253,1366,1369,1370,1280,1373,233,1376,226,1382,1384,1385,1387,1388,1391,1392,460],{},[218,1360,1361],{},"db.env"," holds the variables the socket resolves, as in ",[218,1364,1365],{},"nuxt dev",[218,1367,1368],{},"DATABASE_URL"," by default, ",[218,1371,1372],{},"NETLIFY_DB_URL",[218,1374,1375],{},"NETLIFY_DB_DRIVER",[223,1377,1379],{"href":1378},"\u002Fguide\u002Fsocket#provider-presets",[218,1380,1381],{},"provider: 'netlify'",[218,1383,1269],{}," merged over them. They are set on ",[218,1386,924],{}," while the database is open, unless ",[218,1389,1390],{},"exportEnv: false",", and unset on ",[218,1393,635],{},[1395,1396,1397],"warning",{},[214,1398,1399,1400,1402,1403,1405],{},"As with the development socket, each variable is set only while still unset. With a ",[218,1401,1368],{}," already in the environment, from your shell or a CI job, code reading it reaches that database rather than the test one. ",[218,1404,1361],{}," always holds the test database's values, exported or not: pass it on explicitly when that matters.",[1407,1408,1409,1415,1424],"card-group",{},[1410,1411,1412],"card",{"icon":127,"title":124,"to":125},[214,1413,1414],{},"Fork a seeded database per test.",[1410,1416,1417],{"icon":132,"title":129,"to":130},[214,1418,1419,1420,1423],{},"One database for the whole run, from a ",[218,1421,1422],{},"globalSetup"," file.",[1410,1425,1426],{"icon":137,"title":134,"to":135},[214,1427,1428],{},"Boot the built app against a test database.",[1430,1431,1432],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}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 .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}",{"title":252,"searchDepth":259,"depth":305,"links":1434},[1435,1436,1437],{"id":657,"depth":305,"text":36},{"id":937,"depth":305,"text":182},{"id":1244,"depth":305,"text":898},"A database built from your app's own config for the test suite, shared by the run or isolated per test, without touching the app's data.","md",null,{},{"title":28,"icon":122},{"title":117,"description":1438},"tvtjpmZT2Quo94d0oRK0RpNqJD7K5U68TKVdXQJKK_E",[1446,1448],{"title":112,"path":113,"stem":114,"description":1447,"icon":115,"children":-1},"Why an applied migration never runs again, how applyMigrations notices an edited file, and the way out.",{"title":124,"path":125,"stem":126,"description":1449,"icon":127,"children":-1},"Seed once, then fork the database per test, so each starts from the same data and none sees another's writes.",1791474259253]