diff --git a/packages/nitro/src/rollup/plugins/middleware.ts b/packages/nitro/src/rollup/plugins/middleware.ts index 671a9c4221..247159bfd0 100644 --- a/packages/nitro/src/rollup/plugins/middleware.ts +++ b/packages/nitro/src/rollup/plugins/middleware.ts @@ -2,6 +2,7 @@ import hasha from 'hasha' import { relative } from 'upath' import { table, getBorderCharacters } from 'table' import isPrimitive from 'is-primitive' +import stdenv from 'std-env' import type { ServerMiddleware } from '../../server/middleware' import virtual from './virtual' @@ -13,13 +14,17 @@ export function middleware (getMiddleware: () => ServerMiddleware[]) { return virtual({ '~serverMiddleware': () => { const middleware = getMiddleware() - const dumped = dumpMiddleware(middleware) - if (dumped !== lastDump) { - lastDump = dumped - if (middleware.length) { - console.log('\n\nNitro middleware:\n' + dumped) + + if (!stdenv.test) { + const dumped = dumpMiddleware(middleware) + if (dumped !== lastDump) { + lastDump = dumped + if (middleware.length) { + console.log('\n\nNitro middleware:\n' + dumped) + } } } + return ` ${middleware.filter(m => m.lazy === false).map(m => `import ${getImportId(m.handle)} from '${m.handle}';`).join('\n')} diff --git a/packages/nitro/src/utils/tree.ts b/packages/nitro/src/utils/tree.ts index 15e6607774..2f20ad83f3 100644 --- a/packages/nitro/src/utils/tree.ts +++ b/packages/nitro/src/utils/tree.ts @@ -4,8 +4,13 @@ import prettyBytes from 'pretty-bytes' import gzipSize from 'gzip-size' import { readFile } from 'fs-extra' import chalk from 'chalk' +import stdenv from 'std-env' export async function printFSTree (dir) { + if (stdenv.test) { + return + } + const files = await globby('**/*.*', { cwd: dir }) const items = (await Promise.all(files.map(async (file) => {